I have a strange thing happening while using ZedGraph.
I am using the same item to add multiple curves. Like:
ZedGraph LineItem curve_3;
curve_3 = pane.AddCurve("", xx_1, yy, xxyy);
I call the above lines multiple times to add multiple points. But when I remove the curve, only the last added curve gets removed and left all stays on the pane.
this.zedGraph_RenderedTrack.GraphPane.CurveList.Remove(curve_3);
I am not finding a way that will clear all the curves added. Is there a to do it?
My actual requirement is that I have to add the different lines dynamically on the pane, but I don't need to display the label information and all of them should be plotted by a single click and removed by a single click.
You are holding only the last curve in this code:
ZedGraph LineItem curve_3;
curve_3 = pane.AddCurve("", xx_1, yy, xxyy);
Use collection like List<LineItem> to remember all the curves.
List<LineItem>.foreach(r => this.zedGraph_RenderedTrack.GraphPane.CurveList.Remove(r);
)
If you want to remove all curves from your graph pane, simply use the CurveList.Clear() method:
this.zedGraph_RenderedTrack.GraphPane.CurveList.Clear();
Related
I have a Chart control that contains multiple overlapping Line series like this:
As you can see, the labels of the intersection points of the lines overlap the lines themselves. I tried using the following to no avail:
intersectPoints.SmartLabelStyle.Enabled = true;
intersectPoints.SmartLabelStyle.IsMarkerOverlappingAllowed = false;
I'm pretty sure this is because MarkerOverlapping only applies to Markers in the series the label belongs to.
I'm looking for how to accomplish any one of several solutions:
1) Manually adjust x-y position of Point label
2) Increase opacity of label so that it appears "above" overlapping lines
3) Use some other SmartLabelStyle tool.
4) If no other solution is available, possibly overwriting the draw method for the chart?
I've two curves. One of them is above the another. I've also set the IsSmooth to true (the lines are bent at the corners).
I want to fill the area between the top and bottom curveā¦
What's the best method to do so?
I think using PolyObj is not a good idea because I have to store the points separately, and the final filled area is not smooth like the lines.
Here is a sample:
Is it possible to set width of existing Zedgraph line? Most examples I saw demonstrate following method:
LineItem myCurve1 = myPane.AddCurve("Sine Wave", spl1, Color.Blue, SymbolType.None);
myCurve1.Line.Width = 3.0F;
But as I see it can be done only at moment of adding new curve. Most obvious solution is to create List and add all curves there to access them later. I wonder is it right way or I am at wrong track?
UPDATE
My situation is following. I have several line curves and list of them in listBox. I want to make currently selected curve bold. That is why I need access to existing curves.
LineItem has constructors that support setting the line width, so you can create the curve first and then add it to your GraphPane, like this:
LineItem myCurve1 =
new LineItem("Sine Wave", spl1, Color.Blue, SymbolType.None, 3.0f);
myPane.CurveList.Add(myCurve1);
Which approach to recommend is more a matter of taste, I think, but personally I prefer to initialize my object as much as possible before adding it to any collection.
UPDATE If you later on would like to access your specific curve item, simply retrieve it from myPane.CurveList. The objects in CurveList are CurveItem:s, so you may need to cast to LineItem to modify line specific properties.
example
((LineItem)zedGraphControl1.GraphPane.CurveList[1]).Line.Width = 3.0F;
Pane in ZedGraph already have list of curves. Maybe you need redraw your pane after changing curves?
Original Question
I'm using Microsoft Chart Control to display some data points as a Line. I have a Legend with custom items used to display calculated information about the line (mean average and others).
Now I've enabled IsUserSelectionEnabled which allows the user to "zoom into" a range of values and I want the legend items to be calculated on only the data points that are currently in view.
I can use the AxisViewChanged event to be notified of the view change, but what I can't figure out is how to enumerate only those DataPoint currently in view.
Update
The zoom isn't going to work for my purpose. What I discovered is that the NewPosition and NewSize properties of the AxisViewChanged event do in fact contain the precise area selected by the user, but the resulting zoom contains points outside of that area. I need more precision than that. What I need are two cursors, but the control only gives you one.
So my question now is: How do I customize this thing to add another cursor? I'm not asking just yet and if I do I'll start a new question.
Though I do still need to figure out how to translate client coords into data coords...
Updated again
I found the coord translation functions right on the Axis. Seems obvious in retrospect.
ChartArea.Axis.PixelPositionToValue (for whichever axis you need)
ChartArea.Axis.ValueToPixelPosition
I'm using the Visiblox WPF API and am having trouble getting the chart points in my line chart to scroll horizontally. Instead of scrolling, the points are get squashed together, in which, this isn't particularly a problem, except that I expect to have 100s of data points on the chart. I have looked throughout the examples available on the Visiblox website, but couldn't find what I was looking for. Ive attached an example screenshot.
Any ideas?
Thanks for your help,
Sparky
By default Visiblox Charts will re-calculate the range to include all the data in the series, so there are two possible approaches: 1) when you add the last point, remove the first one which will effectively move the visible window one point over or 2) set an explicit axis range and update that when you want to move the visible window.
Check out the Visiblox blog for more details on how ranges work at: http://www.visiblox.com/blog/2011/03/visiblox-charts-ranges-demystified
I just had something like this recently. Everytime I'd add a point to the cart I'd run a little section of code that would check the amount of time (my x-axis dimension) that had passed since 0. I also set up a range of data I always wanted to see. I always wanted to show 120 seconds of data on the graph. So I had something like this:
private void adjustXasis(int timeCount)
{
if(timeCount>desiredRange)
{
chart.axis.Xaxis.minimum=timeCount-desiredRange;
chart.axis.Xaxis.maximum=timeCount;
}
else //two minutes not reached yet
{
chart.axis.Xaxis.minimum=0;
chart.axis.Xaxis.maximum=desiredRange;
}
}
I don't have VS in front of me and I know that syntax for the axis min/max is wrong but you get the idea.
By default Visiblox Charts will re-calculate the range to include all the data in the series, so there are two possible approaches:
1) when you add the last point, remove the first one which will effectively move the visible window one point over or
2) set an explicit axis range and update that when you want to move the visible window.
Check out the Visiblox blog for more details on how ranges work at: http://www.visiblox.com/blog/2011/03/visiblox-charts-ranges-demystified