use of org.jfree.chart.axis.ValueAxis in project zaproxy by zaproxy.
the class ScanProgressDialog method createChart.
private JFreeChart createChart(final XYDataset dataset) {
JFreeChart result = ChartFactory.createTimeSeriesChart(// No title - it just takes up space
null, Constant.messages.getString("ascan.progress.chart.time"), Constant.messages.getString("ascan.progress.chart.responses"), dataset, true, true, false);
XYPlot plot = result.getXYPlot();
ValueAxis daxis = plot.getDomainAxis();
daxis.setAutoRange(true);
daxis.setAutoRangeMinimumSize(60000.0);
plot.getRangeAxis().setAutoRangeMinimumSize(20);
return result;
}
use of org.jfree.chart.axis.ValueAxis in project series-rest-api by 52North.
the class ChartIoHandler method configureDomainAxis.
private void configureDomainAxis(XYPlot plot) {
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setTickLabelFont(LabelConstants.FONT_LABEL);
domainAxis.setLabelFont(LabelConstants.FONT_LABEL);
domainAxis.setTickLabelPaint(LabelConstants.COLOR);
domainAxis.setLabelPaint(LabelConstants.COLOR);
}
use of org.jfree.chart.axis.ValueAxis in project dhis2-core by dhis2.
the class DefaultChartService method getJFreeChart.
/**
* Returns a JFreeChart of type defined in the chart argument.
*/
private JFreeChart getJFreeChart(PlotData plotData) {
final CategoryDataset[] dataSets = getCategoryDataSet(plotData);
final CategoryDataset dataSet = dataSets[0];
final BarRenderer barRenderer = getBarRenderer();
final LineAndShapeRenderer lineRenderer = getLineRenderer();
// ---------------------------------------------------------------------
// Plot
// ---------------------------------------------------------------------
CategoryPlot plot;
if (plotData.isType(VisualizationType.LINE.name())) {
plot = new CategoryPlot(dataSet, new CategoryAxis(), new NumberAxis(), lineRenderer);
plot.setOrientation(PlotOrientation.VERTICAL);
} else if (plotData.isType(VisualizationType.COLUMN.name())) {
plot = new CategoryPlot(dataSet, new CategoryAxis(), new NumberAxis(), barRenderer);
plot.setOrientation(PlotOrientation.VERTICAL);
} else if (plotData.isType(VisualizationType.BAR.name())) {
plot = new CategoryPlot(dataSet, new CategoryAxis(), new NumberAxis(), barRenderer);
plot.setOrientation(PlotOrientation.HORIZONTAL);
} else if (plotData.isType(VisualizationType.AREA.name())) {
return getStackedAreaChart(plotData, dataSet);
} else if (plotData.isType(VisualizationType.PIE.name())) {
return getMultiplePieChart(plotData, dataSets);
} else if (plotData.isType(VisualizationType.STACKED_COLUMN.name())) {
return getStackedBarChart(plotData, dataSet, false);
} else if (plotData.isType(VisualizationType.STACKED_BAR.name())) {
return getStackedBarChart(plotData, dataSet, true);
} else if (plotData.isType(VisualizationType.RADAR.name())) {
return getRadarChart(plotData, dataSet);
} else if (plotData.isType(VisualizationType.GAUGE.name())) {
Number number = dataSet.getValue(0, 0);
ValueDataset valueDataSet = new DefaultValueDataset(number);
return getGaugeChart(plotData, valueDataSet);
} else {
throw new IllegalArgumentException("Illegal or no chart type: " + plotData.getType());
}
if (plotData.isRegression()) {
plot.setDataset(1, dataSets[1]);
plot.setRenderer(1, lineRenderer);
}
JFreeChart jFreeChart = new JFreeChart(plotData.getName(), TITLE_FONT, plot, !plotData.isHideLegend());
setBasicConfig(jFreeChart, plotData);
if (plotData.isTargetLine()) {
plot.addRangeMarker(getMarker(plotData.getTargetLineValue(), plotData.getTargetLineLabel()));
}
if (plotData.isBaseLine()) {
plot.addRangeMarker(getMarker(plotData.getBaseLineValue(), plotData.getBaseLineLabel()));
}
if (plotData.isHideSubtitle()) {
jFreeChart.addSubtitle(getSubTitle(plotData));
}
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
// ---------------------------------------------------------------------
// Category label positions
// ---------------------------------------------------------------------
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
domainAxis.setLabel(plotData.getDomainAxisLabel());
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setLabel(plotData.getRangeAxisLabel());
return jFreeChart;
}
use of org.jfree.chart.axis.ValueAxis in project GT by Tencent.
the class CPURealTimeChart method createChart.
@Override
public JFreeChart createChart() {
final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU实时曲线图", "时间", "CPU%", dataset, true, true, false);
// 设置,不然中文会存在乱码
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));
XYPlot xyPlot = (XYPlot) chart.getXYPlot();
ValueAxis domainAxis = xyPlot.getDomainAxis();
ValueAxis rangeAxis = xyPlot.getRangeAxis();
domainAxis.setLabelFont(new Font("宋体", Font.BOLD, 14));
domainAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));
rangeAxis.setLabelFont(new Font("宋体", Font.BOLD, 14));
rangeAxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12));
return chart;
}
use of org.jfree.chart.axis.ValueAxis in project n2a by frothga.
the class Plot method updateChart.
public void updateChart(JFreeChart chart) {
XYPlot plot = chart.getXYPlot();
plot.setNotify(false);
updateDatasets();
LegendTitle legend = chart.getLegend();
legend.setVisible(columnCount <= 10);
NumberAxis axis0 = (NumberAxis) plot.getRangeAxis();
axis0.setAutoRangeIncludesZero(false);
if (range0 > 0)
axis0.setAutoRangeMinimumSize(range0 / 2);
else
axis0.setAutoRangeMinimumSize(1);
// range locked
if (!Double.isNaN(ymin))
axis0.setRange(ymin, ymax);
if (!Double.isNaN(xmin)) {
ValueAxis x = plot.getDomainAxis();
x.setRange(xmin, xmax);
}
int count = dataset0.getSeriesCount();
float shift = 0;
if (dataset1 != null) {
// So we use only half of the color range
count *= 2;
shift = 0.75f + 0.5f / count;
}
XYLineAndShapeRenderer renderer;
XYItemRenderer ir = plot.getRenderer();
if (ir instanceof XYLineAndShapeRenderer) {
renderer = (XYLineAndShapeRenderer) ir;
} else {
renderer = new XYLineAndShapeRenderer();
plot.setRenderer(renderer);
}
for (int i = 0; i < dataset0.getSeriesCount(); i++) {
Column column = left.get(i);
// does not fire renderer change event
styleSeries(renderer, i, column, count, shift);
}
// fires renderer change event
renderer.setDrawSeriesLineAsPath(true);
if (dataset1 == null) {
axis0.setTickMarkPaint(Color.black);
axis0.setTickLabelPaint(Color.black);
axis0.setAxisLinePaint(Color.black);
plot.setDataset(1, null);
plot.setRangeAxis(1, null);
plot.setRenderer(1, null);
} else {
Color color0 = Color.getHSBColor(0.0f, 1.0f, 0.8f);
axis0.setTickMarkPaint(color0);
axis0.setTickLabelPaint(color0);
axis0.setAxisLinePaint(color0);
plot.setDataset(1, dataset1);
plot.mapDatasetToRangeAxis(1, 1);
NumberAxis axis1 = (NumberAxis) plot.getRangeAxis(1);
if (axis1 == null) {
axis1 = new NumberAxis();
axis1.setAutoRangeIncludesZero(false);
axis1.setTickLabelFont(axis0.getTickLabelFont());
Color color1 = Color.getHSBColor(0.5f, 1.0f, 0.8f);
axis1.setTickMarkPaint(color1);
axis1.setTickLabelPaint(color1);
axis1.setAxisLinePaint(color1);
plot.setRangeAxis(1, axis1);
}
// else we created axis1, so all the initial settings are correct
if (range1 > 0)
axis1.setAutoRangeMinimumSize(range1 / 2);
else
axis1.setAutoRangeMinimumSize(1);
count = dataset1.getSeriesCount() * 2;
shift = 0.25f + 0.5f / count;
ir = plot.getRenderer(1);
if (ir instanceof XYLineAndShapeRenderer) {
renderer = (XYLineAndShapeRenderer) ir;
} else {
renderer = new XYLineAndShapeRenderer();
plot.setRenderer(1, renderer);
}
for (int i = 0; i < dataset1.getSeriesCount(); i++) {
Column column = right.get(i);
styleSeries(renderer, i, column, count, shift);
}
renderer.setDrawSeriesLineAsPath(true);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
}
plot.setNotify(true);
}
Aggregations