Hi
I'm trying to implement the ChartDrawItemEvent event so that I can draw custom colours on my chart (ColorModel isn't flexible enough for my needs). But the e.Primitive DataPoint property is always null. How do I set that in code? and what value do I need to assign?
Thanks
DataPoint property will be null for most scenarios, except when the primitive represents a single data point. For example, for a column chart, each box represents one datapoint, so DataPoint property will be set. For a line chart a polyline primitive consists of more than one data point, therefore DataPoint property is null and you have to look into the Points collection of the polyline to get the points. I'm not sure why you need the DataPoint property to be set. Have you tried using CustomSkin at your color model?
Thanks for the information. How do I use the CustomSkin? I would like to use certain colours that I have for each type of data point. Each data point has a property called Style (of which there are many) and i would like to use a specific color for each one. My attempts at using the ColorModel have so far been unsuccessful, mainly because the style property is not the data value of the point.
This link has a pretty good explanation of using custom skin:http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Chart_Custom_Skins_and_Paint_Elements.html
Basically, you set the ColorModel.ModelStyle to CustomSkin and add instances of PaintElement to ColorModel.Skin.PEs collection. Each paint element can be customized. Our DataPoint class doesn't have a Style property (you may be using your own class here?)
Our primitives are customized through the PE property, because for certain primitives that have more than one data point, it really wouldn't make much sense to set colors on the data point and expect the entire primitive to change colors. What type of chart are you using? It might help if you included a picture of your chart. Otherwise, it's pretty hard to speculate on what approach would work best.
Sorry to hijack your thread, but I'm running across the same issue. I have an ScatterChart that I need to modify so that it paints each data point with a different color depending on a given formula.
If I try the ColorModel solution in this case, all the dots use the first PE property (since the PointSet probably counts as a single row), but if I do it in a PointChart3D chart I get the expected results. Is there a way to paint each data point in a custom way for an ScatterChart?
Hi David
I managed to get the chart to draw each point with a colour of my choosing. I did not use the colour model, as that requires the use of a ColorPalette which overrides the colors you chose.
I don't know which version you are using (we have v6.3 here), but you need to implement the FillSceneGraph event for the chart. In there you can get all points drawn on the chart, and then to override the color of each one just use the point.PE.Fill to set the color depending on your formula.
Hope that helps.
Jeff