User (Legacy) Posted November 3, 2005 Report Share Posted November 3, 2005 I'm having a lot of trouble with working with multiple YAxes when building a charts with one to many series that are dynamically selected. In my scenario, the series (or 'measures' using this project's business terminology) can belong to one of 3 datatypes which are: a) Numeric (double) Percentage (1 -100) c) Money The user can selects series with different datatypes can be mixed and matched in the same chart. Hence the chart wil lrequire a Yaxis for data type selected. So there can be a chart which has, for example: 2 series of Numeric type data - displays the Numeric Y-Axis 1 Series of Percentage type data - displays the Percentage Y-Axis 2 Series of Money type data - displays the Percentage Y Axis These series have different scales and so the need to use multiple Y-Axes. My problem has been writing the code for this scenario. I am supplying what I have done so far for creating a chart with multiple Y-Axes, but this often causes the chart to fail (big red cross with HtmlTag='Auto'). My main problem is finding how to assign the chart with Main/Secondary axes. Because they are dynamically created, I cannot assign the datatypes with specific axes numbers because there might not be a series of that type. Hence, this code might assign a chart with no Main axis or too many. If I assign the a series axis as the Main, it often fails, but I have no idea why. The single sample code example in the documentation is a hard-coded one and not very self-explanatory. Can you tell me what I'm doing wrong here: int numericAxisIndex, percentAxisIndex, moneyAxisIndex; numericAxisIndex = 1; percentAxisIndex = 2; moneyAxisIndex = 0; foreach(MeasureItem mi in ci.Measures) { series = chart1.Series[m]; //Get the series type and deal with assigning the y-Axis accordingly switch(seriesType) { case MeasureDataType.Numeric: //Numeric Axis axis = chart1.Axis[numericAxisIndex]; axis.Visible = true; axis.Grid.Color = System.Drawing.Color.Blue; axis.TextColor = System.Drawing.Color.Blue; series.YAxis = (SoftwareFX.ChartFX.YAxis)numericAxisIndex; m++; break; case MeasureDataType.Percentage: //Percentage Axis axis = chart1.Axis[percentAxisIndex]; axis.Visible = true; axis.Max = 100.00; axis.Min = 0.00; axis.Grid.Color = System.Drawing.Color.Red; axis.TextColor = System.Drawing.Color.Red; series.YAxis = (SoftwareFX.ChartFX.YAxis)percentAxisIndex; m++; break; case MeasureDataType.Money: //Money Axis axis = chart1.Axis[moneyAxisIndex]; axis.Visible = true; axis.Grid.Color = System.Drawing.Color.Green; axis.TextColor = System.Drawing.Color.Green; series.YAxis = (SoftwareFX.ChartFX.YAxis)moneyAxisIndex; m++; break; } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.