ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Only show tooltip on data points
Posted by Gert Thomas on Sep-12-2013 10:20
Attachments:
Hi,

I have looked but have not found an answer yet, maybe you could help:

Is it possible to only display the tooltip when hovering over the actual data point and
make the tooltip not show when hovering between the data points?

For example, on the chart below (at the bottom of my post) I have hovered on the line
between the last two points and the tooltip has displayed. Is it possible to prevent this
and only display the tooltip when hovering on a data point(the diamond data symbol):

I'm using ChartDirector v5.1 on Windows 7.

Thanks.



My code:
<%@page import="ChartDirector.*, java.sql.*" %>
<%
double[] data1 = {1700, 1900, 2000};

java.util.Date javaDate = new java.util.Date();
long javaTime1 = javaDate.getTime();
long javaTime2 = javaDate.getTime()+86409000;
long javaTime3 = javaDate.getTime()+259209000;

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);

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);

LineLayer layer0 = c.addLineLayer(data1, 0xcc0000, "Name1");
layer0.setLineWidth(2);
layer0.setXData(times1);
DataSet ds = layer0.getDataSet(0);
ds.setDataSymbol(2, 10);

c.packPlotArea(90, 180, 500 - 25, 350);

String chart1URL = c.makeSession(request, "chart1");

// Include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("", "",
    "title='{x|mm-dd-yyyy hh:nn} = {value}'");  //x|mm/dd/yyyy hh:nn:ss   was xLabel

%>
<html>
<body>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
    usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
</body>
</html>
chart.png

  Re: Only show tooltip on data points
Posted by Peter Kwan on Sep-12-2013 21:51
Hi Gert,

In general, the tooltip will apply to the data representation. For example, in a bar chart, the data are represented by bars, so the tooltip will apply to bars. In a line chart, the data are represented by line segments, so the tooltip will apply to line segments.

For your case, you may use a scatter layer for your symbols. In this way, the tooltip will only apply to the symbols. You may continue to use a line layer for the line, and configure the line layer without tooltips. In this way, your chart will contain lines with data symbols, and only the data symbols have tooltips.


c.addScatterLayer(times1, data1, "Name1", 2, 10, 0xcc0000);

LineLayer layer0 = c.addLineLayer(data1, 0xcc0000, "Name1");
layer0.setLineWidth(2);
layer0.setXData(times1);
//no image map for the line layer
layer0.setHTMLImageMap("{disable}");


Hope this can help.

Regards
Peter Kwan