|
XY Graph with Labels for events |
Posted by Dev Kumar on May-05-2012 04:41 |
|
Hi,
I have been using Chart dir for quite a long time and for the first time I am lost about how to get this done. Its basically xy chart with some events to be labeled. I was thinking of using addMark or addCustomLabel. But none of them do what I would like to do. Is there a better option?
Thanks,
Dev
|
Re: XY Graph with Labels for events |
Posted by Peter Kwan on May-08-2012 00:42 |
|
Hi Dev,
You may add a scatter layer for the points you want to label, and use addCustomDataLabel to add the text. It is like (in Java):
ScatterLayer layer = c.addScatterLayer(dataX, dataY, "", Chart.GlassSphereShape, 11, 0xff0000);
for (int i = 0; i < dataX.length; ++i) {
ChartDirector::TextBox t = layer.addCustomDataLabel(0, i, myLabels[i], "Arial Bold", 10, 0x000000);
t.setBackground(Chart.Transparent, 0xaaaaaa);
}
In the above, dataX and dataY are the x and y coordinates of the circles. If your line do not use x-coordinates (no setXData), then the x-coordinate is considered as the array index of your data points. For example, if you want to add scatter symbols to the 7th and 19th data point of your line layer, the scatter data should be:
double[] dataX = { lineDataX[6], lineDataX[18] };
double[] dataY = { lineDataY[6], lineDataY[18] };
or
//assume line has no explicit x-coordinates
double[] dataX = { 6, 18 };
double[] dataY = { lineDataY[6], lineDataY[18] };
Hope this can help.
Regards
Peter Kwan |
Re: XY Graph with Labels for events |
Posted by Dev Kumar on May-08-2012 01:08 |
|
This is perfect for my needs.
Thanks,
Dev |
Re: XY Graph with Labels for events |
Posted by Roger on Nov-16-2012 01:35 |
|
Hi Peter,
Great product. I have an xy chart as part of my development project - displaying financial
data from a sqlite database using your one of your excellent example windows zooming and
scrolling apps.
The Java code for adding labels to an xy chart is exactly what I'm looking for. Could you
supply the code in vb.net for windows forms please?
Thank you.
Roger |
Re: XY Graph with Labels for events |
Posted by Peter Kwan on Nov-17-2012 00:35 |
|
Hi Roger,
The equivalent code in VB.NET is:
Dim layer As ScatterLayer = c.addScatterLayer(dataX, dataY, "", Chart.GlassSphereShape, 11, &Hff0000)
Dim i As Integer
For i = 0 to Ubound(dataX)
Dim t As ChartDirector.TextBox = layer.addCustomDataLabel(0, i, myLabels(i), "Arial Bold", 10, &H000000)
t.setBackground(Chart.Transparent, &Haaaaaa)
Next
Hope this can help.
Regards
Peter Kwan |
Re: XY Graph with Labels for events |
Posted by Roger on Nov-17-2012 04:40 |
|
Hi Peter,
Thank you. I'm sure it will help.
Roger |
|