use of org.jfree.data.time.TimeSeriesCollection in project cubrid-manager by CUBRID.
the class WhiteChart method createChart.
public JFreeChart createChart() {
final Color backGroundColor = Color.WHITE;
JFreeChart chart = ChartFactory.createTimeSeriesChart(EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, new TimeSeriesCollection(), false, false, false);
chart.setBackgroundImageAlpha(0.0f);
chart.setBackgroundPaint(backGroundColor);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.LIGHT_GRAY);
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
plot.setOutlineVisible(false);
if (backgroundIconPath != null) {
plot.setBackgroundImage(CommonUITool.getAWTImage(CubridManagerUIPlugin.getImage(backgroundIconPath).getImageData()));
}
plot.getDomainAxis().setVisible(false);
plot.getRangeAxis().setVisible(false);
return chart;
}
use of org.jfree.data.time.TimeSeriesCollection in project cubrid-manager by CUBRID.
the class ChartCompositePart method createChart.
/**
* Create the chart
*
* @return the instance of JFreeChart
*/
private JFreeChart createChart() {
timeseriescollection = new TimeSeriesCollection();
seriesMap = new TreeMap<String, TimeSeries>();
xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
int number = 0;
for (Map.Entry<String, String> entry : valueMap.entrySet()) {
String key = entry.getKey();
TimeSeries series = new TimeSeries(key);
seriesMap.put(key, series);
if (settingMap.get(key).isChecked()) {
timeseriescollection.addSeries(series);
RGB seriesRgb = settingMap.get(key).getSeriesRgb();
float width = settingMap.get(key).getWidth();
Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
xylineandshaperenderer.setSeriesPaint(number, color);
xylineandshaperenderer.setSeriesStroke(number, new BasicStroke(width, 0, 2));
number++;
}
}
DateAxis dateaxis = new DateAxis("");
NumberAxis numberaxis = new NumberAxis("");
dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
RectangleInsets rectangleInsets = new RectangleInsets();
xyplot.setAxisOffset(rectangleInsets);
xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
xyplot.setOutlineVisible(false);
xyplot.setBackgroundPaint(Color.BLACK);
xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
dateaxis.setFixedAutoRange(300000d);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
dateaxis.setTickLabelsVisible(true);
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
numberaxis.setLowerMargin(0.01D);
numberaxis.setUpperMargin(0.01D);
JFreeChart chart = new JFreeChart(chartTitle, new Font("SansSerif", 1, 15), xyplot, false);
chart.setBorderVisible(false);
chart.setBorderStroke(new BasicStroke(0.0f));
return chart;
}
use of org.jfree.data.time.TimeSeriesCollection in project adempiere by adempiere.
the class MChart method getXYDataset.
public IntervalXYDataset getXYDataset() {
dataset = new TimeSeriesCollection();
loadData();
return (IntervalXYDataset) dataset;
}
use of org.jfree.data.time.TimeSeriesCollection in project cubrid-manager by CUBRID.
the class ReplicationMonitorViewPart method createChart.
/**
* Create chart unit
*
* @return chart
*/
private JFreeChart createChart() {
//create data set
replTimeSeries = new TimeSeries(Messages.msgDelayValue + " ");
replTimeSeries.setMaximumItemAge(2592000);
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
timeseriescollection.addSeries(replTimeSeries);
//create X axis
DateAxis dateaxis = new DateAxis(Messages.msgSlaveTimes);
dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
dateaxis.setFixedAutoRange(300000d);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
dateaxis.setTickLabelsVisible(true);
//create Y axis
NumberAxis numberaxis = new NumberAxis(Messages.msgDelayValue);
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
//create display model
XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, true);
xylineandshaperenderer.setSeriesPaint(0, new Color(146, 208, 80));
xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2F, 0, 2));
XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
//set backcolor of grid
xyplot.setBackgroundPaint(Color.BLACK);
//set vertical line color of grid
xyplot.setDomainGridlinePaint(new Color(130, 130, 130));
//set horizontal line color of grid
xyplot.setRangeGridlinePaint(new Color(130, 130, 130));
xyplot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 10D));
JFreeChart chart = new JFreeChart(Messages.titlePerformancePart, new Font("SansSerif", 1, 15), xyplot, true);
return chart;
}
use of org.jfree.data.time.TimeSeriesCollection in project incubator-dubbo-ops by apache.
the class SimpleMonitorService method createChart.
private static void createChart(String key, String service, String method, String date, String[] types, Map<String, long[]> data, double[] summary, String path) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
DecimalFormat numberFormat = new DecimalFormat("###,##0.##");
TimeSeriesCollection xydataset = new TimeSeriesCollection();
for (int i = 0; i < types.length; i++) {
String type = types[i];
TimeSeries timeseries = new TimeSeries(type);
for (Map.Entry<String, long[]> entry : data.entrySet()) {
try {
timeseries.add(new Minute(dateFormat.parse(date + entry.getKey())), entry.getValue()[i]);
} catch (ParseException e) {
logger.error(e.getMessage(), e);
}
}
xydataset.addSeries(timeseries);
}
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("max: " + numberFormat.format(summary[0]) + (summary[1] >= 0 ? " min: " + numberFormat.format(summary[1]) : "") + " avg: " + numberFormat.format(summary[2]) + (summary[3] >= 0 ? " sum: " + numberFormat.format(summary[3]) : ""), toDisplayService(service) + " " + method + " " + toDisplayDate(date), key, xydataset, true, true, false);
jfreechart.setBackgroundPaint(Color.WHITE);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
xyplot.setBackgroundPaint(Color.WHITE);
xyplot.setDomainGridlinePaint(Color.GRAY);
xyplot.setRangeGridlinePaint(Color.GRAY);
xyplot.setDomainGridlinesVisible(true);
xyplot.setRangeGridlinesVisible(true);
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
BufferedImage image = jfreechart.createBufferedImage(600, 300);
try {
if (logger.isInfoEnabled()) {
logger.info("write chart: " + path);
}
File methodChartFile = new File(path);
File methodChartDir = methodChartFile.getParentFile();
if (methodChartDir != null && !methodChartDir.exists()) {
methodChartDir.mkdirs();
}
FileOutputStream output = new FileOutputStream(methodChartFile);
try {
ImageIO.write(image, "png", output);
output.flush();
} finally {
output.close();
}
} catch (IOException e) {
logger.warn(e.getMessage(), e);
}
}
Aggregations