I am having problems making my LineChart's X NumberAxis display it's Series/Data starting from some left (starting) value.
As above: All my data is ascending for X axis starting with 50000. How can I make the chart also start at 50000?
I've tried: xAxis.setLowerBound(50000); but it didn't work.
Is there maybe some specific time this value should be set?
Additional note: Series is created along with LineChart, the data is added later over time to the Series (ascending order).
As said in #James_D 's comment setForceZeroInRange(false); worked.
Related
Is it possible to generate a bar graph in jFreeChart where bars all start around a particular value instead of the zero axis? Our team has interest in this view.
Here is an example where the default behavior has the bars all between the value and the origin. We want the bars to be between the value and the mean (average).
I suppose a workaround is we calculate the offset from the mean and plot them in respect to the origin and then hide the axis but then we are not able to show the axis to our users.
Instead of having bar graphs stop at another value besides the origin we are just redefining the graph axis origin to be at the mean and offsetting everything. So instead of something like exposure level we now call the value axis distance from aggregate mean. Not exactly what I was originally looking in the OP but a cleaner solution overall. We'll let the user toggle between the two modes.
So I am using MPAndroidChart as library for the viewing of graphs in my app. Now I wanted to make a LineGraph with several lines (n). The problem is that those lines do not have the same x-axis labels and I have not found a solution to put the x-axis labels in relation to the entries. Furthermore does the new line start at x-value 0. Therefore my lines do not fill the entire diagram area. Because when I have two lines with 6 entries each, the x-axis labels have the size 12. And therefore the lines end at half of the diagram.
How do I solve that?
Example LineGraph
I assume you mean the library available here: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity2.java
From the code I grasped, LineChart does not support dual x-axis (while it support dual y-axis, left and right). See here , XAxis.java and YAxis.java
On the other hand, looks like the x-axis fits the data range automatically (there is no method to set min/max of x-axis).
An example of the graph >>
I would suggest you to re-organize your chart to switch x and y axis, and use two y axis if your series have different range of y values, but you want to show them in a chart. Double y-axis is more common than double x-axis from my experience, and easier to understand as well.
I am using afreechart to plot a timeseries as in this example code
However if the chart is panned vertically you reach the areas of the negative y axes. I want to avoid that and would want to set the min and max for both y and x axes.
I tried doing something like the below:-
ValueAxis yaxes=plot.getRangeAaxis();
yaxes.setRange(0,100);
But this does not seem to work and I am still able to pan the chart into non-negative y values area.
Ok I solved it myself.. I was extending from the class DemoView as in the example. I just changed some values as below:-
this.domainMovable=true;
this.rangeMovable=false;
It might be a dirty way but does my job
I'm developing a charting application and I'm using jFreeChart. I'm using a LineChart and a CategoryDataset.
I need to display a LineChart where in the Y axis (RangeAxis) there will be displayed number values and on the X axis (CategoryAxis) there will be displayed dates (yyyy/MM/dd hh:mm:ss) although in String format.
My question is if there is a way to display only certain dates on the CategoryAxis (X axis) althoug keeping all the pair (yyyy/MM/dd hh:mm:ss, Y value) in the series.
Example: the X axis only showing the days (yyyy/MM/dd) of my dataset but on mouseover in the series, the tooltip would stil display the pair (yyyy/MM/dd hh:mm:ss, Y value).
In other words, my CategoryAxis would contain only a subset of points of my series although my series would still contain all the values.
So far I'm limited to the restriction of for each (yyyy/MM/dd hh:mm:ss, Y value) pair displayed I need to have a correspondence (yyyy/MM/dd hh:mm:ss) on my X axis, which makes it unreadable as it is full of points and labels.
Don't know if I made myself clear and specific on my question, thanks in advance.
Since you have dates on your x axis, I think you should use a DateAxis instead of your CategoryAxis, and use an XYPlot.
As seen in the answer to a similar question, you can use DateAxis#setTickUnit(DateTickUnit unit) to set the unit type to DateTickUnitType.DAY.
I'm using the JFreechat API to draw an XYAreaChart with a TimeSeriesCollection dataset. The values I'm putting in the dataset are variables with no limit: they can go from 0 to more than 1000. The problem here is that I want to make the ValueAxis automatically fit the data.
I have tried to use :
XYPlot plot = mychart.getXYPlot();
ValueAxis axis = plot.getDomainAxis();
axis.setAutoRange(true);
I see that with setAutoRange, it is not so "automatically." It's true that it changes the axis when the plot gets big values, but it doesn't re-size the axis when there is no more big data as shown here:
I want that the axis Range gets back to fit the biggest value shown (~400 in this example) because it becomes hard to read the little values with this range without using zoom.
Is that possible?
I'd examine two approaches:
A dataset that discards old data such as DynamicTimeSeriesCollection, shown here.
A dataset whose series allow a maximum age such as TimeSeriesCollection, shown here.