Hi thanks for your response, i figured it out in anoher way. Everything is great and works fine but i have last problem. Could you give me some advice?
So here i create two dataset for two lines
Code: Select all
DefaultCategoryDataset cumulativeResultData = new DefaultCategoryDataset();
DefaultCategoryDataset indexResultData = new DefaultCategoryDataset();
Then in loop im using:
Code: Select all
cumulativeResultData.addValue(cumulativeResult,"Cumulative Result", "" + days);
Days are integer number using in loop, in every step increments days + 1
Last step i create chart:
Code: Select all
CategoryPlot plot = new CategoryPlot();
plot.setDomainAxis(new CategoryAxis("Days"));
plot.setRangeAxis(new NumberAxis("Result"));
plot.setOrientation(PlotOrientation.VERTICAL);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(true,
false);
LineAndShapeRenderer renderer = new LineAndShapeRenderer(true,
false);
plot.setRenderer(renderer);
plot.setDataset(cumulativeResultData);
ValueAxis rangeAxis2 = new NumberAxis("Index price");
rangeAxis2.setRange(minRange - 1, maxRange + 1);
plot.setRangeAxis(1, rangeAxis2);
plot.setRenderer(1, renderer2);
plot.setDataset(1, indexResultData);
plot.mapDatasetToRangeAxis(1, 1);
JFreeChart chart = new JFreeChart(plot);
But when i created chart for lets say 500 days, the chart looks:
http://imgur.com/ExEmyOu
Axis Days is not clearly is any way to display Axis Days legend for examply not for each step in loop?
Now i have 1 2 3 4 5 6 7, i want 1 10 20 30 40 etc?
Edit:
I found solution
Code: Select all
NumberAxis domainAxis = (NumberAxis) plot.getRangeAxis();
domainAxis.setTickUnit(new NumberTickUnit(50));
But in my situation it does not work as in fact the domainAxis is a string not a number... Any sugestion?