How to set range axis values as 0 -100 for StackedbarChart using JFreeChart? - 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, %.

Related

Change axis label Color (JFreeChart)

Can anyone tell me how I can proceed to change the color of the axes' labels as circled below?
You can use setTickLabelPaint() and setLabelPaint() like this:
Axis domain = plot.getDomainAxis();
domain.setTickLabelPaint(Color.blue);
domain.setLabelPaint(Color.blue);
Axis range = plot.getRangeAxis();
range.setTickLabelPaint(Color.red);
range.setLabelPaint(Color.red);

Custom X-axis label formatting in Winform Chart Control

I am plotting graph with numeric value on Y axis and Date time value on X axis in windows forms chart control. I am setting X axis scale "IsLogarithmic" to true and i am getting the graph as shown in the image ...
I want to set the label formatting of X axis in such a way that it shows me 10^1, 10^2, 10^3 and so on...
Any idea or help will be appreciated.

Reseting zoom and pan when updating chart in livecharts

I'm using beto-rodriguez's livecharts for VB.NET/WPF, where I'm setting the source data in the code-behind and showing a plot when the user clicks a button.
I have enabled the zooming feature on my chart using chart.Zoom = ZoomingOptions.X. My issue here if that if I zoom to 150% and pan away from the point (0,0) for example, and I load a new plot on the same control, the zoom is not reset, as the new plot will be zoomed 150% and panned by the same value.
Is there a way to reset the chart zoom and pan every time its .Series value is reset ?
By the way, my x-axis contains dates, therefore, setting the min and max values wouldn't work.
Your answer is right, there you are forcing the range of your axis, but you can also let the chart to try to auto scale setting your axis limits to double.NaN
From the site: https://lvcharts.net/App/examples/v1/wf/Zooming%20and%20panning
cartesianChart1.AxisX[0].MinValue = double.NaN;
cartesianChart1.AxisX[0].MaxValue = double.NaN;
cartesianChart1.AxisY[0].MinValue = double.NaN;
cartesianChart1.AxisY[0].MaxValue = double.NaN;
I found the solution :
xAxis.Labels = labels
' Run these two lines every time the chart is updated
xAxis.MinValue = 0
xAxis.MaxValue = labels.Count - 1
Where xAxis is the name of my Axis control and labels is a list of strings containing the x-axis dates.

Time series chart horizontal gridlines through min/max peaks

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);

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.

Resources