We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Secondary Axis problem

Hi all,

i've some understanding problem at the creating of a secondary axis in the XlsIO Interface. I'm creating a chart with the following code.

// create chart worksheet
IChart chart = chartBook.Charts.Add("Test");

After that i will create a secondary y-Axis with:

chart.SecondaryValueAxis.IsMaxCross = false;
chart.SecondaryCategoryAxis.IsMaxCross = true;

but the chart.SecondaryCategoryAxis is at every time null.

But how can i create a secondary axis? Must i use the IChartCategoryAxis Interface?


Regards,
Stephan


16 Replies

SD Steffen Dunst June 3, 2008 08:03 AM UTC

I'm using the following chartType:

chart.ChartType = ExcelChartType.Column_Clustered;

Stephan


>Hi all,

i've some understanding problem at the creating of a secondary axis in the XlsIO Interface. I'm creating a chart with the following code.

// create chart worksheet
IChart chart = chartBook.Charts.Add("Test");

After that i will create a secondary y-Axis with:

chart.SecondaryValueAxis.IsMaxCross = false;
chart.SecondaryCategoryAxis.IsMaxCross = true;

but the chart.SecondaryCategoryAxis is at every time null.

But how can i create a secondary axis? Must i use the IChartCategoryAxis Interface?


Regards,
Stephan





YG Yavanaarasi G Syncfusion Team June 3, 2008 01:15 PM UTC

Hi Stephan,

Thank you for your interest in Syncfusion products.

How can i create a secondary axis?

You can create the secondary axis by using the below code snippet:

//Use Secondary Axis
serieOne.UsePrimaryAxis = false;
if (chart.SecondaryValueAxis != null)
{
//Set Secondary Value Axis Title.
chart.SecondaryValueAxis.Title = "Secondary Value Axis";
chart.SecondaryCategoryAxis.Title = "Secondary Category Axis";
}

//Display secondary axis.
chart.SecondaryValueAxis.IsMaxCross = true;
chart.SecondaryCategoryAxis.IsMaxCross = true;

Here is the sample for your reference:

http://websamples.syncfusion.com/samples/XlSIO.Windows/F74183/main.htm

Please try this and let me know if this helps.

Regards,
G.Yavana




SD Steffen Dunst June 4, 2008 06:38 AM UTC

Hi,

okay i think it work's now on my project, but i have one last question.

I have ab SyncfusionChartWeb Control with a ChartSeriesCollection of four series. If a series had a specified name, i say that this series should be displayed on the second axis.

// run through the ChartSeriesCollection
for (int i = 0; i < Series.Count; i++)
{
IChartSerie series = chart.Series.Add(Series[i].Name);
if (Series[i].Name.Contains("Base"))
{
series.UsePrimaryAxis = false;
}
if (chart.SecondaryValueAxis != null)
{
//Set Secondary Value Axis Title.
chart.SecondaryValueAxis.Title = "Secondary Value Axis";
chart.SecondaryCategoryAxis.Title = "Secondary Category Axis";
}
}

If the first series in the ChartSeriesCollection is the series which i will display on the second axis, there is an error (Screen enclosed).

If the series is the second, third or fourth everything is fine and it works correctly.

Regards,
Stephan



Error_3cfd8a79.zip


YG Yavanaarasi G Syncfusion Team June 4, 2008 11:38 AM UTC

Hi Stephan,

This issue occurs when the chart has a single serie. From your update, it looks like the second serie is not created when calling first serie for creating secondary axis. This is the behavior of Excel too where user can’t create secondary axis when there is single serie in chart. To rectify this issue, please make sure that you create secondary axis after adding all the other series to the chart. i.e, please move the series.UsePrimaryAxis statement after adding all the series.

Please let me know if the issue still exists.

Regards,
G.Yavana




SD Steffen Dunst June 4, 2008 02:02 PM UTC

Thank you about this information.

Stephan



SD Steffen Dunst June 13, 2008 11:40 AM UTC

Hi all,

one question to the secondary axis. I've created three Serieses and now i will the first series "Base" was displayed one the secondary y-axis and the two other series "Portfoliopreis" and "Marktpreis" should be displayed on the primary y-Axis.

Could you explain me what is wrong.



But with the code beneath it doesn't work correctly.

if (l_ChartID == "chartMTMJahr")
{ chart.PrimaryCategoryAxis.NumberFormat="mm/yy";

for (int j = 0; j < chart.Series.Count; j++)
{
if (chart.Series[j].Name.Contains("Base"))
{ chart.Series[j].UsePrimaryAxis = false;
if (chart.SecondaryValueAxis != null)
{
//Set Secondary Value Axis Title. chart.SecondaryValueAxis.Title = l_TitleYAxis2;

Color bufColor = chart.Series[j].SerieFormat.LineProperties.LineColor;
chart.Series[j].SerieType = ExcelChartType.Line;
chart.Series[j].SerieFormat.LineProperties.LineColor = bufColor;
}
}
else if (chart.Series[j].Name.Contains("Portfoliopreis"))
{
chart.Series[j].UsePrimaryAxis = true;
Color bufColor = chart.Series[j].SerieFormat.LineProperties.LineColor;

chart.Series[j].UsePrimaryAxis = true;

chart.Series[j].SerieType = ExcelChartType.Area;
chart.Series[j].SerieFormat.AreaProperties.BackgroundColor = Color.White;
chart.Series[j].SerieFormat.AreaProperties.ForegroundColor = bufColor;

}
else
{
chart.Series[j].UsePrimaryAxis = true;

Color bufColor = chart.Series[j].SerieFormat.LineProperties.LineColor;
chart.Series[j].SerieType = ExcelChartType.Line;
chart.Series[j].SerieFormat.LineProperties.LineColor = bufColor;
}

}
//Display secondary axis.
chart.SecondaryValueAxis.IsMaxCross = false;
chart.SecondaryCategoryAxis.IsMaxCross = true;
chart.ChartType = ExcelChartType.Combination_Chart;
}


Regards,
Stephan




SD Steffen Dunst June 16, 2008 05:38 PM UTC

Is there no idea?

Stephan



YG Yavanaarasi G Syncfusion Team June 17, 2008 12:40 PM UTC

Hi Stephan,

We are looking into the issue and will update you by tomorrow.

Thank you for your patience.

Regards,
G.Yavana



YG Yavanaarasi G Syncfusion Team June 18, 2008 11:19 AM UTC

Hi stephan,

If you create the chart with series by default it is displayed as a primary axis. You can set the secondary axis for a specified series. Could you please refer the sample that I have send in the previous update. In that sample the first serie is displayed as a secondary axis and other two series are displayed as primary axis. To display secondary axis you have to the set IsMaxCross property as true. But in your code you have set that property as false. This happens the problem.

Please let me know if you have any other concerns.

Regards,
G.Yavana



AD Administrator Syncfusion Team August 18, 2008 04:21 PM UTC

Hello

I've a problem with secondary axis too.
If I set MaxCross=true for my SecondaryValueAxis only, I get an Exception (Index out of Range) on saving the excel sheet.
If I set both, the Value and the Category Axis, I get the Exception as soon as I set MaxCross=true on the Category Axis.

Can you help me with my problem?

regards
Stefan



error_ca9bfc8.zip


YG Yavanaarasi G Syncfusion Team August 19, 2008 11:57 AM UTC

Hi Stefan,

I am not able to reproduce the issue that you mentioned here. I have created a sample and set IsMaxCross as true for only SecondaryValueAxis. I am not getting any exception. Also I tried with setting SecondaryCategoryAxis.IsMaxCross as true and the exception not raised. I have tested this in German windows xp.

Here is the sample for your reference:

http://www.syncfusion.com/development/uploads/F74183_9ec528d2.zip

Please take a look into the above sample and if still the issue exists, could you please try reproducing it in the above sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution?

Also specify the Essential studio version in which the issue caused.

Please refer the article in the below link for getting more details regarding XlsIO chart:
http://www.dotnettoolkit.de/products/Xlsio/backoffice/Articles/charts.aspx

Regards,
G.Yavana



AD Administrator Syncfusion Team August 19, 2008 12:10 PM UTC

Thank you for your response

The odd thing is, if I try the sample you sent (I've tried this before anyway) everything works fine.
I'll try to reproduce the error in the sample later.

Version: Essential Studio 5.1.0.51

regards
Stefan



AD Administrator Syncfusion Team September 4, 2008 09:34 AM UTC

Hello

I've sorted the errors out, it was a mistake I did in settings the ranges for the values.

Know I've just a small problem :)
If you look at the problem.jpg in the attachment you can see the output, the target.jpg shows the correct output, so the second axis is just rotated by 180°.

Where can I change this?
I've searched a lot, but the only rotation property I found is for 3D.

TIA

regards
Stefan



AD Administrator Syncfusion Team September 4, 2008 09:36 AM UTC

Now with attachement ;)

>Hello

I've sorted the errors out, it was a mistake I did in settings the ranges for the values.

Know I've just a small problem :)
If you look at the problem.jpg in the attachment you can see the output, the target.jpg shows the correct output, so the second axis is just rotated by 180°.

Where can I change this?
I've searched a lot, but the only rotation property I found is for 3D.

TIA

regards
Stefan





chart_373c151d.zip


GM Geetha M Syncfusion Team September 8, 2008 12:06 PM UTC

Hi Stefan,

Sorry for the delay and thank you for the file.

I was able to reproduce this issue and have forwarded it to our developers for more analysis. The problem was with the SecondaryCategoryAxis and SecondaryValueAxis. Could you workaround this issue by setting the IsMaxCross property of the Category axis instead of the Value axis to true?

Please refer to the sample in the below link and let me know if you have any concerns:
http://websamples.syncfusion.com/samples/XlsIO.Windows/F74183_1/main.htm

Regards,
Geetha



AD Administrator Syncfusion Team September 11, 2008 07:17 AM UTC

Hello

The problem was that I enabled the category axis too, now everything is fine. :)

Thank you for your help

regards
Stefan


Loader.
Live Chat Icon For mobile
Up arrow icon