Hi,
I have a scatter chart with double values on the Y axis and time in the format of HH:mm
in the X axis. It seems that the values are not exactly positioned, for example in the
attached image the 10:58 and 10:59 values should be nearer the 11:00 line.
I am passing the time values as doubles and I am thinking if this may be the issue
part of the code I am using is this:
double[] dataY0 = Morning.ToArray();
double[] dataY1 = Afternoon.ToArray();
double[] dataY2 = Evening.ToArray();
double[] dataY3 = Night.ToArray();
String[] labels = {"00","01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11",
"12", "13", "14", "15", "16", "17","18", "19", "20", "21", "22", "23","00"};
// Create a XYChart object of size 800 x 360 pixels. Use a vertical gradient
XYChart c = new XYChart(800, 360);
// color from sky blue (aaccff) to white (ffffff) as background. Set border to
// grey (888888). Use rounded corners. Enable soft drop shadow.
c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0xaaccff, 0xffffff
), 0x888888);
c.setRoundedFrame();
c.setDropShadow();
// Set the plotarea at (100, 80) and of size 600 x 230 pixels, with white
// (ffffff) background. Use grey #(aaaaa) dotted lines for both horizontal and
// vertical grid lines.
c.setPlotArea(100, 80, 600, 230, 0xffffff, -1, -1, c.dashLineColor(0xaaaaaa,
Chart.DotLine), -1);
// Add a legend box with the bottom center anchored at (300, 80) (top center of
// the plot area). Use horizontal layout, and 8 points Arial Bold font. Set
// background and border to transparent.
LegendBox legendBox = c.addLegend(400, 50, false, "Arial Bold", 12);
legendBox.setAlignment(Chart.TopCenter);
legendBox.setBackground(Chart.Transparent, Chart.Transparent);
//Add a title to the chart using 14 points Times Bold Itatic font
c.addTitle(ChartHeader, "Arial Bold", 14);
//'Reserve 10% margin at the top of the plot area just to make sure the line does
//'not go too near the top of the plot area
c.yAxis().setAutoScale(0);
//Add a title to the y axis. Draw the title upright (font angle = 0)
c.yAxis().setTitle("Values (mmol/L)", "Arial Bold", 12).setFontAngle(90);
c.xAxis().setTitle("Hour of measurement", "Arial Bold", 12);
//c.xAxis().setLabels2(labels, "{value|0:00.0}");
c.xAxis().setLabels(labels);
// c.xAxis().setLabelFormat("{value|hh}");
//Set the axes line width to 3 pixels
c.xAxis().setWidth(3);
c.yAxis().setWidth(3);
//Add an orange (0xff9933) scatter chart layer, using 13 pixel diamonds as //symbols
for morning
c.addScatterLayer(dataX0, dataY0, "Morning", Chart.DiamondSymbol, 9, 0xff9933);
//Add a green (0x33ff33) scatter chart layer, using 11 pixel triangles as symbols for
aftermoom
c.addScatterLayer(dataX1, dataY1, "Afternoon", Chart.SquareSymbol, 9, 0x33ff33);
//Add a blue (0X7AA4D5) scatter chart layer, using 11 pixel triangles as symbols for
evening
c.addScatterLayer(dataX2, dataY2, "Evening", Chart.TriangleSymbol, 9, 0X7AA4D5);
//Add a black (0X000000) scatter chart layer, using 11 pixel triangles as symbols for
night
c.addScatterLayer(dataX3, dataY3, "Night", Chart.InvertedTriangleSymbol, 9,
0XFFFF00);
any ideas on how I could get a better positioning of the values?
|