User (Legacy) Posted March 20, 2003 Report Share Posted March 20, 2003 I have an app where a user can add or remove series to a chart on the fly. My chart's DataSource uses the ListProvider construct and a Collection which will contain an ArrayList for each Series to be displayed - the Dimension statements look like this: Dim colAllSeries As New Collection() Dim lpvListProvider As New ListProvider(colAllSeries) Each time the user changes what set of series he/she wants to see, I call a procedure (LoadChart); the first thing it does is execute a "chart.cleardata(AllData)", followed by a "chart.DataSource = Nothing". Then I figure out what Series he/she wants to display, and add them to the colAllSeries collection. At the end of the routine I set the chart's DataSource = lpvListProvider, and do a RecalcScale on it. In between I set up multiple Y Axes on the chart - one for each series the user picks - setting the color to match the series color and setting the Axis Position property to "Near". I DON'T set the Min/Max because I do a RecalcScale at the end of the LoadChart routine. Weird things that aren't bugs but are sort of weird to code with: 1) "Near" and "Far" for position instead of "Left" and "Right" (or "Top" and "Bottom" in the case of a Gantt chart). No biggie, you just have to know what "Near" means... 2) Axis(2) is the X AXIS of the chart. Axis(0) is the first series Y axis, Axis(1) is the second series Y axis, then it hops to Axis(3) for the third Y axis - that took a bit of figuring out... 3) With the second series, you set the Y Axis to "Secondary", but for all subsequent series, you set it to 3, 4, 5 etc. Funky - makes me have to put an IF statement in to see what series I'm on. So far so good - does what I want. Except... 1) Sometimes the series the user selects.has all zeros in it. When that happens, I don't get a Y Axis for it - the chart "scoots over to the right" like it's supposed to draw a Y axis there, but it doesn't actually draw it. 2) Let's say the user selects 5 items to chart. Then the user selects a single series to chart. Even after doing the ClearData followed by the DataSource=Nothing, if I query the chart's Axis.Count property, it will still read "6" (remember, it's counting the X Axis too). Which leads me to the third problem which is thre real bad one: 3) After adding and subtracting series back and forth a few times, including ones that have all 0s in them, the chart starts "leaving" Y Axes there for series that aren't in the chart anymore. All I can do at this point is close the form and open it back up again. 4) (related to #3) sometimes the "leftover Y Axis" is for a series that had all 0s, so I wind up with a blank space on the left side of the chart before the "real" Y Axis appears. Any ideas? --TG Link to comment Share on other sites More sharing options...
Software FX Posted March 20, 2003 Report Share Posted March 20, 2003 >> Weird things that aren't bugs but are sort of weird to code with: >>1) "Near" and "Far" for position instead of "Left" and "Right" (or "Top" >> and "Bottom" in the case of a Gantt chart). Because .NET also uses this concept (e.g. when painting strings) we thought people would eventually get used to the Near-Center-Far approach. I agree it is not necessarily obvious what Near means in a specific context. Note that the Axis object exposes an alignment property and independently you specify whether the axis is a Y axis or X axis. I guess we could have defined Left and Top with the same numerical value and Right and Bottom with another. >> 2) Axis(2) is the X AXIS of the chart. Axis(0) is the first series Y >> axis, Axis(1) is the second series Y axis, then it hops to Axis(3) for the >> third Y axis - that took a bit of figuring out... There is an enumeration (AxisItem) that contains this "implementation-detail". We kept this order for historical reasons, our COM version used that approach and we did not want to break code previous customers wrote if they did not use the predefined constants (in the ASP scenario people would just use the numbers instead of the symbolic names). >> 3) With the second series, you set the Y Axis to "Secondary", but for all >> subsequent series, you set it to 3, 4, 5 etc. Funky - makes me have to put >> an IF statement in to see what series I'm on. I agree, we thought that 2 axes is a lot more frequent than unlimited number of access so we wanted to make it real easy to set a secondary Y axis. In your case I would recommend you do not use Secondary and use 3,4,5 for all your axes (except of course for the first series that should use the main Y axes). >> 1) Sometimes the series the user selects.has all zeros in it. When that >> happens, I don't get a Y Axis for it - the chart "scoots over to the right" >> like it's supposed to draw a Y axis there, but it doesn't actually draw it. This should probably not happen (I think it is caused by the fact that an axis will not be painted if min=max) but we would need a way to duplicate this issue (sample code). You can workaround this issue by looping through the axes collection after you pass the data and do the recalc and set the max to 1 (or any other positive number) to any axis where axis.min == axis.max >> 2) 3) and 4) Please add this code after the ClearData call chart1.Axis.Count = 4; This will reset the number of axes to the default state (4 axes - 2 Y - 2 X). This will work if you follow my recommendation and you do not use Secondary and use 3,4,5 for all your axes (except of course for the first series that should use the main Y axes). -- Regards, JC Software FX Support "TG" <timg@pgas.com> wrote in message news:0xRqfsw7CHA.1564@webserver1.softwarefx.com... > I have an app where a user can add or remove series to a chart on the fly. > My chart's DataSource uses the ListProvider construct and a Collection which > will contain an ArrayList for each Series to be displayed - the Dimension > statements look like this: > > Dim colAllSeries As New Collection() > Dim lpvListProvider As New ListProvider(colAllSeries) > > Each time the user changes what set of series he/she wants to see, I call a > procedure (LoadChart); the first thing it does is execute a > "chart.cleardata(AllData)", followed by a "chart.DataSource = Nothing". > Then I figure out what Series he/she wants to display, and add them to the > colAllSeries collection. At the end of the routine I set the chart's > DataSource = lpvListProvider, and do a RecalcScale on it. > > In between I set up multiple Y Axes on the chart - one for each series the > user picks - setting the color to match the series color and setting the > Axis Position property to "Near". I DON'T set the Min/Max because I do a > RecalcScale at the end of the LoadChart routine. > > Weird things that aren't bugs but are sort of weird to code with: > 1) "Near" and "Far" for position instead of "Left" and "Right" (or "Top" > and "Bottom" in the case of a Gantt chart). No biggie, you just have to > know what "Near" means... > 2) Axis(2) is the X AXIS of the chart. Axis(0) is the first series Y > axis, Axis(1) is the second series Y axis, then it hops to Axis(3) for the > third Y axis - that took a bit of figuring out... > 3) With the second series, you set the Y Axis to "Secondary", but for all > subsequent series, you set it to 3, 4, 5 etc. Funky - makes me have to put > an IF statement in to see what series I'm on. > > So far so good - does what I want. Except... > 1) Sometimes the series the user selects.has all zeros in it. When that > happens, I don't get a Y Axis for it - the chart "scoots over to the right" > like it's supposed to draw a Y axis there, but it doesn't actually draw it. > 2) Let's say the user selects 5 items to chart. Then the user selects a > single series to chart. Even after doing the ClearData followed by the > DataSource=Nothing, if I query the chart's Axis.Count property, it will > still read "6" (remember, it's counting the X Axis too). Which leads me to > the third problem which is thre real bad one: > 3) After adding and subtracting series back and forth a few times, > including ones that have all 0s in them, the chart starts "leaving" Y Axes > there for series that aren't in the chart anymore. All I can do at this > point is close the form and open it back up again. > 4) (related to #3) sometimes the "leftover Y Axis" is for a series that > had all 0s, so I wind up with a blank space on the left side of the chart > before the "real" Y Axis appears. > > Any ideas? > > --TG > > Link to comment Share on other sites More sharing options...
User (Legacy) Posted March 21, 2003 Author Report Share Posted March 21, 2003 Thanks for the response - 50% hit/miss ratio. See below... "Software FX Support" <support@softwarefx.com> wrote in message news:2T9dbXx7CHA.1564@webserver1.softwarefx.com... > >> 1) Sometimes the series the user selects.has all zeros in it. When that > >> happens, I don't get a Y Axis for it - the chart "scoots over to the right" > >> like it's supposed to draw a Y axis there, but it doesn't actually draw it. > > This should probably not happen (I think it is caused by the fact that an > axis will not be painted if min=max) but we would need a way to duplicate > this issue (sample code). You can workaround this issue by looping through > the axes collection after you pass the data and do the recalc and set the > max to 1 (or any other positive number) to any axis where axis.min == > axis.max This worked - thanks. I actually did a "min -= 1" and "max +=1" so that the straight horizontal line would appear in the middle of the graph. > >> 2) 3) and 4) > > Please add this code after the ClearData call > > chart1.Axis.Count = 4; > > This will reset the number of axes to the default state (4 axes - 2 Y - 2 > X). This will work if you follow my recommendation and you do not use > Secondary and use 3,4,5 for all your axes (except of course for the first > series that should use the main Y axes). This didn't work. Here's the details: First, I did something you implied NOT to do, just for the sake of completeness - I continued assigning the second series to YAxis.Secondary, and the third and subsequent series used Axis(3), Axis(4), Axis(5), etc. Here's what happened: 1) When first displaying the form with the chart on it, before ANYTHING is sent to the chart (user hasn't selected anything yet), it executes the "chart.axis.count = 4" line fine. 2) User picks a single series to display, again, it executes that line fine. 3) User picks a second series to display with the first one, again, no problems. Ditto for always increasing the number of series being displayed. 4) As soon as I REDUCE the number of series to be charted, I get a "Destination array was not long enough. Check destIndex and length, and the array's lower bounds." error, which seems to be getting fired from the SoftwareFX.ChartFX.AxisCollection.set_Count(Int32 value) function. Ok, not a big deal - that's probably because I'm using the Series(1).YAxis = YAxis.Secondary code which you implied not to do. So, I changed the code - now, every series after the first one gets set to the "SeriesCounter + 2" YAxis. Interesting side note: the book says to do this in the example: Chart1.Series(2).YAxis = 3 This code will not work if you have Option Strict on. So my code instead looks like this - is this correct?: Chart1.Series(2).YAxis = CType(3, SoftwareFX.ChartFX.YAxis) Anyway, getting back to my code - if the series I'm adding to the chart is not the first series (my intSeriesCounter variable starts at 0 for the first one), I execute this code: Chart1.Series(intSeriesCounter).YAxis = CType(intSeriesCounter + 2, SoftwareFX.ChartFX.YAxis) Well, I get the same "Destination array" error when it hit's the Chart1.Axis.Count = 4 line whenever I REDUCE the number of series I'm charting. Is there any other way to manually remove an Axis from the Axis collection of the Chart? I'm willing to cycle through all of them to remove the ones I'm not using. Right now, my only other option is to manually hide the one's I'm not using, and that's not a great solution because they retain the old Min/Max settings from whatever series was in that "Axis position". --TG Link to comment Share on other sites More sharing options...
Software FX Posted March 21, 2003 Report Share Posted March 21, 2003 >> 4) As soon as I REDUCE the number of series to be charted, I get a >> "Destination array was not long enough. Are you using a recent build for ChartFX. We fixed a bug when the AxisCollection count property is set to a number smaller than the current number of axes. >> First, I did something you implied NOT to do, just for the sake of completeness - I suggested this because it would make your code a little cleaner (you only treat the first series in a different fashion) and because not using the secondary would mean setting the Axis.Count to 4 would in fact "clean-up" the axes. If you INSIST :-) in not following my suggestion not to use the secondary axis you can set its visible property to false along with the Axis.Count = 4 call. >> So my code instead looks like this - is this correct?: >> Chart1.Series(2).YAxis = CType(3, SoftwareFX.ChartFX.YAxis) Yes, We had to decide between 2 evils, make the YAxis a numeric property and people have to guess which number is the main and/or secondary axis or make the YAxis an enumeration and force people with more than 2 axes to cast. Note that setting the property to an enumeration gives us also Intellisense support and makes it easier at design time. For any C# programmers, you would have to write Chart1.Series[2].YAxis = (SoftwareFX.ChartFX.YAxis) 3; -- Regards, JC Software FX Support "TG" <timg@pgas.com> wrote in message news:nb#xXb87CHA.3240@webserver1.softwarefx.com... > Thanks for the response - 50% hit/miss ratio. See below... > > "Software FX Support" <support@softwarefx.com> wrote in message > news:2T9dbXx7CHA.1564@webserver1.softwarefx.com... > > > >> 1) Sometimes the series the user selects.has all zeros in it. When > that > > >> happens, I don't get a Y Axis for it - the chart "scoots over to the > right" > > >> like it's supposed to draw a Y axis there, but it doesn't actually draw > it. > > > > This should probably not happen (I think it is caused by the fact that an > > axis will not be painted if min=max) but we would need a way to duplicate > > this issue (sample code). You can workaround this issue by looping through > > the axes collection after you pass the data and do the recalc and set the > > max to 1 (or any other positive number) to any axis where axis.min == > > axis.max > > This worked - thanks. I actually did a "min -= 1" and "max +=1" so that the > straight horizontal line would appear in the middle of the graph. > > > >> 2) 3) and 4) > > > > Please add this code after the ClearData call > > > > chart1.Axis.Count = 4; > > > > This will reset the number of axes to the default state (4 axes - 2 Y - 2 > > X). This will work if you follow my recommendation and you do not use > > Secondary and use 3,4,5 for all your axes (except of course for the first > > series that should use the main Y axes). > > This didn't work. Here's the details: > > First, I did something you implied NOT to do, just for the sake of > completeness - I continued assigning the second series to YAxis.Secondary, > and the third and subsequent series used Axis(3), Axis(4), Axis(5), etc. > Here's what happened: > 1) When first displaying the form with the chart on it, before ANYTHING is > sent to the chart (user hasn't selected anything yet), it executes the > "chart.axis.count = 4" line fine. > 2) User picks a single series to display, again, it executes that line fine. > 3) User picks a second series to display with the first one, again, no > problems. Ditto for always increasing the number of series being displayed. > 4) As soon as I REDUCE the number of series to be charted, I get a > "Destination array was not long enough. Check destIndex and length, and the > array's lower bounds." error, which seems to be getting fired from the > SoftwareFX.ChartFX.AxisCollection.set_Count(Int32 value) function. > > Ok, not a big deal - that's probably because I'm using the Series(1).YAxis = > YAxis.Secondary code which you implied not to do. > > So, I changed the code - now, every series after the first one gets set to > the "SeriesCounter + 2" YAxis. > > Interesting side note: the book says to do this in the example: > Chart1.Series(2).YAxis = 3 > > This code will not work if you have Option Strict on. So my code instead > looks like this - is this correct?: > Chart1.Series(2).YAxis = CType(3, SoftwareFX.ChartFX.YAxis) > > Anyway, getting back to my code - if the series I'm adding to the chart is > not the first series (my intSeriesCounter variable starts at 0 for the first > one), I execute this code: > Chart1.Series(intSeriesCounter).YAxis = CType(intSeriesCounter + 2, > SoftwareFX.ChartFX.YAxis) > > Well, I get the same "Destination array" error when it hit's the > Chart1.Axis.Count = 4 line whenever I REDUCE the number of series I'm > charting. > > Is there any other way to manually remove an Axis from the Axis collection > of the Chart? I'm willing to cycle through all of them to remove the ones > I'm not using. Right now, my only other option is to manually hide the > one's I'm not using, and that's not a great solution because they retain the > old Min/Max settings from whatever series was in that "Axis position". > > --TG > > Link to comment Share on other sites More sharing options...
User (Legacy) Posted March 24, 2003 Author Report Share Posted March 24, 2003 See below... "Software FX Support" <support@softwarefx.com> wrote in message news:I31xxA97CHA.2116@webserver1.softwarefx.com... > >> 4) As soon as I REDUCE the number of series to be charted, I get a > >> "Destination array was not long enough. > > Are you using a recent build for ChartFX. We fixed a bug when the > AxisCollection count property is set to a number smaller than the current > number of axes. Here are the version numbers for the DLLs I'm referencing - where can I go on the site to download updates if I need them? ChartFX.Base.dll 6.0.937.27448 ChartFX.Data.dll 6.0.839.0 ChartFX.dll 6.0.839.0 ChartFX.Borders.dll 6.0.937.27455 --TG Link to comment Share on other sites More sharing options...
Software FX Posted March 24, 2003 Report Share Posted March 24, 2003 http://support.softwarefx.com/cfxnet -- Regards, JC Software FX Support "TG" <timg@pgas.com> wrote in message news:JTyzLih8CHA.2116@webserver1.softwarefx.com... > See below... > > "Software FX Support" <support@softwarefx.com> wrote in message > news:I31xxA97CHA.2116@webserver1.softwarefx.com... > > >> 4) As soon as I REDUCE the number of series to be charted, I get a > > >> "Destination array was not long enough. > > > > Are you using a recent build for ChartFX. We fixed a bug when the > > AxisCollection count property is set to a number smaller than the current > > number of axes. > > Here are the version numbers for the DLLs I'm referencing - where can I go > on the site to download updates if I need them? > > ChartFX.Base.dll 6.0.937.27448 > ChartFX.Data.dll 6.0.839.0 > ChartFX.dll 6.0.839.0 > ChartFX.Borders.dll 6.0.937.27455 > > --TG > > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.