Search in sources :

Example 11 with XYLineAndShapeRenderer

use of org.jfree.chart.renderer.xy.XYLineAndShapeRenderer in project gephi by gephi.

the class ChartUtils method decorateChart.

public static void decorateChart(JFreeChart chart) {
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 2, 2));
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainGridlinePaint(java.awt.Color.GRAY);
    plot.setRangeGridlinePaint(java.awt.Color.GRAY);
    plot.setRenderer(renderer);
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)

Example 12 with XYLineAndShapeRenderer

use of org.jfree.chart.renderer.xy.XYLineAndShapeRenderer in project pinot by linkedin.

the class AnomalyGraphGenerator method createChart.

/**
   * Creates a chart containing the current/baseline data (in that order) as well as markers for
   * each anomaly interval. timeGranularity and windowMillis are used to determine the date format
   * and spacing for tick marks on the domain (x) axis.
   */
public JFreeChart createChart(final XYDataset dataset, final String metric, final TimeGranularity timeGranularity, final long windowMillis, final Map<RawAnomalyResultDTO, String> anomaliesWithLabels) {
    // create the chart...
    final JFreeChart chart = // no chart title for email
    ChartFactory.createTimeSeriesChart(// no chart title for email
    null, // x axis label
    "Date (" + DEFAULT_TIME_ZONE.getID() + ")", // y axis label
    metric, // data
    dataset, // include legend
    true, // tooltips - n/a if the chart will be saved as an img
    false, // urls - n/a if the chart will be saved as an img
    false);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    // dashboard webapp currently uses solid blue for current and dashed blue for baseline
    // (5/2/2016)
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.BLUE);
    // http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo5showingtheuseofacustomdrawingsupplier.htm
    // set baseline to be dashed
    renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f));
    plot.setRenderer(renderer);
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    DateTickUnit dateTickUnit = getDateTickUnit(timeGranularity, windowMillis);
    SimpleDateFormat dateFormat = getDateFormat(timeGranularity);
    axis.setDateFormatOverride(dateFormat);
    axis.setTickUnit(dateTickUnit);
    axis.setVerticalTickLabels(true);
    List<Marker> anomalyIntervals = getAnomalyIntervals(anomaliesWithLabels);
    for (Marker marker : anomalyIntervals) {
        plot.addDomainMarker(marker);
    }
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) XYPlot(org.jfree.chart.plot.XYPlot) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) ValueMarker(org.jfree.chart.plot.ValueMarker) Marker(org.jfree.chart.plot.Marker) IntervalMarker(org.jfree.chart.plot.IntervalMarker) SimpleDateFormat(java.text.SimpleDateFormat) JFreeChart(org.jfree.chart.JFreeChart)

Example 13 with XYLineAndShapeRenderer

use of org.jfree.chart.renderer.xy.XYLineAndShapeRenderer in project cubrid-manager by CUBRID.

the class HostDashboardViewPart 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);
    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) 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) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 14 with XYLineAndShapeRenderer

use of org.jfree.chart.renderer.xy.XYLineAndShapeRenderer 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;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor) RGB(org.eclipse.swt.graphics.RGB) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) RectangleInsets(org.jfree.ui.RectangleInsets) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 15 with XYLineAndShapeRenderer

use of org.jfree.chart.renderer.xy.XYLineAndShapeRenderer 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;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) RectangleInsets(org.jfree.ui.RectangleInsets) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)16 XYPlot (org.jfree.chart.plot.XYPlot)15 JFreeChart (org.jfree.chart.JFreeChart)11 DateAxis (org.jfree.chart.axis.DateAxis)9 Map (java.util.Map)7 BasicStroke (java.awt.BasicStroke)6 Color (java.awt.Color)6 TreeMap (java.util.TreeMap)6 ChartCompositePart (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart)4 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)4 ShowSetting (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 Group (org.eclipse.swt.widgets.Group)4 NumberAxis (org.jfree.chart.axis.NumberAxis)4 TimeSeries (org.jfree.data.time.TimeSeries)4 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)4 Font (java.awt.Font)3