This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Jason, I have noticed a few issues with a bar chart of a monthly time series that the attached solution demonstrates. If you run the attached solution please notice the following: 1) I put a NaN in the data series--it shows up at the top. I know I could make this disappear from a bar chart by changing the value to zero, but for varius reasons I don't like this solution. Would you mind handling the NaN for bar series like you did for the line series. 2) Notice that with X-tick spacing set to 6 the vertical gridlines coincide with bars (maybe stretch chart to see better). 3) Change X-tick spacing to 3. Though the X-Tick spacing box is bound to MajorTickSpacing property of X-Axis the chart does not update. 4) Now click the "Remake Chart" button. Though the chart clearly updated, the tick spacing of 3 is still not effective. The remake chart updates the data bound to the series (in DataContext). 5) Now check the "Clear X-Axis Min/Max" checkbox and click "Remake Chart" again. Note the tick-spacing becomes effective. This check box causes the X-Axis Minimum and Maximum properties to be cleared each time the data is updated. It appears that you have to somehow force a reset of these properties to get the tick spacing to update properly. This can also be accomplished by changing the Start Month. 6) Now notice that the vertical gridline pass between bars (more or less). This seems kind of random. I would like to be able to control where the gridline appear relative to bars, but I can't see how to control this. 7) Notice the X-axis minor ticks have no relation to the data. It always seems to draw 4 minor ticks between each major. It would be nice to be able to control this. For example, I might want to have a major tick one a year and minor ticks once per quarter. Also, the minor tick on/off has the same updaing issue as the major tick spacing. 8) Notice that with tick spacing set to 3 the first data point (April 2002), appears in the middle of the Y-axis and the first gridline. Now April is the first month of the secong quarter. With tick-spacing set to 3 it would be better to have months grouped by quarters. I don't see how the chart decides where to draw the first bar (try changinh the tick-spacing back to 6 or 12 then updating). Is there a way to control this? 9) Notice the X-axis labels start with April because that is the first data point. I would probably prefer to label each January, or maybe just put a year label once a year (relying on the major and minor ticks to make it clear which month is which. I know I can control the label frequency with the label step property, but I would also like to control whci label is the first label. It's very important for me to be able to present labels and gridlines so that the user can see a bar and easily figure out which month it actually corresponds to. 10) The x-axis labels dissappear for some values--try values between -6 and -23. I know this is a lot of stuff. Thanks Peter |
|
|
Hello Peter Thanks for all the feed back. We will be looking into all these items throughout next week. -Jason |
|
|
Hello Peter Thanks for the repro sample, this has been helping a lot. If you download the current nightly builds, you'll find that bar charts now support missing data points using null or NaN values. I'll be working on the remaining items next work. Sorry for the delay. Regards Jason Fauchelle |
|
|
Hello Peter 3/4/5) This issue has now been resolved. Changing the MajorTickSpacing property at runtime will cause the axis to be updated. 7) ChartAxis now has a MinorTickMarkCount property which lets you specify the number of minor tick marks to render between each major tick mark. The MinorTickMarkVisibility updating issue has also been resolved. The fixes for the issues above will be available in the next nightly build. 10) I think what you are talking about here is a cause of the automatic label step feature. The axis will skip some of the labels based on the size of the labels and the size of the chart control. This is to prevent label overlaps. This can be controlled by setting the LabelStep property. If you set this to 1, then all labels can be displayed. Just be aware that this can get messy if the are lots of labels and the chart is small. For your remaining points (2, 6, 8 and 9) I will look into providing some options to give you more control of how data gets rendered. This is going to take a bit of time to get it right and to make sure that these options behave nicely with the existing axis options. I'll try get these ready by next week. While you're waiting, if you could send me some images of how you roughly want the data to be rendered relative to the tick marks etc, then this would help me clarify exactly what you want. Below is some explanation of why you are seeing the data being rendered in the way you have described. 2) This is expected behaviour. Here is the reasoning: Wherever you see a label, this is where the data is going to be rendered. The first label is April 2002 which gets rendered between the first and second major tick marks. That means the data for April 2002 will also be rendered between the first and second major tick marks. April 2002 does not represent the entire space between these 2 major tick marks, instead it is the plotting position exactly between the 2 tick marks. Same goes for October 2002 which is between the 2nd and 3rd major tick marks (when tick spacing is 6). Now, inclusively between April 2002 and October 2002 there are 7 data points. These data points are rendered with equal size between the center of the 2 labels. Since this is an odd number, the center data point is rendered exactly between the 2 labels. This happens to be where the grid lines are rendered as well. 6) Considering the reasoning for number 2, when the tick spacing is set to 3, there will be 4 data points inclusively between labels. Since this is an even number, the grid lines end up going between the data points. 8) As mentioned above, wherever a label is, that is where the appropriate data is going to be rendered. When you have larger tick spacing values, the pixel spacing between each major tick mark is increased. The labels are rendered exactly between tick marks meaning the first data point is rendered further away from the Y axis. Jason Fauchelle |
|
|
Hi Jason, Thanks for your work on this. Sorry for the delay in responding to your post. I have been pulled onto a different project for a while so I am just now able to get back to this. I have confirmed the updating issues have been resolved, and the MinorTickMarkCount property works as advertised. One minor quibble is that the apparent default for this property (seems to be 4) doesn't make much sense to me for a bar chart. I would think something like (MajorTickSpacing - 1) would make more sense, so that the number of minor ticks would correspond to the bars. However, since I can control this no big deal. Rather than sending pictures I think I can desribe my needs more effectively. I forsee basically two scenarios for bar charts: 1) Arbitrary categories. In this case I need to label every bar group, and if labels don't fit I can rotate them or choose a smaller font. I think your chart will work fine for this scenario. 2) Time Series. In this case I might have a lot of bars, and I need a way to lay out the gridlines, tick marks, and labels so the user can tell which bar corresponds to which month (or other period). I think the obvious way to do this is to set the MajorTickSpacing to 3, 6, or 12 (depending on the number of months) so each major tick corresponds to a quarter, half year, or year. However, it will make the most sense to the user if these are calendar quarters (Jan-Mar, Apr-Jun, etc), calendar half years (Jan-Jun, Jul-Dec), or calendar years. In this scenario I think it makes more sense to draw the gridlines between bars, whether or not I am showing quarters (odd MajorTickSpacing) or other (even MajorTickSpacing). So here are some features I think would be very useful: a) A property to control whether major ticks should fall on bars (or bar groups), between bars, or the current scheme where it depends on whether MajorTickSpacing is odd or even. b) Properties to control where the first major tick and bar are placed. Lets assume for the moment that my data series starts in January and I have set MajorTickSpacing to 3. Currently the chart seems to place the first major tick/gridline 3 bar-group widths from the y-axis, and place the first bar-group (Jan) half way between the y-axis and the first tick/gridline, which results in first major tick coming betweem Feb and March, and the next major tick coming between May and Jun. This is just not sensible for my scenario. The problem arises from the padding the chart has inserted to the left of the first bar to get the first bar in the middle of the space between the y-axis and the first major tick. I would like to eliminate this padding in this case, so that the first bar is right next to the y-axis. Then the major ticks would fall nicely between calendar quarters. Now lets assume that my data started in February. Now either I would like the padding back, or I would like to move the first major tick one position to the left so the major ticks would still dilineate calendar quarters. Really I would like to be able to control both of these. c) A property to control the first bar to be labeled, and probably to control the label step on a bar-group level, rather than on the major-tick level. Currently if the LabelStep is 1 it means that the middle bar between each pair of major ticks is labeled. If the LabelStep is 2 then the middle bar between every other pair of major ticks get's labeled. If I am going to label the individual bars I would rather label the first bar in each quarter (Jan, Apr, Jul...) rather than the middle one. Or maybe I would want to label more than one bar between each pair of ticks. Right now I just don't have enough control over which bars get labeled. Lastly, I have noticed what appears to be a bug in how the chart updates in some circumstances. To see it please run the attached project. Try clicking the Start Month a couple of months to the right (later)--only the axis labels change, which is correct since the same data is being plotted except for the dates. Now please restart the program and click the Start Month to the left (earlier). This time the bars change, which is not correct. Notice as you continue to click to the left the dates on the axis start to wrap. A attached a picture (chart.pnj) Thanks Peter |
|
|
Hello Peter Thanks for this fantastic feedback. I have already been planning to implement some of this functionality soon. With this feedback I have come up with some more ideas of how to do this. It will be about 3 to 4 weeks before we can get this fully complete but I'll keep you posted as we make progress. Jason Fauchelle |
|
|
Hi Jason, Thanks for the quick response, as usual. I do understand that this could take some time, and waiting for a few weeks is not a problem for me--I have plenty of other things to keep me busy. Looking forward to your updates. Peter |
|
|
Hello Peter Although none of these items are ready yet, I thought I'd let you know that I've done some internal refactoring in preparation for implementing these features. This is coming along well and I'll let you know more as I progress. Regards Jason Fauchelle |
|
|
Hello Peter I'm working on these items this week. I'll let you know when they are ready for you to try out. Jason Fauchelle |
|
|
Hello Peter The first update for these issues will be available in the next nightly build. First off, the padding between the Y axis and the first bar has been considered to be a bug, so this has been resolved. The first bar will always be drawn close to the Y axis (as long as ChartAxis.LabelLayout is set to Inside - this is set by default). Next, I've added a LabelSpacing property to the ChartAxis which will allow you to specify any logical spacing between the labels. By default this will be the same as the MajorTickSpacing which is the current behavior. So if you needed to, you could set the MajorTickSpacing to be 3 so there is a tick mark every 3 bars, but set the LabelSpacing to be 1 so every bar gets labelled. By default, the labelling will start at the first bar, and the tick marks will be half way between each label. Again this is the current behavior. But for your scenario, you'll want to adjust this so the ticks are placed between quarters (Jan-Mar etc). To do this you can use the TickMarkOffset and LabelOffset properties. For example, say you set the MajorTickSpacing property to 3. The first bar (Jan) and fourth bar (Apr) gets labelled, and a tick mark is placed between them. In this case the tick mark will be placed right between the Feb and Mar bars. This is 1 bar away from where you want it to be, so set the TickMarkOffset property to 1. Now you'll have tick marks clearly separating annual quarters, and the first bar of each quarter will be labelled. If you want labels to be centred between the tick marks in this scenario, then set the LabelOffset property to also be 1. Now the middle bar of each quarter instead of the first bar will be labelled. A good trick to get the right settings for different MajorTickMark values is to first run up the application without setting the offset properties. Then see how far off the tick marks are from where you want them to be rendered, and use this to set the offset properties. If you set the MajorTickSpacing to be 6, when you run it up you will see the tick marks are lining up with the bars instead of between the bars. I've mentioned the reason for this before since 6 is an even number, and 3 is an odd number. So this time, set the TickMarkOffset to be 2.5 to get the desired result. With the new LabelSpacing, TickMarkOffset and LabelOffset properties you'll have a lot of control on how labels and tick marks are positioned. When the next nightly build is available, try this out and let me know if you have any questions or need help with a particular scenario. I'll be looking into the bug you mentioned soon. Jason Fauchelle |
|
|
Hello Peter The next nightly build will have a fix for the bug you demonstrated in the repro project. Jason Fauchelle |
|
|
Hi Jason, I am very pleased to read about the improvements you have made. Right now I am a bit tied up with other things, but I hope to be able to test the new version in a week or so. Peter |
|
|
Hi Jason, Much later than expected I finally got to test the changes you made for adjusting ticks and lables on bar charts, and I do find that I can now get the arrangement I want. Thanks! One residual question: Prior to your fix there could be a variable amount of space between the Y-axis and the first bar, which could be quite large and could not be controlled by me (thanks for fixing that). Now, however, on a chart with many bars there might be essentially no space between the y-axis and first bar. I think a little space could improve the visual appeal. Is there a good way I can add a little space between the y-axis and first bar, and between the last bar and the right edge of the plot area? Of course this should result in moving the ticks and labels slightly to stay aligned with the bars. Peter |
|
|
Hello Peter In the next nightly build you will be able to use the ChartAxis.Padding property to get this behavior. This padding property is just the usual Control.Padding property which is of type Thickness. So in xaml you can set this value with 1, 2 or 4 numbers separated by commas. The XAxis only uses the Left and Right values, and the YAxis only uses the Top and Bottom Values. If you want the padding at both ends of the XAxis to be the same, simply set the Padding property of the XAxis to be the number of pixels you want to pad the data by. This will also affect the tick marks and labels. Jason Fauchelle |
|