Example |
Here is a simple Line Chart. If you would like to not have shapes plotted on the line, simply pass NULL as the value on the Array index of Shapes to the LineChartProperties Object. |
String[] xAxisLabels= { "1998", "1999", "2000", "2001", "2002", "2003", "2004" }; String xAxisTitle= "Years"; String yAxisTitle= "Problems"; String title= "Micro$oft at Work"; DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title ); double[][] data= new double[][]{ { 250, 45, -36, 66, 145, 80, 55 } }; String[] legendLabels= { "Bugs" }; Paint[] paints= TestDataGenerator.getRandomPaints( 1 ); Stroke[] strokes= { LineChartProperties.DEFAULT_LINE_STROKE }; Shape[] shapes= { PointChartProperties.SHAPE_CIRCLE }; LineChartProperties lineChartProperties= new LineChartProperties( strokes, shapes ); AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data, legendLabels, paints, ChartType.LINE, lineChartProperties ); dataSeries.addIAxisPlotDataSet( axisChartDataSet ); ChartProperties chartProperties= new ChartProperties(); AxisProperties axisProperties= new AxisProperties(); LegendProperties legendProperties= new LegendProperties(); AxisChart axisChart= new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, AxisCharts.width, AxisCharts.height ); |
Line Strokes |
The lines in the chart use the java.awt.Stroke Interface to control their rendering appearance. This is specified on the LineChartProperties Object. |
Stroke[] strokes= new Stroke[ 2 ]; strokes[ 0 ]= new BasicStroke( 3.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 5f, new float[]{ 5f, 5f, 10f, 5f}, 4f ); strokes[ 1 ]= new BasicStroke( 5.0f ); Shape[] shapes= { PointChartProperties.SHAPE_CIRCLE, null }; LineChartProperties lineChartProperties= new LineChartProperties( strokes, shapes ); |
Null Values |
You can show missing values on Line Charts by using Double.NaN values in your dataset. |
data[ 0 ][ 3 ]= Double.NaN data[ 0 ][ 4 ]= Double.NaN |