Hi , I faced this problem when I tried to create a Stock table with tooltip
This is the code I am using
final StockChart stockChart = new StockChart()
.setToolTip(new ToolTip()
.setFormatter(new ToolTipFormatter() {
public String format(ToolTipData toolTipData) {
String dateString=DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss")
.format(new Date(toolTipData.getXAsLong()))
+ toolTipData.getYAsDouble();
return dateString;
}
})
);
And this is the code I am using to add series to the chart.
final Series series = stockChart.createSeries();
stockChart.addSeries(series.setName("Random data"));
long time = new Date().getTime();
for(int i = -19; i <= 0; i++) {
series.addPoint(time + i * 1000, com.google.gwt.user.client.Random.nextDouble());
}
When I run it in GWT development mode, I found the tool tip is not display, and when opening the Javascript console, I found the error as below:
"Uncaught com.google.gwt.dev.shell.HostedModeException: Something other than a double was returned from JSNI method '@org.moxieapps.gwt.highcharts.client.ToolTipData::getYAsDouble()': JS value of type undefined, expected double."
Below that, there is another line which said: " event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future."
When I removed the code "NumberFormat.getFormat("0.00").format(toolTipData.getYAsDouble())", the tool tip is showing.
Does anyone know what's going on here ?
The highstock.js I am using is version 1.1.2.
The moxie highchart gwt I am using is 1.1.3
GWT SDK is 2.4.0
Last edit: XiGuan 2012-01-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It looks like stock charts have tooltips running in "shared" mode by default, so you'll need to use the ToolTipData's "getXAsLong(int index)" and "getYAsDouble(int index)" (or take the tooltip out of shared mode.) Here's a working example:
final StockChart stockChart = new StockChart()
.setToolTip(new ToolTip()
.setEnabled(true)
.setFormatter(new ToolTipFormatter() {
public String format(ToolTipData toolTipData) {
String dateString = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss")
.format(new Date(toolTipData.getXAsLong(0))) + " " +
toolTipData.getYAsDouble(0);
return dateString;
}
})
);
final Series series = stockChart.createSeries();
stockChart.addSeries(series.setName("Random data"));
long time = new Date().getTime();
for (int i = -19; i <= 0; i++) {
series.addPoint(time + i * 1000, com.google.gwt.user.client.Random.nextDouble());
}
Can you let us know if the clears up the problem you're seeing?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi , I faced this problem when I tried to create a Stock table with tooltip
This is the code I am using
And this is the code I am using to add series to the chart.
When I run it in GWT development mode, I found the tool tip is not display, and when opening the Javascript console, I found the error as below:
"Uncaught com.google.gwt.dev.shell.HostedModeException: Something other than a double was returned from JSNI method '@org.moxieapps.gwt.highcharts.client.ToolTipData::getYAsDouble()': JS value of type undefined, expected double."
Below that, there is another line which said: " event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future."
When I removed the code "NumberFormat.getFormat("0.00").format(toolTipData.getYAsDouble())", the tool tip is showing.
Does anyone know what's going on here ?
The highstock.js I am using is version 1.1.2.
The moxie highchart gwt I am using is 1.1.3
GWT SDK is 2.4.0
Last edit: XiGuan 2012-01-17
It looks like stock charts have tooltips running in "shared" mode by default, so you'll need to use the ToolTipData's "getXAsLong(int index)" and "getYAsDouble(int index)" (or take the tooltip out of shared mode.) Here's a working example:
Can you let us know if the clears up the problem you're seeing?