Re: Is it possible to display y point values in a line chart?

David Han <[email protected]> Fri, 12 Mar 2004 08:38:04 -0500
Newsgroups gmane.comp.krysalis.jcharts.user
Message-ID <a05210649bc776b4386e7@[128.183.190.142]>
I didn't even know that ScatterPlot exists since it wasn't included 
in the documentation.  Isn't a scatter plot supposed to show 
correlation between two variables?  Anyway, I tried the ScatterPlot 
to see whether it can show X-axis labels as well as y point values. 
My code below draws a chart (including x-axis and y-axis labels, 
title, and legends) but without data points.  Am I missing something?

       String[] xAxisLabels = { "1998", "1999", "2000", "2001",
                                "2002", "2003", "2004" };
       String xAxisTitle = "Years";
       String yAxisTitle = "Problems";
       String title = "Micro$haft 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.blue};

       Stroke[] strokes = { ScatterPlotProperties.DEFAULT_LINE_STROKE };
       Shape[]  shapes = { PointChartProperties.SHAPE_CIRCLE };
       ScatterPlotProperties properties =
             new ScatterPlotProperties(strokes, shapes);

       AxisChartDataSet axisChartDataSet =
              new AxisChartDataSet(data, legendLabels, paints,
                                   ChartType.SCATTER_PLOT, properties );
       dataSeries.addIAxisPlotDataSet (axisChartDataSet);

       ChartProperties chartProperties   = new ChartProperties();
       AxisProperties axisProperties     = new AxisProperties();
       LegendProperties legendProperties = new LegendProperties();

       AxisChart axisChart= new AxisChart(dataSeries, chartProperties,
                                          axisProperties, legendProperties,
                                          width-50, height-50);
       axisChart.setGraphics2D ( (Graphics2D) panel.getGraphics() );
       axisChart.render();


>Did you try the ScatterPlot?
>
>
>
>--- David Han <[email protected]> wrote:
>>  Is it possible to display y point values in a line chart?  Looks like
>  > there aren't any APIs for this.  Is this a correct observation?
>

-- 


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click