Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sat Sep 02, 2017 3:18 pm

Hello

1- Assume we have an xy-scattered chart with many data series, and data of each series is located somewhere else in work book. Like:
Series-1, x values-> A1:A10
Series-1, Y values-> C1:C10
Series-2, x values-> B1:B10
Series-2, y values-> D1:D10
How can I add this kind of data series to an existing chart? How is it to create an instance of Spire.Xls.Charts.ChartSerie?

2- How to enforce a serie to use secondary x axis?

ahmadi_rad@yahoo.com
 
Posts: 43
Joined: Thu Apr 13, 2017 3:53 pm

Mon Sep 04, 2017 5:59 am

Hello,

Sorry for late reply as weekend.
Here is sample code for your reference.
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"F:\testing\xls test form\sample document\Sample.xlsx");
            Worksheet sheet = workbook.Worksheets[0];
            //get the chart
            Chart chart = sheet.Charts[0];
            //add a new series to the chart
            ChartSerie cs = chart.Series.Add(ExcelChartType.ScatterLine);
            //set the series name
            cs.Name = sheet.Range["B16"].Value;
            // set the X value
            cs.CategoryLabels = sheet.Range["A17:A25"];
           //set the Y value
            cs.Values = sheet.Range["B17:B25"];
           //use the secondary Axis
            cs.UsePrimaryAxis = false;
           //set the tick label position.
            chart.SecondaryValueAxis.TickLabelPosition = TickLabelPositionType.TickLabelPositionHigh;
            //save the file
            workbook.SaveToFile("11525.xlsx",ExcelVersion.Version2013);

If there is still issue, please get back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Sep 05, 2017 9:28 am

Hello,

Did you test the code I provided ?
Has your issue been resolved ?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Sep 05, 2017 2:48 pm

Hello

Please give me some time, I'm implementing it in a complicated structure. I will inform you as soon as it is done.
Thanks for your kind efforts.

Regards

ahmadi_rad@yahoo.com
 
Posts: 43
Joined: Thu Apr 13, 2017 3:53 pm

Wed Sep 06, 2017 1:57 am

Hello,

Thanks for your feedback.
And looking forward to your response after testing.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS