Java Code Examples for org.jfree.chart.axis.ValueAxis#setLabel()

The following examples show how to use org.jfree.chart.axis.ValueAxis#setLabel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataPlotPanel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private void configureRangeAxis(int index, MetadataElement metadataElement, String yAttributeName, String[] recordElementNames,
                                String refRecordName,
                                double[] recordIndices) {
    double[] yAxisData = new double[recordIndices.length];
    Arrays.setAll(yAxisData, i -> getDataAsDouble(metadataElement.getElement(recordElementNames[i]).getAttribute(yAttributeName).getData()));
    DefaultXYDataset dataset2 = new DefaultXYDataset();
    dataset2.addSeries(yAttributeName, new double[][]{recordIndices, yAxisData});
    xyPlot.setDataset(index, dataset2);
    xyPlot.mapDatasetToRangeAxis(index, index);

    int yDataType = getAttributeType(metadataElement.getElement(refRecordName).getAttribute(yAttributeName));
    ValueAxis yAxis = configureRangeIndex(index, yDataType);
    String yUnit = metadataElement.getElement(refRecordName).getAttribute(yAttributeName).getUnit();
    yAxis.setLabel(getYAxisLabel(yAttributeName, yUnit));
    xyPlot.setRenderer(index, creatItemRenderer(index, yDataType));
}
 
Example 2
Source File: MetadataPlotPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private ValueAxis configureRangeIndex(int index, int dataType) {
    ValueAxis axis = createAxis(dataType);
    axis.setAutoRange(true);
    Font axisFont = axis.getLabelFont().deriveFont(Font.BOLD);
    axis.setLabelFont(axisFont);
    axis.setLabel(String.format("Y%d Samples", index + 1));
    xyPlot.setRangeAxis(index, axis);
    xyPlot.setRangeAxisLocation(index, index == 0 ? AxisLocation.BOTTOM_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT);
    return axis;
}
 
Example 3
Source File: MetadataPlotPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void configureDomainAxis(int index, String nameX, int dataType) {
    ValueAxis axis = createAxis(dataType);
    axis.setAutoRange(true);
    axis.setAutoRangeMinimumSize(2);
    axis.setLabel(nameX);
    Font axisFont = axis.getLabelFont().deriveFont(Font.BOLD);
    axis.setLabelFont(axisFont);
    xyPlot.setDomainAxis(index, axis);
}
 
Example 4
Source File: KafkaFT.java    From flink-perf with Apache License 2.0 5 votes vote down vote up
private static JFreeChart createChart(XYDataset xydataset) {
	JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Flink Exactly-Once on Kafka with YARN Chaos Monkey", "Date", "Value", xydataset, true, true, false);
	XYPlot xyplot = (XYPlot) jfreechart.getPlot();

	XYLineAndShapeRenderer r0 = (XYLineAndShapeRenderer) xyplot.getRenderer(0);

	// draw data points as points
	r0.setSeriesShapesVisible(2, true);
	r0.setSeriesLinesVisible(2, true);
	// order elements as assed
	xyplot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

	DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();

	Number first = xydataset.getX(0, 0);
	Minute minute = new Minute(new Date((Long)first));
	System.out.println("first = "+first);
	RelativeDateFormat relativedateformat = new RelativeDateFormat(minute.getFirstMillisecond());
	relativedateformat.setSecondFormatter(new DecimalFormat("00"));
	dateaxis.setDateFormatOverride(relativedateformat);


	//dateaxis.setDateFormatOverride(new SimpleDateFormat("mm:ss"));
	ValueAxis valueaxis = xyplot.getRangeAxis();
	valueaxis.setAutoRangeMinimumSize(1.0D);
	valueaxis.setLabel("Elements/Core");

	xyplot.getRenderer().setSeriesPaint(2, ChartColor.DARK_MAGENTA);
	return jfreechart;
}
 
Example 5
Source File: MetadataPlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void configureChartForDefault(MetadataElement metadataElement, String nameX, String nameY1, String nameY2) {
    if (!isValidYField(metadataElement, metadataElement.getName(), nameY1)) {
        return;
    }

    MetadataAttribute xAttribute = metadataElement.getAttribute(nameX);
    int xDataType = getAttributeType(xAttribute);
    configureDomainAxis(0, nameX, xDataType);
    double[] xData = new double[1];
    Arrays.setAll(xData, i -> getDataAsDouble(xAttribute.getData()));

    MetadataAttribute y1Attribute = metadataElement.getAttribute(nameY1);
    int y1DataType = getAttributeType(y1Attribute);
    ValueAxis y1Axis = configureRangeIndex(0, y1DataType);
    String unitY1 = y1Attribute.getUnit();
    y1Axis.setLabel(getYAxisLabel(nameY1, unitY1));
    double[] y1AxisData = new double[1];
    Arrays.setAll(y1AxisData, i -> getDataAsDouble(y1Attribute.getData()));
    DefaultXYDataset dataset1 = new DefaultXYDataset();
    dataset1.addSeries(nameY1, new double[][]{xData, y1AxisData});
    xyPlot.setDataset(0, dataset1);
    xyPlot.mapDatasetToRangeAxis(0, 0);
    xyPlot.setRenderer(0, creatItemRenderer(0, y1DataType));

    if (!isValidYField(metadataElement, metadataElement.getName(), nameY2)) {
        return;
    }

    MetadataAttribute y2Attribute = metadataElement.getAttribute(nameY2);
    int y2DataType = getAttributeType(y2Attribute);
    ValueAxis y2Axis = configureRangeIndex(1, y2DataType);
    String unitY2 = y2Attribute.getUnit();
    y2Axis.setLabel(getYAxisLabel(nameY2, unitY2));
    double[] y2AxisData = new double[1];
    Arrays.setAll(y2AxisData, i -> getDataAsDouble(y2Attribute.getData()));
    DefaultXYDataset dataset2 = new DefaultXYDataset();
    dataset2.addSeries(nameY2, new double[][]{xData, y2AxisData});
    xyPlot.setDataset(1, dataset2);
    xyPlot.mapDatasetToRangeAxis(1, 1);
    xyPlot.setRenderer(1, creatItemRenderer(1, y1DataType));
}