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
Related
I have multiple series which share the same x-axis but some values are repeated as they have different number of data points. Since this is the case I want to set the same number of data points for all my series.
Is setting empty data points a solution to make all series have the same number of data points or are there any other solutions? If setting empty data points is a solution, how do I use it? My series aren't fixed and vary according to user selection.
They follow:
Chart1.Series[i].XValueMember = "Receipt date";
Chart1.Series[i].YValueMembers = "AvgAgingDays";
Is setting empty data points a solution?
Well, it certainly will achieve the counts to be the same. But how it looks is a different matter.
One question here is where do you inset them (X-Value), probably where they are missing, right?
The other question is what ChartType do your series have? Here are a few typical types:
Point, Bars, Columns: That is fine, just make the Color of the 'empty' Points Transparent!
Line, Area: That is more tricky. You don't want gaps in the lines so you need to keep them visible. And you want the lines to go straight so you need to calculate the Y-Values from the neighbours. Simple for one missing Point, a little bit more work for larger gaps. Not possible for points missing at the start or end. Those should be invisible again..
Spline: Next to impossible to get really right. Either put in some more work or live with some inaccuracies!
If you have a Line chart, to fully document the situation, you may consider adding a Point Series on top with the same data, but with the missing Points invisible.
Btw: If you have correctly set the XValueType as DateTime, all this ought to be unnecessary, as then the missing dates won't matter and the DataPoints all sit at their respective dates. They only shift if you don't have a valid X-Value and/or fitting XValueType.
This is a rather comon mistake because at first it all looks fine but without setting the type it will be string and then you run into trouble when you want to act on the values or rely on their positions or even just format them..
Btw: While it is possible to AddXY the missing points afterwards, it makes things a lot easier if you can detect and add them while adding the real points..
Apologies for not able to find a more suitable title for my issue here. I am using MS Chart control in my project to plot real-time values from a source that generates 4 values per second. X axis is time at which the value is generated and the Y axis the value itself. I am dynamically adding a new series for each variable. All the variables are manually added by the user one-by-one and then a series will be created for it.
Basic part seems to be working except the chart is plotting values from different series at different time even though the values are generated at same time. Following image shows the exact issue:
As you can see, the list in bottom is a list of values I am plotting. It shows values and the time they are generated at (hh:mm:ss.ms)
When I plot these values, which is shown in the chart area, this is what I get. See the location of the latest values (marked by red arrows) for all the series. The latest value is at different time even though they all are generated at the same time. Every series seem to have a separate X axis. I expected the latest Y values should be plotted at the same X value and that should be shown at the extreme right of the chart. More like the bottom most series is being shown. That is the very first series created. Every time only the series that is created first works fine and the following series lags for some reason.
Chart, share X axis between different series looks like similar issue to mine but is not answered.
Chart Multiple series different length generate duplicate x axis seems to be the exact issue I am having but the difference is - I am plotting a real-time graph. I can't loop through every series after adding a new data point to mark whether a point is empty or not. That will be a lot of overhead. Some Googling suggested use of InsertEmptyPoints() to every series to match all the X axis. MS Chart sample code also explains using this method but I am not sure where/when to use this method. If I use it after creating a series but before adding a data point - the code crashes. I have tried something like this:
_chart.Series.Add(series);
_chart.DataManipulator.InsertEmptyPoints(250, IntervalType.Milliseconds, name);
Am I doing something wrong here? Thanks for any help offered.
I got this working by adding empty points. I filled every series with max possible data points to begin with. Say I want to show 100 data points in every series before I start deleting the oldest (Points[0]) data point so that my chart will look like it's moving from right to left. In that case I will add 100 empty points while creating every series using:
for (int i = 0; i < 100; i++)
{
series.Points.AddXY(i.ToString(), double.NaN);
series.Points[i].AxisLabel = " ";
}
Then, while adding real data just do it normal way:
_chart.Series[index].Points.AddXY(time, YValue);
// delete more than max. points.
if (_chart.Series[index].Points.Count > MaxTrendPoints - 10) // -10 is adjustment. Got it by trial and error.
_chart.Series[index].Points.RemoveAt(0);
I add points to the chart, using
chart1.Series[0].Points.AddXY(x,y);
Millions of points were added. The chart automatically starts drawing them in the current chartarea. Problem is that, it could take a long time before the program become responsive, and I don't need to see all of them at the beginning.
If I call
chart1.ChartAreas[0].AxisX.ScaleView.Zoom(a, b);
right after adding points, it would not work, because the chartview is still empty yet.
So how can I stop the automatically drawing process?
Just some point of views don't know if it can help of if it is possible but
Maybe reduce decrease value of AxisX maximum can speed up,
Turn off AntiAliasing to none at chart1 can give a try otherwise keep it set All,
Maybe being Drawing Paint can be stopped by catch related Pre Post paint or
other event and return "handled" after enough needed requested point are drawn
Try reduce number of Value to be used at Points array of Series it self and
update this Points array when needed with new points
Regards
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 having trouble with my Silverlight Chart. My model is unsorted, that is, the sorting is done on the server side. It needs to support year transitions, but as you can see from the screenshot the charting control automatically sorts the model and fills in the gaps. The line sort be ever increasing and not taking a dip on new year.
How can I make the chart display the data in the order specified in the grid control to the left?
Btw, using SL3
alt text http://img705.imageshack.us/img705/7602/unsortedsilverlightchar.png
The line chart is not designed to do the task you seem to be asking. After all the purpose of a line chart is to help the user trace a trend or even visually interpolate an interim value. However if the interval between horizontal points is not linear and always traveling in the same direction such lines meaningless.
I would therefore suggest that the Line chart is not appropriate or that you have some other hidden data which should be used for the Y-axis which would make the lines meaningful.
Alternatives might be to use a Scatter graph or a Column series where the y-axis value has been converted to a string and thus cause the series to use a Category based axis instead of range based one.