use of org.jfree.chart.JFreeChart in project cubrid-manager by CUBRID.
the class CombinedBarTimeSeriesChart method createSeriesChart.
/**
* Create the series chart
*
* @return an instance of series chart
*/
private JFreeChart createSeriesChart() {
if (isAreaRender) {
seriesdataset = createTableSeriesDataset();
} else {
seriesdataset = createTimeSeriesDataset();
}
JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", seriesdataset, false, false, false);
chart.setBorderVisible(false);
chart.setBorderStroke(new BasicStroke(0.0f));
//plot
XYPlot xyplot = (XYPlot) chart.getPlot();
xyplot.setOutlineVisible(false);
RectangleInsets rectangleInsets = new RectangleInsets();
xyplot.setAxisOffset(rectangleInsets);
xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
xyplot.setBackgroundPaint(Color.BLACK);
xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
if (isAreaRender) {
XYAreaRenderer2 render = new StackedXYAreaRenderer2();
render.setSeriesPaint(0, Color.GREEN);
render.setSeriesPaint(1, Color.RED);
xyplot.setRenderer(render);
} else {
XYLineAndShapeRenderer render = (XYLineAndShapeRenderer) xyplot.getRenderer();
render.setSeriesPaint(0, Color.GREEN);
render.setSeriesPaint(1, Color.RED);
}
//dateAxis
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setFixedAutoRange(300000d);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
dateaxis.setVisible(isShowSeriesAxis);
numberaxis = (NumberAxis) xyplot.getRangeAxis();
numberaxis.setVisible(isShowSeriesAxis);
numberaxis.setRange(0 - 0.5, barMax + 0.5);
return chart;
}
use of org.jfree.chart.JFreeChart in project cubrid-manager by CUBRID.
the class DbSystemMonitorCompositePart method fireChartSetting.
/**
* This method is responsible for preparing data for ChartSettingDlg and
* dealing with the results of chartSettingDlg
*
*/
public void fireChartSetting() {
ChartSettingDlg chartSettingDlg = new ChartSettingDlg(composite.getShell());
chartSettingDlg.setHasTitlSetting(false);
chartSettingDlg.setHasHistoryPath(true);
chartSettingDlg.setHasAxisSetting(false);
chartSettingDlg.setHasSeriesItemSetting(false);
chartSettingDlg.setHasChartSelection(true);
// plot appearance
XYPlot dbStatplot = cpuChart.getSeriesChart().getXYPlot();
String plotBgColor = trimPaintColor(dbStatplot.getBackgroundPaint().toString());
String plotDomainGridColor = trimPaintColor(dbStatplot.getDomainGridlinePaint().toString());
String plotRangGridColor = trimPaintColor(dbStatplot.getRangeGridlinePaint().toString());
chartSettingDlg.setPlotBgColor(plotBgColor);
chartSettingDlg.setPlotDomainGridColor(plotDomainGridColor);
chartSettingDlg.setPlotRangGridColor(plotRangGridColor);
//history setting
chartSettingDlg.setHistoryFileName(historyFileName);
chartSettingDlg.setHistoryPath(historyPath);
// chart selection
chartSettingDlg.setChartSelectionLst(getSelectedCharts());
if (chartSettingDlg.open() == Dialog.OK) {
// plot appearance
plotBgColor = chartSettingDlg.getPlotBgColor();
plotDomainGridColor = chartSettingDlg.getPlotDomainGridColor();
plotRangGridColor = chartSettingDlg.getPlotRangGridColor();
JFreeChart cpuBarChart = cpuChart.getBarChart();
Plot cpuBarPlot = cpuBarChart.getPlot();
XYPlot cpuSeriesPlot = (XYPlot) cpuChart.getSeriesChart().getPlot();
JFreeChart memoryBarChart = memoryChart.getBarChart();
Plot memoryBarPlot = memoryBarChart.getPlot();
XYPlot memorySeriesPlot = (XYPlot) memoryChart.getSeriesChart().getPlot();
// history path
String newHistoryPath = chartSettingDlg.getHistoryPath();
boolean isChangedHistoryPath = historyPath.equals(newHistoryPath) ? false : true;
if (isChangedHistoryPath) {
historyPath = newHistoryPath;
historyFileHelp.setHistoryPath(historyPath);
historyFileHelp.setChangedHistoryPath(true);
}
int red = 0;
int green = 0;
int blue = 0;
//background
red = getColorElem(plotBgColor, 0);
green = getColorElem(plotBgColor, 1);
blue = getColorElem(plotBgColor, 2);
Color bgColor = new Color(red, green, blue);
dbStatplot.setBackgroundPaint(bgColor);
//cpu chart
cpuBarChart.setBackgroundPaint(bgColor);
cpuBarPlot.setBackgroundPaint(bgColor);
cpuSeriesPlot.setBackgroundPaint(bgColor);
//memoryChart
memoryBarPlot.setBackgroundPaint(bgColor);
memoryBarChart.setBackgroundPaint(bgColor);
memorySeriesPlot.setBackgroundPaint(bgColor);
//DomainGridColor
//db Chart
red = getColorElem(plotDomainGridColor, 0);
green = getColorElem(plotDomainGridColor, 1);
blue = getColorElem(plotDomainGridColor, 2);
Color domainGridlineColor = new Color(red, green, blue);
dbStatplot.setDomainGridlinePaint(domainGridlineColor);
//cpu chart
cpuSeriesPlot.setDomainGridlinePaint(domainGridlineColor);
//memoryChart
memorySeriesPlot.setDomainGridlinePaint(domainGridlineColor);
//RangeGridColor
red = getColorElem(plotRangGridColor, 0);
green = getColorElem(plotRangGridColor, 1);
blue = getColorElem(plotRangGridColor, 2);
Color rangeGridColor = new Color(red, green, blue);
dbStatplot.setRangeGridlinePaint(rangeGridColor);
//cpu chart
cpuSeriesPlot.setRangeGridlinePaint(rangeGridColor);
//memoryChart
memorySeriesPlot.setRangeGridlinePaint(rangeGridColor);
//chart Selection
fireChartSelection(chartSettingDlg.getChartSelectionLst());
}
}
use of org.jfree.chart.JFreeChart in project processdash by dtuma.
the class ScheduleBalancingDialog method addChartToPanel.
private void addChartToPanel(JPanel panel, int gridY) {
// create a dataset for displaying schedule data
chartData = new ChartData();
updateChart();
// customize a renderer for displaying schedules
XYBarRenderer renderer = new XYBarRenderer();
renderer.setUseYInterval(true);
renderer.setBaseToolTipGenerator(chartData);
renderer.setDrawBarOutline(true);
// use an inverted, unadorned numeric Y-axis
NumberAxis yAxis = new NumberAxis();
yAxis.setInverted(true);
yAxis.setTickLabelsVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setUpperMargin(0);
// use a Date-based X-axis
DateAxis xAxis = new DateAxis();
// create an XY plot to display the data
XYPlot plot = new XYPlot(chartData, xAxis, yAxis, renderer);
plot.setOrientation(PlotOrientation.VERTICAL);
plot.setRangeGridlinesVisible(false);
plot.setNoDataMessage(TaskScheduleDialog.resources.getString("Chart.No_Data_Message"));
// create a chart and a chart panel
JFreeChart chart = new JFreeChart(plot);
chart.removeLegend();
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setInitialDelay(50);
chartPanel.setDismissDelay(60000);
chartPanel.setMinimumDrawHeight(40);
chartPanel.setMinimumDrawWidth(40);
chartPanel.setMaximumDrawHeight(3000);
chartPanel.setMaximumDrawWidth(3000);
chartPanel.setPreferredSize(new Dimension(300, gridY * 25));
// add the chart to the dialog content pane
GridBagConstraints c = new GridBagConstraints();
c.gridy = gridY;
c.gridwidth = 4;
c.weightx = 2;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 0, 0, 0);
panel.add(chartPanel, c);
// colors with the schedule rows so they can act as a legend
for (int i = scheduleRows.size(); i-- > 0; ) {
ScheduleTableRow oneRow = scheduleRows.get(i);
oneRow.addColoredIcon(renderer.lookupSeriesPaint(i));
}
}
use of org.jfree.chart.JFreeChart in project dhis2-core by dhis2.
the class DefaultChartService method getRadarChart.
private JFreeChart getRadarChart(BaseChart chart, CategoryDataset dataSet) {
SpiderWebPlot plot = new SpiderWebPlot(dataSet, TableOrder.BY_ROW);
plot.setLabelFont(LABEL_FONT);
JFreeChart radarChart = new JFreeChart(chart.getName(), TITLE_FONT, plot, !chart.isHideLegend());
setBasicConfig(radarChart, chart);
return radarChart;
}
use of org.jfree.chart.JFreeChart in project dhis2-core by dhis2.
the class DefaultChartService method getMultiplePieChart.
private JFreeChart getMultiplePieChart(BaseChart chart, CategoryDataset[] dataSets) {
JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart(chart.getName(), dataSets[0], TableOrder.BY_ROW, !chart.isHideLegend(), false, false);
setBasicConfig(multiplePieChart, chart);
if (multiplePieChart.getLegend() != null) {
multiplePieChart.getLegend().setItemFont(SUB_TITLE_FONT);
}
MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot();
JFreeChart pieChart = multiplePiePlot.getPieChart();
pieChart.setBackgroundPaint(COLOR_TRANSPARENT);
pieChart.getTitle().setFont(SUB_TITLE_FONT);
PiePlot piePlot = (PiePlot) pieChart.getPlot();
piePlot.setBackgroundPaint(COLOR_TRANSPARENT);
piePlot.setOutlinePaint(COLOR_TRANSPARENT);
piePlot.setLabelFont(LABEL_FONT);
piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}"));
piePlot.setSimpleLabels(true);
piePlot.setIgnoreZeroValues(true);
piePlot.setIgnoreNullValues(true);
piePlot.setShadowXOffset(0d);
piePlot.setShadowYOffset(0d);
for (int i = 0; i < dataSets[0].getColumnCount(); i++) {
piePlot.setSectionPaint(dataSets[0].getColumnKey(i), COLORS[(i % COLORS.length)]);
}
return multiplePieChart;
}
Aggregations