|
Tooltip not showing the xLabel |
Posted by Gert Thomas on Jul-02-2013 08:45 |
|
Hi,
I've got a chart with multiple axis, each data set has different dates and I'm trying to show it all in one chart.
Seems to be working except that when I hover over a line it doesn't show the xLabel in the tooltip. It is showing the dataSetName and value but just not the xLabel.
I've replicated the problem in the full code below, any help would be appreciated:
I'm using ChartDirector v5.1 on Windows 7.
Thanks.
<%@page import="ChartDirector.*, java.sql.*" %>
<%
double[] data1 = {1700, 1900, 2000};
double[] data2 = {500, 900, 1000};
double[] data3 = {400, 1000, 800};
double[] data4 = {1500, 2000, 2200};
java.util.Date javaDate = new java.util.Date();
long javaTime1 = javaDate.getTime();
long javaTime2 = javaDate.getTime()+86400000;
long javaTime3 = javaDate.getTime()+259200000;
long javaTime4 = javaDate.getTime()+345600000;
long javaTime5 = javaDate.getTime()+432000000;
long javaTime6 = javaDate.getTime()+518400000;
long javaTime7 = javaDate.getTime()+604800000;
long javaTime8 = javaDate.getTime()+691200000;
long javaTime9 = javaDate.getTime()+777600000;
long javaTime10 = javaDate.getTime()+864000000;
long javaTime11 = javaDate.getTime()+950400000;
long javaTime12 = javaDate.getTime()+1036800000;
java.sql.Timestamp[] times1 = new java.sql.Timestamp[3];
times1[0] = new java.sql.Timestamp(javaTime1);
times1[1] = new java.sql.Timestamp(javaTime2);
times1[2] = new java.sql.Timestamp(javaTime3);
java.sql.Timestamp[] times2 = new java.sql.Timestamp[3];
times2[0] = new java.sql.Timestamp(javaTime4);
times2[1] = new java.sql.Timestamp(javaTime5);
times2[2] = new java.sql.Timestamp(javaTime6);
java.sql.Timestamp[] times3 = new java.sql.Timestamp[3];
times3[0] = new java.sql.Timestamp(javaTime7);
times3[1] = new java.sql.Timestamp(javaTime8);
times3[2] = new java.sql.Timestamp(javaTime9);
java.sql.Timestamp[] times4 = new java.sql.Timestamp[3];
times4[0] = new java.sql.Timestamp(javaTime10);
times4[1] = new java.sql.Timestamp(javaTime11);
times4[2] = new java.sql.Timestamp(javaTime12);
XYChart c = new XYChart(800, 460);
c.setPlotArea(100, 80, 400, 230, 0xffffff, -1, -1, c.dashLineColor(0xaaaaaa,
Chart.DotLine), -1);
c.xAxis().setTitle("Date");
c.yAxis().setTitle("A").setAlignment(Chart.TopLeft2);
c.yAxis().setColors(0xcc0000, 0xcc0000, 0xcc0000);
c.yAxis2().setTitle("B").setAlignment(Chart.TopRight2);
c.yAxis2().setColors(0x008000, 0x008000, 0x008000);
Axis leftAxis = c.addAxis(Chart.Left, 50);
leftAxis.setTitle("C").setAlignment(Chart.TopLeft2);
leftAxis.setColors(0x0000cc, 0x0000cc, 0x0000cc);
Axis rightAxis = c.addAxis(Chart.Right, 50);
rightAxis.setTitle("D").setAlignment(Chart.TopRight2);
rightAxis.setColors(0x880088, 0x880088, 0x880088);
LineLayer layer0 = c.addLineLayer(data1, 0xcc0000, "Name1");
layer0.setLineWidth(2);
layer0.setXData(times1);
LineLayer layer1 = c.addLineLayer(data2, 0x008000, "Name2");
layer1.setLineWidth(2);
layer1.setUseYAxis2();
layer1.setXData(times2);
LineLayer layer2 = c.addLineLayer(data3, 0x0000cc, "Name3");
layer2.setLineWidth(2);
layer2.setUseYAxis(leftAxis);
layer2.setXData(times3);
LineLayer layer3 = c.addLineLayer(data4, 0x880088, "Name4");
layer3.setLineWidth(2);
layer3.setUseYAxis(rightAxis);
layer3.setXData(times4);
c.packPlotArea(90, 180, 500 - 25, 350);
String chart1URL = c.makeSession(request, "chart1");
String imageMap1 = c.getHTMLImageMap("", "",
"title='{dataSetName} on {xLabel} = {value}'");
%>
<html>
<body>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
</body>
</html> |
Re: Tooltip not showing the xLabel |
Posted by Peter Kwan on Jul-03-2013 00:18 |
|
Hi Gert,
In ChartDirector, the {xLabel} refers to the label on the x-axis. It is not the same as the x-coordinate of the data {x}. For example, in an application that plots temperature, people may use 10, 20, 30 as the coordinates, but display "Cold", "Warm", "Hot" on the axis as labels.
For your case, it is likely your x-coordinates are in positions that do not have x-axis labels, so the {xLabel} is empty. I think your intention is to actually display the x-coordinates, like {x|mm/dd/yyyy hh:nn:ss}.
Hope this can help.
Regards
Peter Kwan |
Re: Tooltip not showing the xLabel |
Posted by Gert Thomas on Jul-03-2013 09:22 |
|
Thanks Peter, that has cleared that up for me. |
|