|
Displayed data is not right |
Posted by Tom on Jan-31-2013 11:25 |
|
import java.util.Calendar;
import java.util.Date;
import ChartDirector.Chart;
import ChartDirector.ColorAxis;
import ChartDirector.SurfaceChart;
public class Demo{
double[][] dataX = new double[365][24];
Date[] dataY = new Date[365];
double[] dataZ = new double[365 * 24];
static SurfaceChart c = null;
public static void main(String[] args)
{
Demo d = new Demo();
d.createChartX();
}
public void createChartX() {
String[] lableX = new String[24];
for(int i = 0; i < 24; i ++)
{
lableX[i] = String.valueOf(i+1);
}
Calendar day = Calendar.getInstance();
for(int i=0; i < 365; i++)
{
day.add(Calendar.DATE, 1);
dataY[i] = day.getTime();
}
for (int i = 0; i < 365; ++i)
for (int j = 0; j < 24; ++j)
dataZ[i * 24 + j] = 0.0f;
for(int i=5; i < 8; i++)
{
for(int j= 80; j<100;j++ )
{
dataZ[j*24+i] = 3.9f;
}
}
c = new SurfaceChart(800, 600);
c.setData(null, Chart.CTime(dataY), dataZ);
c.setPlotRegion(385, 300, 480, 240, 240);
c.setViewAngle(45, -45);
c.xAxis().setLabels(lableX);
c.xAxis().setTickDensity(75);
c.setInterpolation(80, 40);
c.setSurfaceAxisGrid(0xcc000000);
c.setContourColor(Chart.SameAsMainColor);
ColorAxis cAxis = c.setColorAxis(780, 250, Chart.Right, 180, Chart.Left);
cAxis.setBoundingBox(0xeeeeee, 0x888888);
c.xAxis().setLabelStyle("MingLiU Bold");
c.yAxis().setLabelStyle("MingLiU Bold");
c.zAxis().setLabelStyle("MingLiU Bold");
c.colorAxis().setLabelStyle("MingLiU Bold");
c.yAxis().setDateScale(dataY[0], dataY[dataY.length-1], 30 * 86400);
c.yAxis().setLabelFormat("{value|m}");
c.xAxis().setTitle("time", "MingLiU", 15, 0x000088);
c.yAxis().setTitle("month", "MingLiU", 15, 0x000088);
c.zAxis().setTitle("temp", "MingLiU", 15, 0x000088);
c.zAxis().setLinearScale(-5, 5);
c.makeChart("demo.png");
}
}
|
Re: Displayed data is not right |
Posted by Peter Kwan on Jan-31-2013 21:28 |
|
Hi Tom,
I confirm the chart displayed is correct.
In brief, to plot a continously chart (like a line chart in 2D or a surface chart in 3D), ChartDirector must join the points. If the joining is "smooth", then the curve or surface may overshoot or undershoot. For example, in the spline curve in the attached image, you can see the peak of the curve is higher than the maximum data values, which is normal. If the joining is linear, there will be no overshoot or undershoot.
On the surface chart, the SurfaceChart.setInterpolation method can be used to configure the interpolation method. Using the following code will result in linear interpolation, with no overshoot or undershoot.
c.setInterpolation(80, 40, false);
Hope this can help.
Regards
Peter Kwan
|
|