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.
Related
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
Im writing scientific/educational app. One of the features is calculating integrals aproximation with rectangle and trapeze methods. I want to display f(x) function chart with the results of the calculations where i could mark the areas that are accurate and inaccurate with different colors.
So far, i tried to use charts from DataVisualisation.Charting. For displaying f(x) functions i used Spline chart. In case of rectangle method i tried to use bar chart for aproximation.
There are two problems: firstly, the mesureing point are in the middle of the bars instead of on the right side; secondly, i don't know if it's possible to mark the inacuracies like on the pics above while useing the default library.
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
I'm trying to draw something in a System.Windows.Media.DrawingVisual but I need to draw thins in millimeter unit. How can I do that?
In WPF, you can't even draw something in pixel units without at least some extra effort. WPF uses "device independent units" where each unit is 1/96th of an inch. Even that is only a theoretical relationship, as it depends on the display device correctly reporting its resolution, which in turn is dependent on the display, its configuration, and what the user has set e.g. in the "large fonts" setting (i.e. in the screen resolution settings, clicking the link that reads "Make text and other items larger or smaller").
All of these affect WPF's interpretation of the available display resolution information, which in turn affect how WPF chooses to render its "device independent" 1/96th of a inch units.
The bottom line is that the link commenter Sheridan offered really is the closest you can come to displaying in millimeters, barring a lot of extra work and help from the user. By scaling your input units, intended as millimeters, by the factor value provided (i.e. 96/ 25.4…in the expression, you can see the 25.4 to convert from millimeters to inches, then the 96 that converts inches to 1/96ths of an inch), you can convert your millimeters into the 96 dpi units that WPF uses natively.
Assuming the display is configured correctly (an optimistic assumption, but it does happen :) ), this will result in reasonably accurate presentation on the screen according to your desired millimeter-based dimensions.
Note that you can accomplish this scaling through the use of a transform on your rendered UI elements. The easiest thing to do would be to set the LayoutTransform property of the outer-most container object where you want the millimeter-based rendering. Then you can just lay out your objects in that container using the millimeters values for their location and size, and WPF will use the transform to present the container and the rendered objects within at the scale you want.
I pass a dataset to my report, which renders a line chart showing a sprint burn down chart. One of the fiends in the dataset is 'PeriodType', which can be either 'Planning, 'Burning' or 'Retrospective'.
The chart shows dates along x axis, and the y axis holds hours.
What I would like to do, is grey the background, where the x axis has a value that is not a 'Burning' period. So the object that is used to create the chart, as mentioned, has a type field I can use.
Is there a way to change the background colour of the x 'columns' based on the flag? Some sort of conditional background colouring? I have searched, but can't seem to find such a handy thing.
Yes, that is possible.
Open the Properties pane, in the BackgroundColor or Color (whichever is relevant) property of the chart, enter an IFF statement like:
=IIF(Str(Fields!PeriodType.Value) <> "Burning", "Gray", "SomeOtherColor")
Hope that helps