I try to put text on my chart. I follow example in documentation:
String text = "mytext";
IGraphics3D g = chart.getGraphics3D();
g.textOut(0, 0, text);
CRASH!!!!
Exception in thread "main" java.lang.NullPointerException
at com.steema.teechart.drawing.Graphics3DAWT.drawString(Graphics3DAWT.java:706)
at com.steema.teechart.drawing.Graphics3D.textOut(Graphics3D.java:1936)
at com.steema.teechart.drawing.Graphics3DAWT.textOut(Graphics3DAWT.java:726)
at ................ <my code reference here>
Custom drawing on canvas fails
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Happy,
This works fine for me here using this code:
Can you please try if it works fine at yoru end?
Thanks in advance.
This works fine for me here using this code:
Code: Select all
com.steema.teechart.styles.Shape shape1 = new com.steema.teechart.styles.Shape(tChart.getChart());
shape1.setX0(0);
shape1.setY0(0);
shape1.setX1(100);
shape1.setY1(100);
shape1.getMarks().setVisible(true);
shape1.setStyle(ShapeStyle.DIAMOND);
shape1.setText(new String[] {"This is my shape"});
shape1.getFont().setSize(20);
shape1.getGradient().setVisible(true);
shape1.getGradient().setStartColor(Color.RED);
shape1.getGradient().setEndColor(Color.RED);
shape1.getGradient().setTransparency(50);
tChart.addChartPaintListener( new ChartPaintAdapter() {
public void chartPainted(ChartDrawEvent pce) {
IGraphics3D g = tChart.getGraphics3D();
g.textOut(tChart.getAxes().getBottom().iStartPos + 5,
tChart.getSeries(0).getVertAxis().iStartPos + 5,
"My custom text");
};
});
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
ok, I added your code and it works, but I still have an issue with adding in the even listener because the method in which I create the chart is static, and so the listener doesn't have access to the chart object.
For testing purposes I made the chart object a static member of the class, but this is not an ideal thing to do when it comes to servlet programming because that object will be shared amongst all the web-server's threads.
and I don't want to synchronize the variable because our web server serves about 50 requests per second.
For testing purposes I made the chart object a static member of the class, but this is not an ideal thing to do when it comes to servlet programming because that object will be shared amongst all the web-server's threads.
and I don't want to synchronize the variable because our web server serves about 50 requests per second.