|
From: Stephen Q. <st...@ni...> - 2005-04-03 16:22:23
|
Hi,
I'm new to JCharts. I have modified the ComboChart example to display
two datasets. After defining the two datasets, I use addIAxisPlotDataSet()
to add each dataset to a dataSeries. However, for some reason, only the
last dataset added is visible in the graph. I have tried this with some of
the other examples (e.g., the ScatterPlotDataSeries/DataSet) and it seems
to only render one dataset (typically, the last dataset added to the chart).
I cannot seem to find a working example of two separate datasets in
JCharts 0.7.5. Perhaps I am adding datasets incorrectly? (by the way,
I am using JDK 1.4.2 on 64-bit Fedora/Linux and Jakarta Tomcat 5.0.29).
Here is my small modification to the ComboChartServlet example:
try
{
String[] xAxisLabels = {"1995", "1996", "1997", "1998", "1999", "2000",
"2001", "2002", "2003", "2004"};
String xAxisTitle = "Years";
String yAxisTitle = "Problems";
String title = "Micro$oft At Work";
IAxisDataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle,
yAxisTitle, title );
double[][] data = new double[][]{{1500, 6880, 4510, 2600, 1200, 1580,
8000, 4555, 4000, 6120}};
double[][] data2 = new double[][]{{1000, 2000, 3000, 4000, 5000, 6000,
6100, 6500, 7000, 8000}};
String[] legendLabels = {"Bugs"};
Paint[] linePaints = new Paint[]{Color.red};
Paint[] linePaints2 = new Paint[]{Color.blue};
dataSeries.addIAxisPlotDataSet( new AxisChartDataSet( data,
legendLabels, linePaints, ChartType.LINE, this.lineChartProperties ) );
dataSeries.addIAxisPlotDataSet( new AxisChartDataSet( data2,
legendLabels, linePaints2, ChartType.LINE, this.lineChartProperties ) );
AxisChart axisChart = new AxisChart( dataSeries, this.chartProperties,
this.axisProperties, this.legendProperties, this.width, this.height );
ServletEncoderHelper.encodeJPEG13( axisChart, 1.0f, response );
}
catch ()...
Here, only data2 (in blue) is rendered. How do I get both datasets to be
rendered on the chart?
Thanks,
Steve
--
Stephen Quirolgico, Ph.D.
National Institute of Standards and Technology
100 Bureau Dr., Stop 8920
Gaithersburg, MD 20899-8920 USA
Tel: (301) 975-8426
Fax: (301) 590-0932
WWW: http://www.antd.nist.gov/~steveq
|