ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  ChartViewer.setChart() of Bar Chart throws java.lang.NullPointerException
Posted by hiro on Aug-08-2015 09:28
Hi Peter,

I'm getting the following exception in ChartViewer.setChart(c) of BarChart...
Do you have any solution? 

---------------------------------
java.lang.NullPointerException
at ChartDirector.DrawArea.h(SourceFile:4448)
at ChartDirector.DrawArea.a(SourceFile:2182)
at ChartDirector.bs.drawOn(SourceFile:3763)
at ChartDirector.TTFBlocks.drawBlocks(SourceFile:860)
at ChartDirector.TTFBlocks.drawOn(SourceFile:822)
at ChartDirector.TTFBlocks.draw(SourceFile:796)
at ChartDirector.ej.a(SourceFile:407)
at ChartDirector.TextBox.a(SourceFile:39)
at ChartDirector.iv.a(SourceFile:2452)
at ChartDirector.iv.a(SourceFile:3244)
at ChartDirector.Axis.w(SourceFile:5485)
at ChartDirector.PlotArea.e(SourceFile:553)
at ChartDirector.XYChart.b(SourceFile:902)
at ChartDirector.BaseChart.a(SourceFile:1071)
at ChartDirector.BaseChart.makeChart(SourceFile:865)
at ChartDirector.BaseChart.makeChart3(SourceFile:870)
at ChartDirector.ChartViewer.b(SourceFile:718)
at ChartDirector.ChartViewer.setChart(SourceFile:706)
at MyClass.drawChart(MyClass.java:335)
at MyClass.chartViewer_viewPortChanged(MyClass.java:297)
at MyClass.access$0(MyClass.java:295)
at MyClass$3.viewPortChanged(MyClass.java:238)
at ChartDirector.ChartViewer.a(SourceFile:1708)
at ChartDirector.ChartViewer.updateViewPort(SourceFile:1656)
at MyClass.chartUpdate(MyClass.java:303)
---------------------------------


And below is the source of drawChart of MyClass...


---------------------------------
private void drawChart(ChartViewer viewer) {

xyChart = new XYChart(560, 65);
xyChart.recycle(viewer.getChart());
xyChart.setBackground(Chart.Transparent, Chart.Transparent);
xyChart.setBorder(Chart.Transparent);
xyChart.setPlotArea(5, 0, xyChart.getWidth() - 40, xyChart.getHeight() - 20);
xyChart.swapXY();

if (refVolume < totalVolume) {
data_trade_ref[0] = refVolume;
BoxWhiskerLayer markLayer = xyChart.addBoxWhiskerLayer(null, null, null,
null, data_trade_ref, -1, 0xff0000);
markLayer.setDataGap(0.1);
}

data_trade_sum[0] = totalVolume;
barLayer = xyChart.addBarLayer(data_trade_sum, 0x0045b9);
barLayer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top));
long maxValue = refVolume > totalVolume ? refVolume : (long)(totalVolume *
1.2);

xyChart.yAxis().setLinearScale(0, maxValue);
xyChart.yAxis().setTickDensity(100);
xyChart.xAxis().setColors(Chart.Transparent);
xyChart.yAxis().setColors(Chart.Transparent, 0xcccccc);
xyChart.yAxis().setLabelFormat("{value|,}");

viewer.setChart(xyChart);
}
---------------------------------

Thanks for any help.

  Re: ChartViewer.setChart() of Bar Chart throws java.lang.NullPointerException
Posted by Peter Kwan on Aug-11-2015 00:07
Hi hiro,

This might be caused by a known bug in ChartDirector, which is related to drawing text on a
transparent background. If this is the cause of the issue, using ChartDirector 6.0 should
solve the issue. Please try to use the JAR file "ChartDirector.jar" from the latest version of
ChartDirector to see if it can solve the problem.

Regards
Peter Kwan

  Re: ChartViewer.setChart() of Bar Chart throws java.lang.NullPointerException
Posted by hiro on Aug-11-2015 15:50
Hi Peter,


Thank you for your reply.

I think this problem is due to the specific hardware and middleware.
This is because the majority of our customers and our test environment this problem does
not occur, it is because occurred in only a small number of customer environments.

However, we think let's try to use the latest version of the library.


Regards,
hiro

  Re: ChartViewer.setChart() of Bar Chart throws java.lang.NullPointerException
Posted by hiro on Mar-07-2016 11:21
Note: I was able to solve this problem in ChartDirector 6.0.