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);
}
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;
}
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);
}
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;
}
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;
}
Aggregations