Re: How to render Axis Charts

David Han <[email protected]>
Newsgroups gmane.comp.krysalis.jcharts.user
Message-ID <a05210638bc7380697999@[128.183.190.142]>
>did you look at the SwingDemo in the demo package?


Yes, I did look prior to posting my message.  I don't any difference 
between my code and the SwingDemo.java code.  What is my code missing?

    private void initComponents() throws ChartDataException, PropertyException
    {
       this.setSize( width, height );
       this.panel = new JPanel( true );
       this.panel.setSize( width, height );
       this.getContentPane().add( this.panel );
       this.setVisible( true );

       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 = { 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,
                                          450, 450);
       axisChart.setGraphics2D ( (Graphics2D) this.panel.getGraphics() );
       axisChart.render();
}


-- 
David Han
[email protected]
301-286-3617


-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.