I have a scatter chart, and i want to color the points based on a condition.
for ex
datapoint1 would be green if market value >50000
would be red if market value<50000
Just wanted to know how to do it.
Thanks
Hi Kartik,
You could get all desired information about the points in the chart's PointSets in the FillSceneGraph event hadler too looping throught the SceneGraph elements of the chart the way you do it in the ChartDrawItem event handler. That way you will not need any global variables. Here is a sample of something similar.
The ChartDrawItem event is fired for every item of the SceneGraph which is why it is not a good idea to change the SceneGraph in that event handler and it's not accesable throught it. The FillSceneGraph event is for this reason.
The FillSceneGraph event is fired initially in the chart creation and I can not reproduce any problematic behavior with it. Are you using the latest version of the control? Let me know what exactly is the behavior you experienced if it is still a problem for your case.
Yes, i am doing the same now, i am de-drawing an ellipse over hte data point, This is what i am doing
Step 1: ChartDrawItem Event
DataTable
dtchart = new DataTable();
dtchart = (
DataTable)ucNicRpt.DataSource;
if (e.HasData)
{
PointSet pointset = e.Primitive as PointSet;
foreach (DataPoint dp in pointset.points)
long s = (long)dtchart.Rows[dp.Row][dp.Column];//Since the chart doesnt recognize the dateTime i need to convert it to long and compare.
DateTime t = new DateTime(s);
if (t > Convert.ToDateTime(dtNewDataDate.Value))
lstDP.Add(dp);
}
Then I take the List<PointSet> lstDP to the Fill Scene Graph and Draw the ellipse over the selected datapoints.
There are 3 things i hate about it.
1. I cannot highlight a datapoint in the chartdrawitem event since there is no way i can acces hte scenegraph
2. Declaring a global varialble to store the datapoint
3. The FillScene event only fire when the mouse is moved away from the chart area. i have a context menu option in my chart where it transfer hte chart to log scale, and the user had to move his mouse away from the chart to fire the FillSceneGrpah Event to re-draw the ellipse accordingly
kartik
Hi,
If your datapoints are displayed initially green, you should use the FillSceneGraph event to get the desired datapoints with market value < 50000, so you could create new datapoints with red color and add them to the SceneGraph of the chart, so they could be redrawn over the green ones.
Let me know if you encounter some problems.