工具提示无法在图表中工作

时间:2014-04-07 22:01:41

标签: javascript dojo dojox.charting

require([
    "dojox/charting/Chart",
    "dojox/charting/action2d/Tooltip", 
    "dojox/charting/themes/Tom",
    "dojox/charting/plot2d/Lines",
    "dojox/charting/plot2d/Markers",
    "dojox/charting/axis2d/Default",
    "dojo/domReady!"], function (Chart, Tooltip, theme, LinesPlot) {
    var chartData = [4.92, 4.98, 4.89];
    var chart = new Chart("chartNode");
    var tip = new Tooltip(chart, "default");

    chart.setTheme(theme);

    chart.addPlot("default", {
        type: LinesPlot,
        markers: true
    });

    chart.addAxis("x");
    chart.addAxis("y", {
        min: 4.90,
        max: 5.0000,
        vertical: true
    });

    chart.addSeries("Monthly Sales", chartData);

    chart.render();
});

demo

除了激活工具提示选项外,此图表工作正常。但是我找不到原因。有什么问题?

1 个答案:

答案 0 :(得分:0)

在添加“默认”图之前,您正在设置工具提示。如果在添加“默认”图之后移动工具提示声明,那么它应该可以正常工作。以下是重新排列工具提示的示例。

chart.addPlot("default", {
    type: LinesPlot,
    markers: true
});
var tip = new Tooltip(chart, "default");

http://jsfiddle.net/jxJZ6/2/