|
Problem with java surface chart |
Posted by Dilip on Dec-06-2012 01:28 |
|
Hi There,
I'm using java Surface Chart Axis Types graph
I found one issue with it, please find the attachment that has the description of the issue.
Could you please help me with this?
Thanks very much
|
Re: Problem with java surface chart |
Posted by Peter Kwan on Dec-06-2012 17:43 |
|
Hi Dilip,
Currently, ChartDirector surface chart can only plot surfaces of the form z = f(x, y), that is, the z must be a function of x and y. In other words, given (x, y), you must be able to determine a unique z value on the surface. (If you imagine the xy plane as the horizontal table, and if you look at the surface from the top down, the surface must not self overlap.)
So some surfaces are not supported by ChartDirector. For example, any self-overlapping or intersecting surfaces are not supported. ChartDirector cannot plot a complete sphere. (If you look at the sphere from the top, the top half of the sphere will block or overlap with the bottom half of the sphere.) However, ChartDirector can plot a half-sphere. In particular, ChartDirector cannot plot an absolutely vertical surface.
For your case, your data are in fact represents an absolutely vertical surface (that is, given x and y, it is not possible to obtain a unique z value from the surface). However, if you introduce an infinitesimal change to the dateData so that it is no longer absolutely vertical, the chart will be plotted.
May be you can try something like the followings, which applies an infinitesimal change to the dateData if it is a constant value. It also solves the date format issue mentioned in your Word document.
double[] myData = Chart.CTime(dateData);
if (new ArrayMath(myData).max() == new ArrayMath(myData).min()) {
for (int i = 0; i < myData.length; ++i)
myData[i] += myData[i] / 1E13 * i;
c.yAxis().setDateScale(myData[0] - 10, myData[0] + 10, 5);
}
c.yAxis().setDateScale("{value|dd/mm/yy hh:nn:ss}");
c.setData(dataX, myData, dataY);
Hope this can help.
Regards
Peter Kwan |
Re: Problem with java surface chart |
Posted by Dilip on Dec-10-2012 23:26 |
|
Thanks very much for your help |
Re: Problem with java surface chart |
Posted by Dilip on Dec-14-2012 19:05 |
|
Hi
Found one more problem with surface chart
its working but sometimes its throwing java.lang.NegativeArraySizeException exception
This is my code in the java file which set up surface chart
public static SurfaceChart createSurfaceChart(
List<DataItem> dataItems)
{
SurfaceChart surfaceChart= new SurfaceChart(1000, 550);
Date[] dateData = new Date[dataItems.size()];
double[] xData = new double[dataItems.size()];
double[] yData = new double[dataItems.size()];
for (int i = 0; i < dataItems.size(); i++)
{
DataItem currentItem = dataItems.get(i);
dateData[i] = currentItem.getDate();
xData[i] = currentItem.getXValue();
yData[i] = currentItem.getYValue();
}
double[] myData = Chart.CTime(dateData);
surfaceChart.yAxis().setDateScale("{value|dd/mm/yy hh:nn:ss}");
surfaceChart.setPlotRegion(450, 200, 550, 240, 240);
// set the data to surface chart
surfaceChart.setData(xData, myData, yData);
*
* rest of the chart configuration code
*
*
}
Error stack trace....
root cause
java.lang.NegativeArraySizeException
ChartDirector.SurfaceChart.b(SourceFile:2172)
ChartDirector.SurfaceChart.e(SourceFile:672)
ChartDirector.BaseChart.layout(SourceFile:792)
ChartDirector.BaseChart.a(SourceFile:1030)
ChartDirector.BaseChart.makeChart(SourceFile:819)
ChartDirector.BaseChart.makeChart2(SourceFile:840)
ChartDirector.BaseChart.makeSession(SourceFile:854)
org.apache.jsp.Web.Test.Test3DChart_jsp._jspService(Test3DChart_jsp.java:159)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.c3.amulet.NGT.filter.NoCacheFilter.doFilter(NoCacheFilter.java:90)
Could you please tell me how to fix it?
Thanks very much |
Re: Problem with java surface chart |
Posted by Peter Kwan on Dec-15-2012 04:22 |
|
Hi Dilip,
From the stack trace, it seems you are using ChartDirector 5.0.x. In that version, we are aware of two SurfaceChart bugs that can crash ChartDirector.
(a) Using scatter data with more than 46341 points.
(b) The data has more than 2 points, but less than 2 distinct points (that is, some points are duplicates or NoValue, to the extent that there is only 1 or 0 distinct point).
The above issues should have already been fixed in ChartDirector 5.1.
In your case, the issue could be (a). Please download the latest ChartDirector, and use the updated "ChartDirector.jar" to replace your existing "ChartDirector.jar" to see if this can solve the problem. (Upgrading from ChartDirector 5.0.x to 5.1.x is free of charge.)
Regards
Peter Kwan |
Re: Problem with java surface chart |
Posted by dilip on Dec-15-2012 08:30 |
|
Hi Peter,
I have upgraded to the latest Chartdirector.jar and its now working perfectly
Thanks a lot for help.
Dilip |
|