Search in sources :

Example 1 with DateAxis

use of org.jfree.chart.axis.DateAxis in project series-rest-api by 52North.

the class ChartIoHandler method configureTimeAxis.

private void configureTimeAxis(XYPlot plot) {
    DateAxis timeAxis = (DateAxis) plot.getDomainAxis();
    final Date start = getStartTime(getTimespan());
    final Date end = getEndTime(getTimespan());
    timeAxis.setRange(start, end);
    final Locale locale = i18n.getLocale();
    String timeformat = getChartStyleDefinitions().getTimeFormat();
    DateFormat requestTimeFormat = new SimpleDateFormat(timeformat, locale);
    final DateTimeZone timezone = getTimezone();
    requestTimeFormat.setTimeZone(timezone.toTimeZone());
    timeAxis.setDateFormatOverride(requestTimeFormat);
    timeAxis.setTimeZone(timezone.toTimeZone());
}
Also used : Locale(java.util.Locale) DateAxis(org.jfree.chart.axis.DateAxis) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) DateTimeZone(org.joda.time.DateTimeZone)

Example 2 with DateAxis

use of org.jfree.chart.axis.DateAxis in project cubrid-manager by CUBRID.

the class DbDashboardHistoryViewPart method loadDatabaseChart.

/**
	 * Load an instance of ChartCompositePart stand for database monitor info
	 *
	 * @param parent an instance of Composite
	 */
private void loadDatabaseChart(Composite parent) {
    dbStatComp = new Composite(parent, SWT.NULL);
    dbStatComp.setLayout(new GridLayout());
    dbStatComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group dbGrp = new Group(dbStatComp, SWT.NONE);
    dbGrp.setText(Messages.dbDatabaseStatusSeriesGroupName);
    GridLayout layoutGrp = new GridLayout();
    layoutGrp.verticalSpacing = 0;
    layoutGrp.horizontalSpacing = 0;
    layoutGrp.marginLeft = 0;
    layoutGrp.marginRight = 0;
    layoutGrp.marginTop = 0;
    layoutGrp.marginBottom = 0;
    dbGrp.setLayout(layoutGrp);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    dbGrp.setLayoutData(gridData);
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = convertMapKey(dbStatDumpData.getDiagStatusResultMap());
    dbStatChartPart = new ChartCompositePart(dbGrp, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = dbStatChartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
    }
    dbStatChartPart.loadContent();
    JFreeChart chart = (JFreeChart) dbStatChartPart.getChart();
    chart.setBorderVisible(false);
    XYPlot xyplot = (XYPlot) dbStatChartPart.getChart().getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(true);
    xyplot.getRangeAxis().setVisible(true);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    renderer.setURLGenerator(null);
    renderer.setBaseToolTipGenerator(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) DateAxis(org.jfree.chart.axis.DateAxis) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) JFreeChart(org.jfree.chart.JFreeChart) GridLayout(org.eclipse.swt.layout.GridLayout) XYPlot(org.jfree.chart.plot.XYPlot) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with DateAxis

use of org.jfree.chart.axis.DateAxis in project cubrid-manager by CUBRID.

the class DatabaseDashboardViewPart method loadDatabaseChart.

/**
	 * Load an instance of ChartCompositePart stand for database monitor info
	 *
	 * @param parent an instance of Composite
	 */
private void loadDatabaseChart(Composite parent) {
    dbStatComp = new Composite(parent, SWT.NULL);
    dbStatComp.setLayout(new GridLayout());
    dbStatComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group dbGrp = new Group(dbStatComp, SWT.NONE);
    dbGrp.setText(Messages.dbDatabaseStatusSeriesGroupName);
    GridLayout layoutGrp = new GridLayout();
    layoutGrp.verticalSpacing = 0;
    layoutGrp.horizontalSpacing = 0;
    layoutGrp.marginLeft = 0;
    layoutGrp.marginRight = 0;
    layoutGrp.marginTop = 0;
    layoutGrp.marginBottom = 0;
    dbGrp.setLayout(layoutGrp);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    dbGrp.setLayoutData(gridData);
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = convertMapKey(dbStatDumpData.getDiagStatusResultMap());
    dbStatChartPart = new ChartCompositePart(dbGrp, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = dbStatChartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
    }
    dbStatChartPart.loadContent();
    JFreeChart chart = (JFreeChart) dbStatChartPart.getChart();
    chart.setBorderVisible(false);
    XYPlot xyplot = (XYPlot) dbStatChartPart.getChart().getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(false);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    renderer.setURLGenerator(null);
    renderer.setBaseToolTipGenerator(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) DateAxis(org.jfree.chart.axis.DateAxis) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) JFreeChart(org.jfree.chart.JFreeChart) GridLayout(org.eclipse.swt.layout.GridLayout) XYPlot(org.jfree.chart.plot.XYPlot) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 4 with DateAxis

use of org.jfree.chart.axis.DateAxis in project cubrid-manager by CUBRID.

the class HostDashboardHistoryViewPart method loadBrokerChart.

/**
	 * Load an instance of ChartCompositePart stand for broker monitor info
	 *
	 * @param parent the instance of Composite
	 */
private void loadBrokerChart(Composite parent) {
    brokerComp = new Composite(parent, SWT.NULL);
    brokerComp.setLayout(new GridLayout());
    brokerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group brokerGrp = new Group(brokerComp, SWT.NONE);
    brokerGrp.setText(Messages.hostBrokerSeriesGroupName);
    GridLayout layoutGrp = new GridLayout();
    layoutGrp.verticalSpacing = 0;
    layoutGrp.horizontalSpacing = 0;
    layoutGrp.marginLeft = 0;
    layoutGrp.marginRight = 0;
    layoutGrp.marginTop = 0;
    layoutGrp.marginBottom = 0;
    brokerGrp.setLayout(layoutGrp);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    brokerGrp.setLayoutData(gridData);
    BrokerDiagData brokerDiagData = new BrokerDiagData();
    TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
    brokerChartPart = new ChartCompositePart(brokerGrp, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = brokerChartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.BROKER);
    }
    brokerChartPart.loadContent();
    JFreeChart chart = (JFreeChart) brokerChartPart.getChart();
    chart.setBorderVisible(false);
    XYPlot xyplot = (XYPlot) brokerChartPart.getChart().getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    renderer.setURLGenerator(null);
    renderer.setBaseToolTipGenerator(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) DateAxis(org.jfree.chart.axis.DateAxis) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) JFreeChart(org.jfree.chart.JFreeChart) GridLayout(org.eclipse.swt.layout.GridLayout) XYPlot(org.jfree.chart.plot.XYPlot) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 5 with DateAxis

use of org.jfree.chart.axis.DateAxis in project jgnash by ccavanaugh.

the class MonthlyAccountBalanceChart method createVerticalXYBarChart.

private JFreeChart createVerticalXYBarChart(Account a) {
    DateFormat df = new SimpleDateFormat("MM/yy");
    TimeSeriesCollection data = createTimeSeriesCollection(a);
    DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
    dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    // if (a.getTransactionCount() > 0) {
    Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
    Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
    dateAxis.setRange(start, end);
    // }
    NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance"));
    StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
    XYBarRenderer renderer = new XYBarRenderer(0.2);
    renderer.setBaseToolTipGenerator(tooltipGenerator);
    XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
    String title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

DateAxis (org.jfree.chart.axis.DateAxis)52 XYPlot (org.jfree.chart.plot.XYPlot)44 JFreeChart (org.jfree.chart.JFreeChart)33 NumberAxis (org.jfree.chart.axis.NumberAxis)27 SimpleDateFormat (java.text.SimpleDateFormat)24 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)17 ValueAxis (org.jfree.chart.axis.ValueAxis)14 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)13 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)13 Color (java.awt.Color)10 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)9 DateFormat (java.text.DateFormat)8 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)8 Date (java.util.Date)7 Map (java.util.Map)7 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)7 BasicStroke (java.awt.BasicStroke)6 DecimalFormat (java.text.DecimalFormat)5 TreeMap (java.util.TreeMap)5 DateTickUnit (org.jfree.chart.axis.DateTickUnit)5