Time series chart horizontal gridlines through min/max peaks - jfreechart

I am using JFreeChart to plot a timeseries chart. The chart is working fine, but the gridline alignment is becoming a problem.
My requirement is to show the horizontal gridlines through the peak values (i.e for the max and min value). Could you please let me know if there is any property for this, as I am getting grids randomly.

Have you considered using a Marker to highlight the min and max values?
As trashgod sugested you use the Dataset to get the minimum and maximum values and then add a Marker to the Plot
Range range = dataset.getRangeBounds(true);
plot.addRangeMarker(new ValueMarker(range.getLowerBound(),Color.GREEN,new BasicStroke(2.0f)),Layer.BACKGROUND);
plot.addRangeMarker(new ValueMarker(range.getUpperBound(),Color.BLUE,new BasicStroke(2.0f)),Layer.BACKGROUND);

Related

In wpf, using livecharts, how can I set minimum distance between point and columns?

I'm using wpf and livecharts to wpf app. I want to set minimum distances at but can't find out options.
I'm using 2 kind of charts. one is lineseries chart and the other is column series chart.
Because livechart automatically resize axis X and Y to fit, sometimes the chart is too crowded to see. So I want to set minimum distance between points and columns. panning will solve browsing part.
But problem is, I can't find out setting option. I've checked chart, axis and series options and tried some options. width, minwidth, margin, padding.. but all options didn't work.
My last option is make page and let user change page to see. But if user want to compare another page's value, it is not easy. So I want to avoid it.
Is there any option I'm missing? Please help.
You have to zoom in and out. To do this you have to manually assign an axis to the chart. Axis exposes properties like MinValue and MaxValue. You can use this values to zoom in (e.g. MaxValue < max data x value) or out (e.g. MaxValue > max data x value). MinValue and MaxValue control the visible section (or range). You would need to pan the graph to view other ranges.
To enable panning you have to set the Zoom property on the chart to the axis you wish to pan:
<wpf:CartesianChart Zoom="Xy">
<wpf:CartesianChart.AxisX>
<wpf:Axis MinValue="0" MaxValue="20" />
</wpf:CartesianChart.AxisX >
<wpf:CartesianChart.Series>
<wpf:LineSeries Title="Values" Values="{Binding DataValues}" />
</wpf:CartesianChart.Series>
</wpf:CartesianChart>

JFreeChart: Logarithmic Axis Tick Labels missing

I am using JFreeChart to make XYLineCharts with a Logarithmic y-axis but am facing an issue that I am unable to resolve.
My x, y values are very low in some cases (in one such case, the y-axis values for the dataset range between 4.5e-8 to 1.7). I plot these values on a XYLineChart using a Logarithmic Axis for the y-axis (and using LogAxis.createLogTickUnits(Locale.ENGLISH) and .setExpTickLabelsFlag(true) on the y-axis to create the exponential tick units). I set my range's bounds from 4.5e-8 to 1.7 and can see the points plotted clearly but there are no tick labels visible for the y-axis !
I was earlier having this issue while zooming into the charts but I have fixed the zoom & AutoZoom by over-riding those methods.
My current LogarithmicAxis works well for most of my x, y datasets but in a few cases, the y-axis is plotted but does not show any Tick Labels on it, despite my creating them & setting their visibility to true.
If anyone has any suggestions on how to fix this & ensure that the Tick Labels are visible no matter what the y-axis values may be, please let me know soon as I need to get this done ASAP.
Thanks.

How to set range axis values as 0 -100 for StackedbarChart using JFreeChart?

I need to develop a Stacked bar chart usinfg JFreeChart that shows values in Percentage and Number. For percentage mode when I am setting range, the values in the range axis changes but the chart gets squished. Please guide me with your valuable suggestions.
Thanks in advance
The code
CategoryPlot plot = chart.getCategoryPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setRange(0, 100);
As shown in this variation of StackedBarChartDemo2, you should specify (or convert to) percentages in the data model, not in the view. Then you can simply set the range axis label to the percent symbol, %.

Silverlight Area Series chart: how to define interval for X-Axis

I have a silverlight chart with an Area Series.
my data source returns many points representing time of day to be displayed in the chart's X-axis.
since the X-axis has many values, the values appear scrambled as each value is stuck beside the next value.
is there a method to avoid displaying all the values in the X-axis and display intervals instead ?
thanks
The DateTimeAxis has Interval and IntervalType properties that allow you to set the interval the you prefer.

Silverlight toolkit chart too many labels on axis

I'm using the newest chart control from silverlight toolkit to plot some data. For small cases it works ok, but for bigger samples the X axis labels overlap. It would be no problem if the chart would simply omit some of the values or I could specify to just show every 10th of them ...
I couldn't find any properties providing this behavior. Any ideas?
Assuming this is a Linear axis then you can specify the interval to use via the the Interval property on the axis.
If the axis in question is Category Axis then dropping some labels may not be valuable to the user. One option is to use the LayoutTransfomer to rotate the labels to an angle reducing the width needed for each one. See this Delay Blog on the subject.

Resources