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
|
I find that when I add data labels to a scatter series using the LabelBinding property of the series, and with my own DataLabelStyle the first data label does not properly show up (no content). If I don't specify my own DataLabelStyle then all the labels do appear, but with Y values, rather then the values from by LabelBinding. From Snoop I notice that the DataPoint property of the first DataLabel is set to a CartesianDataPoint with a null LabelContent, whereas the other labels have their DataPoint property set to a ChartSymbol with the LabelContent as specified by the LabelBinding. Demo code is below. Just run it and not that the first label is always blank (should be "A"). A couple of other issues: 1) If I don't specify a custom DataLabelStyle shouldn't the content specified by the label binding still be used? This is not of much concern to me because it is not a problem to specify my own label style. 2) the label placement appears to be pretty random in term of the angle, and will sometimes be placed over another point, even when a plenty of open positions are available. I had written a method that went into the label canvas and repositioned the labels in an attempt to prevent this, which worked pretty well. However, as is the risk when mucking around with the internals of someone else's control, it stopped working properly at some point and I haven't had time to fix it up. It would be very nice if the Chart control could handle label placement better, though I acknowledge that it isn't easy. An alternative would be to add something to the API that gave the programmer the ability to control label placement, like a label offset that could be relative between any label corner (programmer's choice) and the target point. Here is the demo XAML:
Here is the C#
|
|
|
Hello Peter Thanks for pointing out the issue with displaying data in the first label. This will be resolved in the next nightly build. You are right that the default label style should really respect the LabelBinding feature. This is on my todo list. The label placement algorithm for scatter series is the same as with line series which take the previous and next data points into consideration to try and avoid putting a label over a line. This make the label placement for scatter series look random though as there is no line. I had experimented with writing an algorithm that minimized data point and label overlaps, but as you mentioned, it isn't easy. I would like to finish working on this, and also plan to at least provide a way for developers to provide their own label positioning logic, but I am not sure when I will be able to do this. I hate to say this, but you may need to stick to hacking the visual tree for now if you need this functionality right now. -Jason Fauchelle |
|
|
Hi Jason, The first label does display correctly now--thanks. Peter |
|