From: <de...@in...> - 2004-11-12 17:18:42
|
Hi, Could anybody tell me whats wrong with the following code to plot a = scatter plot. It doesnt show the data points. The title, legends and = axis titles diplay correclty though. Thanks Deepa public void scatterChartDraw(BaseXWPropertyMap view, ChartDataSet cData, = BaseXWPropertyMap style) throws ChartDataException, PropertyException { =20 =20 String[] xAxisLabels =3D { "1998", "1999", "2000", "2001", "2002", "2003", "2004" }; String xAxisTitle =3D "Years"; String yAxisTitle =3D "Problems"; String title =3D "Microsoft at Work"; DataSeries dataSeries =3D new DataSeries(xAxisLabels, xAxisTitle, yAxisTitle, title ); =20 double[][] data =3D new double[][]{ {250, 45, 36, 66, 145, 80, 55} }; String[] legendLabels =3D { "Bugs" }; Paint[] paints =3D {Color.pink}; =20 Stroke[] strokes =3D { ScatterPlotProperties.DEFAULT_LINE_STROKE }; Shape[] shapes =3D { PointChartProperties.SHAPE_DIAMOND}; ScatterPlotProperties properties =3D new ScatterPlotProperties(strokes, shapes); =20 AxisChartDataSet axisChartDataSet =3D new AxisChartDataSet(data, legendLabels, paints, ChartType.SCATTER_PLOT, properties ); dataSeries.addIAxisPlotDataSet (axisChartDataSet); =20 ChartProperties chartProperties =3D new ChartProperties(); chartProperties.setBackgroundPaint((Paint) Color.yellow);=20 chartProperties.setBorderStroke( (ChartStroke) = ChartStroke.DEFAULT_AXIS );=20 =20 AxisProperties axisProperties =3D new AxisProperties(); LegendProperties legendProperties =3D new LegendProperties(); =20 AxisChart axisChart=3D new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, width, height); =20 this.exportImage( axisChart, filePath ); =20 } |
From: Nathaniel G. A. <nat...@ya...> - 2004-11-14 13:41:33
|
you need to use a ScatterPlotDataSet not an AxisChartDataSet --- de...@in... wrote: > Hi, > > Could anybody tell me whats wrong with the following code to plot a scatter plot. It doesnt show > the data points. The title, legends and axis titles diplay correclty though. > > Thanks > Deepa > > > public void scatterChartDraw(BaseXWPropertyMap view, ChartDataSet cData, BaseXWPropertyMap > style) throws ChartDataException, PropertyException > { > > > String[] xAxisLabels = { "1998", "1999", "2000", "2001", > "2002", "2003", "2004" }; > String xAxisTitle = "Years"; > String yAxisTitle = "Problems"; > String title = "Microsoft 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 = {Color.pink}; > > Stroke[] strokes = { ScatterPlotProperties.DEFAULT_LINE_STROKE }; > Shape[] shapes = { PointChartProperties.SHAPE_DIAMOND}; > ScatterPlotProperties properties = > new ScatterPlotProperties(strokes, shapes); > > AxisChartDataSet axisChartDataSet = > new AxisChartDataSet(data, legendLabels, paints, > ChartType.SCATTER_PLOT, properties ); > dataSeries.addIAxisPlotDataSet (axisChartDataSet); > > ChartProperties chartProperties = new ChartProperties(); > chartProperties.setBackgroundPaint((Paint) Color.yellow); > chartProperties.setBorderStroke( (ChartStroke) ChartStroke.DEFAULT_AXIS ); > > AxisProperties axisProperties = new AxisProperties(); > LegendProperties legendProperties = new LegendProperties(); > > AxisChart axisChart= new AxisChart(dataSeries, chartProperties, > axisProperties, legendProperties, > width, height); > > this.exportImage( axisChart, filePath ); > > > } __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com |
From: Chris W. <cw...@go...> - 2004-12-08 16:08:02
|
What is the difference between a ScatterPlotDataSet, and a ScatterPlotDataSeries. The ScatterPlotDataSet appears to have the methods to add multiple lines to it I think. The ScatterPlotTestDriver creates one line with a ScatterPlotDataSet, then creates a ScatterPlotDataSeries with that DataSet and the labels. If I want multiple plotted lines, which class do I add the data for the line to? scatterPlotDataSet.addDataPoints( points, paint, legendLabel ); ? scatterPlotDataSeries.addIAxisPlotDataSet( iScatterPlotDataSet ); ? chris On Sunday 14 November 2004 07:41 am, Nathaniel G. Auvil wrote: > you need to use a ScatterPlotDataSet not an AxisChartDataSet |
From: Chris W. <cw...@go...> - 2004-12-08 19:28:46
|
Ok, I guess I get to answer my own question. You add data to a ScatterPlotDataSet. I finally figured out that the createScatterPlotDataSet method in the ScatterPlotTestDriver was not really set up to create multiple datasets. This change to that method will create random data for any numberOfDataSets. private ScatterPlotDataSet createScatterPlotDataSet( int numberOfDataSets, int numberOfValuesToCreate, int xMinValue, int xMaxValue, int yMinValue, int yMaxValue ) throws ChartDataException { ScatterPlotDataSet scatterPlotDataSet= new ScatterPlotDataSet( this.getScatterPlotProperties( numberOfDataSets ) ); Point2D.Double[] points; for( int i=0; i < numberOfDataSets; i++ ) { points= TestDataGenerator.getRandomPoints( numberOfValuesToCreate, xMinValue, xMaxValue, yMinValue, yMaxValue ); Paint paint = TestDataGenerator.getRandomPaint(); String[] legendLabels = TestDataGenerator.getRandomStrings( 1, 12, false ); scatterPlotDataSet.addDataPoints( points, paint, legendLabels[ 0 ] ); } return scatterPlotDataSet; } On Wednesday 08 December 2004 10:08 am, Chris Ward wrote: > What is the difference between a ScatterPlotDataSet, and a > ScatterPlotDataSeries. The ScatterPlotDataSet appears to have the methods > to add multiple lines to it I think. > > The ScatterPlotTestDriver creates one line with a ScatterPlotDataSet, then > creates a ScatterPlotDataSeries with that DataSet and the labels. If I want > multiple plotted lines, which class do I add the data for the line to? > > scatterPlotDataSet.addDataPoints( points, paint, legendLabel ); ? > scatterPlotDataSeries.addIAxisPlotDataSet( iScatterPlotDataSet ); ? > > chris |