I’m using a 3D Cylinder Column Chart. These charts are then used in creating a PDF by way of the Infragistics.Documents.Report object. Is it possible to display data values that are zero (0) as nothing, or as a different color? i.e. I don’t want a flat, round, red disk displayed when the value is zero (0).
You should handle the ChartDrawItem event and remove the drawing of anything that has to do with the 0 valued data points. Here's some sample code:
protected void UltraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e) { if (e.Primitive.Value != null) { Double val = (Double)e.Primitive.Value; if (val == 0) { e.Primitive.Visible = false; } } }
WARNING: This is very hacked together code, you'd probably want to handle exceptions and do a better check to make sure what you're dealing with is actually going to give you a Primitive.Value that is a double, but this should set you on the right track.
Good luck, and let me know how it goes.
That did the trick! Thank you very much.
Now if I can just figure out how to change the color ... I can do this for 2D but can't get it to work with 3D.
I'm using:
e.Primitive.PE.Fill and e.Primitive.PE.FillStopColor
Any ideas?
Awesome! I'm glad you found a workaround, good luck with the rest of your charting.
-Paul
Sorry for the typos.
This works partially for me. I can colour the bar(s) I want red, but then the bar(s) are just an even red plane, no more edges, no more shading giving the 3d-effect. How can I do that?
If the mouse pointer hovers over a bar in a 3D Bar chart, it changes colour as well. So it should be possible basically?
Each bar consists of multiple paths. Since you're making them all one color, you lose the shaded appearance, because those colors get applied after the lighting is taken into effect. This is partially the reason we don't recommend using ChartDrawItem/FillSceneGraph events for 3d charts. You would have to set different shades of your color to the paths in each bar to create a 3d appearance.
"You would have to set different shades of your color to the paths in each bar to create a 3d appearance."
How would I do that? Do you have any further hints, code samples or links? Which events/functions to use instead? I don't think I found anything regarding this probles in the chart sample application.
Thank you in advance for your efforts.
FillSceneGraph is the event to handle. Each side of your 3d bar is represented by a Path primitive and each path has a brush you can set. If, for example, the bar has a red brush, if you set different shades of red to each of the sides, you'll see a 3d effect.
List<Path> paths = new List<Path>();foreach (Primitive p in e.SceneGraph){ if (p is Path && p.Row >= 0 && p.Column >= 0) { paths.Add(p as Path); }}
int R = 0;int G = 0;int B = 0;
foreach (Path path in paths){ if (path.Row == 0 && path.Column == 0) { R += 30; path.Brush = new SolidBrush(Color.FromArgb(255, R, G, B)); }}