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.
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
You don't need to override the pointset. Picture a drawing surface with existing pointsets. Now take any of the indexed points of a pointset and draw a symbol at the point's coordinates. Something like this://somewhere in the foreach(p in scene) loop store a reference to your pointset to make it accessible outside the loop; let's call it myPointSet.//this will draw a large red circle over the 2nd point in the pointsetPoint point = myPointSet.points[1].point;Symbol symbol = new Symbol(point, SymbolIcon.Circle, SymbolIconSize.Large);symbol.PE.Fill = Color.Red;scene.Add(symbol);
Thanks for the info. Does this also work on version 6.3? I notice that there is no Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs with my version.
Also, the current code we have uses poinset primitives. When you say I need to add symbols on top, does that mean override the pointsets???
I am using a ChartLayer class which implements the ILayer class, and in there I have a FillSceneGraph(SceneGraph scene) method (this is legacy code which I did not write, see below):
How would I implement different colours depending on the strategyId???
{
IDictionary pointSetData = chart.PointSetData;
if (points != null)
int counter = GetRow(points);
points.fillColor = Color.LimeGreen;
}
points.drawColor = Color.Blue;
points.icon = SymbolIcon.Triangle;
points.fillColor = Color.Red;
else
points.fillColor = Color.Yellow;
PointSet points = p as PointSet;
// Use pointSetData
// special case
points.iconSize = SymbolIconSize.Large;
short styleId = model.AnalysisModel.ChartProvider.StyleId(counter);
points.drawColor = GetStrategyColor(strategyId);
points.fillColor = GetStrategyColor(strategyId);
points.iconSize = SymbolIconSize.Medium;
points.fillColor = Color.Pink;
points.character = '#';
// Make different color around an icon
// Add labels
pnt.Offset(3, -3);
dataP.PE.Fill = GetStrategyColor(strategyId);
dataP.drawColor = GetStrategyColor(strategyId);
fontColor = Color.Red;
text.labelStyle.FontColor = fontColor;
newItems.Add(text);
// Now add those new items
scene.Add(t);
The 2D scatter chart uses pointset primitives,which unfortunately, don't provide a way to color individual data points. You can work around this by adding Symbol primitives directly on top on the existing data points using FillSceneGraph event of the chart.
Try following the example in this link, except instead of adding a Box primitive it would be a Symbol.http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Chart_Modify_Scene_Graph_Using_FillSceneGraph_Event.html
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?