Jfree图表更改Y轴数据 [英] Jfree chart change Y axis data
本文介绍了Jfree图表更改Y轴数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Jfree图表0.9.20的XYLineChartDemo来绘制程序中运行进程的执行时间。我的X轴表示时间,Y轴表示Pid。如何编辑Jfreechart文件,使我的Y轴表示我想要的值,而不是数字0范围?还有一种方法,使绘制的线条做得更宽的宽度?
I am using Jfree chart 0.9.20's XYLineChartDemo for plotting the execution time of running processes in a program. My X axis denotes the time and Y axis should denote the Pid. How can I edit the Jfreechart files to make my Y axis to denote values I want and not numbers 0-range?? Also is there a way to make the line plotted to be made thicker in width?
推荐答案
研究:
public JFreeChart createChart(String axisX, String axisY){
JFreeChart chart = ChartFactory.createTimeSeriesChart(null, axisX, axisY, dataSeries, true, true, false);
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesLinesVisible(0,true);
renderer.setSeriesShapesVisible(0, true);
//percentage (y-axis)
final NumberAxis percentAxis = new NumberAxis(axisY);
percentAxis.setInverted(false);
percentAxis.setRange(0.0, 100.0);
//time (x-axis)
final DateAxis timeAxis = new DateAxis(axisX);
timeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits(TimeZone.getDefault(), Locale.ENGLISH));
double range = 0;
switch (format){
case ONE_MINUTE_RANGE: range = 60*1000; break;
case TEN_MINUTE_RANGE: range = 10*60*1000; break;
case ONE_HOUR_RANGE: range = 60*60*1000; break;
}
timeAxis.setRange(System.currentTimeMillis()-range/2, System.currentTimeMillis()+range/2); //time duration based on format chosen
XYPlot plot = chart.getXYPlot();
plot.setDomainAxis(timeAxis);
plot.setRangeAxis(percentAxis);
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.gray);
plot.setRangeZeroBaselinePaint(Color.gray);
plot.setDomainGridlinePaint(Color.gray);
plot.setForegroundAlpha(0.5f);
plot.setRenderer(renderer);
chart.setBackgroundPaint(Color.white);
return chart;
}
这篇关于Jfree图表更改Y轴数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文