Hi everbody,
I'm using a UltraChart component to draw a barChart. The values can be positive or negative. Depending on values (max minus min), I calculate and update the rangeMax, the rangeMin and the TickmarkInterval to obtain a good looking graph. (the customer wanted to display tickmark with round values).
Now, I'd like how I could draw a single line horizontally on the graph (where the zero value is). just a single black line starting for a specific point and ending at another one.
My idea is to add a layer and draw the line myself (http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=5432) but is it the best solution?
here is a an exemple: I'd like to draw the line to separate clearly positive and negative values.
thanks in advance
If you are using a recent version of NetAdvantage you can just use the FillSceneGraph event. If that event is not available then you would use a custom layer.
Here is a blog post that talks about the fillscenegraph event in the 301 section:
http://blogs.infragistics.com/blogs/skim/archive/2008/09/05/chart-university-chart-101-and-some-201-301-401-stuff.aspx
Modified code for plotting a line at zero:
private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
{
//gets the X and Y axis
IAdvanceAxis x = (IAdvanceAxis)e.Grid["X"];
IAdvanceAxis y = (IAdvanceAxis)e.Grid["Y"];
//checks if axis exist
if (x != null)
//figures out the coordinate to draw
//a line at y=0
int target = 0;
int yVal = (int)y.Map(target);
//note: the x axis is a string axis
//that means that 0 stands for the first
//column and 50 stands for the 50th
//column
int xStart = (int)x.Map(0);
int xEnd = (int)x.Map(50);
//creates the line primitive based
//on the coordinates
Line l = new Line(new Point(xStart, yVal), new Point(xEnd, yVal));
//sets the color of the line
l.PE.Stroke = Color.Black;
l.PE.StrokeWidth = 2;
//adds it to the scene
e.SceneGraph.Add(l);
}
yeah!!!
it seems to be exactly what I'm looking for. Thank you!!!
I just have to figure how to make it working. I added the event but it does not seem to be fired because I'm creating the chart in memory and the SaveStream method does not seem to work like the Save() method (http://dotnetfacts.blogspot.com/2008/03/infragistics-user-controls-library.html)
:/
(I'm using Infra 7.3)
also, the axis scrollbar is dragging is enabled as of 2008.2