From: Marcin G. <da...@to...> - 2003-06-25 22:01:49
|
Hi, I use jCharts 0.7.3 I get this: 23:40:56,045 ERROR [STDERR] java.lang.NullPointerException 23:40:56,055 ERROR [STDERR] at org.jCharts.axisChart.axis.XAxis.render(XAxis.java:406) 23:40:56,055 ERROR [STDERR] at org.jCharts.axisChart.AxisChart.renderChart(AxisChart.java:442) 23:40:56,055 ERROR [STDERR] at org.jCharts.Chart.render(Chart.java:169) 23:40:56,055 ERROR [STDERR] at org.jCharts.encoders.BinaryEncoderUtil.render(BinaryEncoderUtil.java:90) 23:40:56,065 ERROR [STDERR] at org.jCharts.encoders.PNGEncoder.encode(PNGEncoder.java:91) 23:40:56,085 ERROR [STDERR] at extranet.ChartServlet.performTask(ChartServlet.java:341) The code from my ChartServlet that generates the chart is below, What I am doing wrong? regards Marcin =============== String[] xAxisLabels= { "I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII" }; out = response.getOutputStream(); java.util.ResourceBundle txts = java.util.ResourceBundle.getBundle("charts",new Locale(language)); String year = getParameter(request,"Year"); if (year == null) year="2002"; Collection v = user.getNumbersByYear(kid, new Long(year)); Iterator it = v.iterator(); double[][] data = new double[1][12]; for (int i=0; i<12; i++) { double d = ((Long)it.next()).doubleValue(); data[0][i] = d; } String xAxisTitle = fix(txts.getString("CHART1_XAXIS")); String yAxisTitle = fix(txts.getString("CHART1_YAXIS")); Object[] arg = { year }; String title = fix(MessageFormat.format(txts.getString("CHART1_TITLE"), arg)); DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title ); String[] legendLabels = { fix(txts.getString("CHART1_LEGEND")) }; Paint[] paints={ new GradientPaint(0,0,new Color(255,213,83,150),0,350,new Color(243,116,0,200)) }; BarChartProperties barChartProperties = new BarChartProperties(); ValueLabelRenderer valueLabelRenderer = new ValueLabelRenderer( false, false, false, -1 ); valueLabelRenderer.setValueLabelPosition( ValueLabelPosition.ON_TOP ); valueLabelRenderer.useVerticalLabels(false); barChartProperties.addPostRenderEventListener( valueLabelRenderer ); AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.BAR, barChartProperties); dataSeries.addIAxisPlotDataSet(axisChartDataSet); ChartProperties chartProperties = new ChartProperties(); DataAxisProperties xAxisProperties = new DataAxisProperties(); xAxisProperties.setAxisTitleChartFont(ft_axis); xAxisProperties.setScaleChartFont(ft_labels); DataAxisProperties yAxisProperties = new DataAxisProperties(); yAxisProperties.setAxisTitleChartFont(ft_axis); yAxisProperties.setScaleChartFont(ft_labels); yAxisProperties.setRoundToNearest(0); AxisProperties axisProperties = new AxisProperties(xAxisProperties, yAxisProperties); LegendProperties legendProperties = new LegendProperties(); chartProperties.setTitleFont(ft_title); legendProperties.setFont(ft_base_); axisProperties.setBackgroundPaint(new GradientPaint(0,0,new Color(255,255,255),0,300,new Color(167,213,255))); AxisChart axisChart= new AxisChart( dataSeries, chartProperties, axisProperties, null, //legendProperties, 548, 350 ); // wymiary wykresu response.setContentType("image/png"); PNGEncoder.encode(axisChart, out); |
From: Nathaniel G. A. <nat...@ya...> - 2003-06-26 02:29:45
|
The problem you are having is that you are passing a DataAxisProperties Object for the y-axis properties when this should be a LabelAxisProperties Object. try this for your xAxisProperties: LabelAxisProperties xAxisProperties = new LabelAxisProperties(); --- Marcin Gryszkalis <da...@to...> wrote: > Hi, I use jCharts 0.7.3 > > I get this: > 23:40:56,045 ERROR [STDERR] java.lang.NullPointerException > 23:40:56,055 ERROR [STDERR] at org.jCharts.axisChart.axis.XAxis.render(XAxis.java:406) > 23:40:56,055 ERROR [STDERR] at > org.jCharts.axisChart.AxisChart.renderChart(AxisChart.java:442) > 23:40:56,055 ERROR [STDERR] at org.jCharts.Chart.render(Chart.java:169) > 23:40:56,055 ERROR [STDERR] at > org.jCharts.encoders.BinaryEncoderUtil.render(BinaryEncoderUtil.java:90) > 23:40:56,065 ERROR [STDERR] at org.jCharts.encoders.PNGEncoder.encode(PNGEncoder.java:91) > 23:40:56,085 ERROR [STDERR] at extranet.ChartServlet.performTask(ChartServlet.java:341) > > The code from my ChartServlet that generates the chart is below, > What I am doing wrong? > regards > Marcin > > =============== > String[] xAxisLabels= { "I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII" }; > out = response.getOutputStream(); > > java.util.ResourceBundle txts = java.util.ResourceBundle.getBundle("charts",new > Locale(language)); > > String year = getParameter(request,"Year"); > if (year == null) year="2002"; > > Collection v = user.getNumbersByYear(kid, new Long(year)); > Iterator it = v.iterator(); > > double[][] data = new double[1][12]; > for (int i=0; i<12; i++) > { > double d = ((Long)it.next()).doubleValue(); > data[0][i] = d; > } > String xAxisTitle = fix(txts.getString("CHART1_XAXIS")); > String yAxisTitle = fix(txts.getString("CHART1_YAXIS")); > > Object[] arg = { year }; > String title = fix(MessageFormat.format(txts.getString("CHART1_TITLE"), arg)); > > DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title ); > > String[] legendLabels = { fix(txts.getString("CHART1_LEGEND")) }; > > Paint[] paints={ new GradientPaint(0,0,new Color(255,213,83,150),0,350,new Color(243,116,0,200)) > }; > BarChartProperties barChartProperties = new BarChartProperties(); > > ValueLabelRenderer valueLabelRenderer = new ValueLabelRenderer( false, false, false, -1 ); > valueLabelRenderer.setValueLabelPosition( ValueLabelPosition.ON_TOP ); > valueLabelRenderer.useVerticalLabels(false); > barChartProperties.addPostRenderEventListener( valueLabelRenderer ); > > AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, > ChartType.BAR, barChartProperties); > dataSeries.addIAxisPlotDataSet(axisChartDataSet); > ChartProperties chartProperties = new ChartProperties(); > > DataAxisProperties xAxisProperties = new DataAxisProperties(); > xAxisProperties.setAxisTitleChartFont(ft_axis); > xAxisProperties.setScaleChartFont(ft_labels); > > DataAxisProperties yAxisProperties = new DataAxisProperties(); > yAxisProperties.setAxisTitleChartFont(ft_axis); > yAxisProperties.setScaleChartFont(ft_labels); > yAxisProperties.setRoundToNearest(0); > > AxisProperties axisProperties = new AxisProperties(xAxisProperties, yAxisProperties); > LegendProperties legendProperties = new LegendProperties(); > > chartProperties.setTitleFont(ft_title); > legendProperties.setFont(ft_base_); > > axisProperties.setBackgroundPaint(new GradientPaint(0,0,new Color(255,255,255),0,300,new > Color(167,213,255))); > AxisChart axisChart= new AxisChart( > dataSeries, > chartProperties, > axisProperties, > null, //legendProperties, > 548, 350 ); // wymiary wykresu > > response.setContentType("image/png"); > PNGEncoder.encode(axisChart, out); > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > jCharts-users mailing list > jCh...@li... > https://lists.sourceforge.net/lists/listinfo/jcharts-users ===== http://nathaniel-auvil.blog-city.com/ __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com |
From: Marcin G. <da...@to...> - 2003-06-26 05:45:07
|
On 2003-06-26 04:28, Nathaniel G. Auvil wrote: > The problem you are having is that you are passing a DataAxisProperties Object for the y-axis > properties when this should be a LabelAxisProperties Object. > > try this for your xAxisProperties: > > LabelAxisProperties xAxisProperties = new LabelAxisProperties(); but, DataAxisProperies directly extends LabelAxisProperties... Anyway, the code is: DataAxisProperties yAxisProperties = new DataAxisProperties(); yAxisProperties.setAxisTitleChartFont(ft_axis); yAxisProperties.setScaleChartFont(ft_labels); yAxisProperties.setRoundToNearest(0); AxisProperties axisProperties = new AxisProperties(xAxisProperties, yAxisProperties); if I change it do LabelAxisProperties, how can I access 'round-to-nearest' property (which is defined in DataAxisProperties)? regards Marcin |
From: Nathaniel G. A. <nat...@ya...> - 2003-06-26 11:45:24
|
--- Marcin Gryszkalis <da...@to...> wrote: > On 2003-06-26 04:28, Nathaniel G. Auvil wrote: > > > The problem you are having is that you are passing a DataAxisProperties Object for the y-axis > > properties when this should be a LabelAxisProperties Object. > > > > try this for your xAxisProperties: > > > > LabelAxisProperties xAxisProperties = new LabelAxisProperties(); > > but, DataAxisProperies directly extends LabelAxisProperties... Yeah, but the logic uses the type of AxisProperties in determining how to draw the Axis. > if I change it do LabelAxisProperties, how can I > access 'round-to-nearest' property (which is defined in DataAxisProperties)? Your data is plotted against the y-axis so you would place your rounding code there. The labels are on the x-axis so rounding does not apply there. ===== http://nathaniel-auvil.blog-city.com/ __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com |
From: Marcin G. <da...@to...> - 2003-06-26 14:31:45
|
Ok, now I understand You wrote: >>>The problem you are having is that you are >>>passing a DataAxisProperties Object for the y-axis ^^^^^^ That's why I didn't understand, should be x-axis, right? regards Marcin |