use of org.jfree.chart.JFreeChart in project GT by Tencent.
the class CPURealTimeChart method createChart.
@Override
public JFreeChart createChart() {
final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU实时曲线图", "时间", "CPU%", dataset, true, true, false);
//设置,不然中文会存在乱码
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));
XYPlot xyPlot = (XYPlot) chart.getXYPlot();
ValueAxis domainAxis = xyPlot.getDomainAxis();
ValueAxis rangeAxis = xyPlot.getRangeAxis();
domainAxis.setLabelFont(new Font("宋体", Font.BOLD, 14));
domainAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));
rangeAxis.setLabelFont(new Font("宋体", Font.BOLD, 14));
rangeAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));
return chart;
}
use of org.jfree.chart.JFreeChart in project GT by Tencent.
the class PieChart method createChart.
private JFreeChart createChart() {
this.dataset = new DefaultPieDataset();
final JFreeChart chart = ChartFactory.createPieChart("内存构成分析", this.dataset, true, true, false);
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));
PiePlot plot = (PiePlot) chart.getPlot();
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}"));
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
return chart;
}
use of org.jfree.chart.JFreeChart in project hudson-2.x by hudson.
the class LoadStatisticsTest method testGraph.
public void testGraph() throws IOException {
LoadStatistics ls = new LoadStatistics(0, 0) {
public int computeIdleExecutors() {
throw new UnsupportedOperationException();
}
public int computeTotalExecutors() {
throw new UnsupportedOperationException();
}
public int computeQueueLength() {
throw new UnsupportedOperationException();
}
};
for (int i = 0; i < 50; i++) {
ls.totalExecutors.update(4);
ls.busyExecutors.update(3);
ls.queueLength.update(3);
}
for (int i = 0; i < 50; i++) {
ls.totalExecutors.update(0);
ls.busyExecutors.update(0);
ls.queueLength.update(1);
}
JFreeChart chart = ls.createTrendChart(TimeScale.SEC10).createChart();
BufferedImage image = chart.createBufferedImage(400, 200);
File tempFile = File.createTempFile("chart-", "png");
FileOutputStream os = new FileOutputStream(tempFile);
try {
ImageIO.write(image, "PNG", os);
} finally {
IOUtils.closeQuietly(os);
tempFile.delete();
}
}
use of org.jfree.chart.JFreeChart in project Openfire by igniterealtime.
the class GraphEngine method createChart.
private JFreeChart createChart(String title, XYPlot plot) {
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(Color.white);
return chart;
}
use of org.jfree.chart.JFreeChart in project Openfire by igniterealtime.
the class GraphEngine method generateSparklineAreaChart.
/**
* Generates a SparkLine Time Area Chart.
* @param key
* @param stats
* @param startTime
* @param endTime
* @return chart
*/
private JFreeChart generateSparklineAreaChart(String key, String color, Statistic[] stats, long startTime, long endTime, int dataPoints) {
Color backgroundColor = getBackgroundColor();
XYDataset dataset = populateData(key, stats, startTime, endTime, dataPoints);
JFreeChart chart = ChartFactory.createXYAreaChart(// chart title
null, // xaxis label
null, // yaxis label
null, // data
dataset, PlotOrientation.VERTICAL, // include legend
false, // tooltips?
false, // URLs?
false);
chart.setBackgroundPaint(backgroundColor);
chart.setBorderVisible(false);
chart.setBorderPaint(null);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setForegroundAlpha(1.0f);
plot.setDomainGridlinesVisible(false);
plot.setDomainCrosshairVisible(false);
plot.setRangeCrosshairVisible(false);
plot.setBackgroundPaint(backgroundColor);
plot.setRangeGridlinesVisible(false);
GraphDefinition graphDef = GraphDefinition.getDefinition(color);
Color plotColor = graphDef.getInlineColor(0);
plot.getRenderer().setSeriesPaint(0, plotColor);
plot.getRenderer().setBaseItemLabelsVisible(false);
plot.getRenderer().setBaseOutlinePaint(backgroundColor);
plot.setOutlineStroke(null);
plot.setDomainGridlinePaint(null);
NumberAxis xAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
xAxis.setLabel(null);
xAxis.setTickLabelsVisible(true);
xAxis.setTickMarksVisible(true);
xAxis.setAxisLineVisible(false);
xAxis.setNegativeArrowVisible(false);
xAxis.setPositiveArrowVisible(false);
xAxis.setVisible(false);
NumberAxis yAxis = (NumberAxis) chart.getXYPlot().getRangeAxis();
yAxis.setTickLabelsVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setAxisLineVisible(false);
yAxis.setNegativeArrowVisible(false);
yAxis.setPositiveArrowVisible(false);
yAxis.setVisible(false);
return chart;
}
Aggregations