Using OxyPlot.Wpf 2.1, I am creating a bar graph where the horizontal axis (x) is a DateTimeAxis and the vertical axis (y) is a LinearAxis. I need 4 series that stack on each other so when one series is disabled there are no vertical gaps. A BarSeries seemed to be the best option at first since it contains the IsStacked property so hiding a series properly displays the bar graph with no vertical gaps. However, it requires a CategoryAxis along the x axis which does not seem to work well with the DateTimeAxis.
I have used a RectangleSeries and a RectangleBarSeries but they do not support stacking which means I have to recalculate all items to avoid vertical gaps when a series is hidden.
I have also used a LinearBarSeries but the larger series overlaps and hides the smaller series and does not support stacking either.
Is there some bar series in OxyPlot that supports a DateTimeAxis and stacking? I am able to use a CategoryAxis and display the time as the Category label but zooming out does not support readjusting tick size and labels which is what is ideal and functional with a DateTimeAxis. Also I am dealing with continuous data where the user can look at past or future times which does not seem possible with a CategoryAxis since the bounds are determined by how many categories you have.
This github issue claims that LinearBarSeries does support stacking but I do not see how it is possible from the code.
https://github.com/oxyplot/oxyplot/issues/1172
Related
I'm using WPF and OxyPlot and I wanted to hide some points on a series... however this doesn't seem to be possible to my surprise! Am I missing something? I am iterating over a set of points on a series, and I'm concentrating on a specific region of the graph of the series where I want the data points outside that range to not display.
I have a FIFO Real Time chart (pretty much taken from their published Example) of a SciChart graph. As it renders, it starts out completely zoomed in very close and as the line is drawn, it zooms out to accommodate the full size of the line.
<s:SciChartSurface.XAxis>
<s:NumericAxis x:Name="axisX" MinHeight="50" AutoRange="Always" AxisTitle="{Binding Path=XAxisTitle}" DrawMinorGridLines="False" DrawMinorTicks="False" TextFormatting="0.##">
<s:NumericAxis.GrowBy>
<s:DoubleRange Max="0.1" Min="0.1" />
</s:NumericAxis.GrowBy>
</s:NumericAxis>
</s:SciChartSurface.XAxis>
However, what I would like is for it to begin zoomed out by a certain amount already - e.g. the X axis would already be displaying from (for example) 0 - 10 and as the line is drawn it proceeds across the screen, only zooming if the line happens to get bigger than the space provided.
I've tried setting the VisibleRangeLimit, but while this does allow me to define the range of the chart area, the zoom doesn't kick in when the curve gets too big (so it literally goes "off the chart")
How can this be accomplished?
The reason for this is the Fifo Example in sciChart WPF uses XAxis AutoRange set to Always to scale the axis to fit the data. When the example starts, even if the Fifo buffer has a capacity of 10,000 points, it has no data in it, hence the axis is scaled small to accommodate the data.
There are two ways around this:
Is to pre-fill your FIFO DataSeries with X=xValue, Y=double.NaN. Given enough values the chart will think it has to draw all these points so the XAxis will scale accordingly
Is to take control of XAxis.VisibleRange yourself (do not use AutoRange). In this case, you need to set XAxis.VisibleRange to a window size to accommodate N points, and as you update data, update the window.
The FAQ 'How to create a StripChart in SciChart' demonstrates technique (2), how to update the visible-range of the XAxis to achieve scrolling behaviour.
Disclosure, I am the tech lead of the SciChart WPF Team
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
Is there a way to modify the width of a ZedGraph bar? If so, what is the code necessary to do so? Is it possible to make it so the bars scale with the zoom also? I have bars that don't show up because of the way the scaling works currently (there is a wide x-axis range, which makes all of the bars very skinny). If the bar is too narrow, it won't show up at all. I'd like the bars to be wider so they will always show up without having to zoom in to see them.
The documentation for ZedGraph has the following to say about bar type graphs (emphasis mine):
Typically, bar charts would be created with XAxis.Type = AxisType.Text or XAxis.Type = AxisType.Ordinal (both types use ordinal values), such that the bars are drawn at integral values along the "base" axis, starting with 1 (e.g., the first bar cluster is at 1.0, the second is at 2.0, etc.). However, the ordinal axis type is not a requirement for bar charts. It is possible to create a bar chart that is not evenly spaced, by providing X values and using AxisType.Linear (in this case, you may need to use the GraphPane.ClusterScaleWidth property to tell ZedGraph how wide the bars should be. See this wiki page for details). For bar charts, the tic marks are typically between the bar clusters, which can be accomplished with the Axis.MajorTic.IsBetweenLabels property. However, this property is only applicable for AxisType.Text axes.
Unfortunately the wiki link goes to the old domain which the authors of ZedGraph seem to have abandoned. However there is an archived version: Wiki Page
Finally you may find it helpful to check the excellent source code reference at sourceforge.
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.