use of org.jfree.chart.axis.DateAxis 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.chart.axis.DateAxis 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.chart.axis.DateAxis in project jgnash by ccavanaugh.
the class SecuritiesHistoryDialog method createChart.
private static JFreeChart createChart(final SecurityNode node) {
Objects.requireNonNull(node);
final List<SecurityHistoryNode> hNodes = node.getHistoryNodes();
final Date max = DateUtils.asDate(hNodes.get(hNodes.size() - 1).getLocalDate());
final Date min = DateUtils.asDate(hNodes.get(0).getLocalDate());
final DateAxis timeAxis = new DateAxis(null);
timeAxis.setVisible(false);
timeAxis.setAutoRange(false);
timeAxis.setRange(min, max);
final NumberAxis valueAxis = new NumberAxis(null);
valueAxis.setAutoRangeIncludesZero(false);
valueAxis.setVisible(false);
final XYAreaRenderer renderer = new XYAreaRenderer();
renderer.setBaseToolTipGenerator(new SecurityItemLabelGenerator(node));
renderer.setOutline(true);
renderer.setSeriesPaint(0, new Color(225, 247, 223));
final XYPlot plot = new XYPlot(null, timeAxis, valueAxis, renderer);
final List<List<SecurityHistoryNode>> groups = node.getHistoryNodeGroupsBySplits();
for (int i = 0; i < groups.size(); i++) {
int size = groups.get(i).size();
Date[] date = new Date[size];
double[] high = new double[size];
double[] low = new double[size];
double[] open = new double[size];
double[] close = new double[size];
double[] volume = new double[size];
for (int j = 0; j < size; j++) {
final SecurityHistoryNode hNode = groups.get(i).get(j);
date[j] = DateUtils.asDate(hNode.getLocalDate());
high[j] = hNode.getAdjustedHigh().doubleValue();
low[j] = hNode.getAdjustedLow().doubleValue();
open[j] = hNode.getAdjustedPrice().doubleValue();
close[j] = hNode.getAdjustedPrice().doubleValue();
volume[j] = hNode.getVolume();
}
final AbstractXYDataset data = new DefaultHighLowDataset(node.getDescription() + i, date, high, low, open, close, volume);
plot.setDataset(i, data);
}
plot.setInsets(new RectangleInsets(1, 1, 1, 1));
final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.chart.axis.DateAxis 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);
}
}
use of org.jfree.chart.axis.DateAxis in project pentaho-platform by pentaho.
the class JFreeChartEngine method createStackedTimeSeriesChart.
/*
* The only type of chart this method will produce is a stacked XY area chart with a time series dimension. This
* is because the dataset that jFreeChart expects is different than the regular TimeSeriesCOllection. More
* lipstick on this homely pig.
*/
private static JFreeChart createStackedTimeSeriesChart(final TimeTableXYDatasetChartDefinition chartDefinition) {
JFreeChart chart = null;
// TODO Make the following accessible from the chartDefinition
String domainAxisLabel = null;
String rangeAxisLabel = null;
boolean tooltips = true;
boolean urls = true;
// -----------------------------------------------------------
String title = chartDefinition.getTitle();
boolean legend = chartDefinition.isLegendIncluded();
DateAxis domainAxis = new DateAxis(domainAxisLabel, TimeZone.getDefault());
ValueAxis rangeAxis = new NumberAxis(rangeAxisLabel);
XYItemRenderer renderer = null;
switch(chartDefinition.getChartType()) {
case AREA_CHART_TYPE:
renderer = chartDefinition.isStacked() ? new StackedXYAreaRenderer2() : new XYAreaRenderer();
break;
default:
// should log an error if invalid chart type passed in - at least return null for no renderer
return null;
}
if (tooltips) {
XYToolTipGenerator generator = new StandardXYToolTipGenerator(chartDefinition.getTooltipContent(), new SimpleDateFormat(chartDefinition.getTooltipXFormat()), new DecimalFormat(chartDefinition.getTooltipYFormat()));
renderer.setToolTipGenerator(generator);
}
if (urls) {
renderer.setURLGenerator(new StandardXYURLGenerator());
}
renderer.setStroke(JFreeChartEngine.getLineStyleStroke(chartDefinition.getLineStyle(), chartDefinition.getLineWidth()));
XYPlot plot = new XYPlot(chartDefinition, domainAxis, rangeAxis, renderer);
JFreeChartEngine.updatePlot(plot, chartDefinition);
chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
Aggregations