dojo工具提示不可见

时间:2014-05-09 20:01:47

标签: dojo dojox.charting

图表工具提示不适合我。似乎鼠标悬停甚至没有触发显示工具提示的功能。

我在Tooltip的文本功能中添加了一条警告消息,但当我将鼠标悬停在标记上时没有警告消息。

此代码有什么问题?

Codepen链接:http://codepen.io/pradeepsixer/pen/Ldrha

<html>
    <head>
        <script src="dojo/dojo.js"></script>
    </head>
  <body>
    <div id="chartArea">
    </div>
    <div id="legendArea">
    </div>
    <script type="text/javascript">
    require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/StackedAreas", "dojox/charting/themes/Dollar", "dojox/charting/action2d/Tooltip", "dojox/charting/widget/Legend", "dojo/ready"],
              function(Chart, Default, StackedAreas, Dollar, Tooltip, Legend, ready){
                ready(function(){
                  var mychart = new Chart("chartArea");
                  mychart.addPlot("default", { markers: true, marker: "m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0" })
                  mychart.addPlot("redline", { fill:'#000', stroke: {color:'#f00', width: 2}, markers: true })
                  .addAxis("x", {fixLower: "major", fixUpper: "major", labels:[{value:14,text:'Great'},{value:16,text:'Bread'},{value:18, text:'Soft'},{value:20,text:'Great Bread'}], length:2, natural:true, minorTicks: false, microTicks: false, majorTickStep: 2, majorLabels: true, microLabels: true})
                    .addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0, max: 20})
                    .setTheme(Dollar)
                  .addSeries("Series A", [{x:14,y:1},{x:16,y:5},{x:20,y:18}], {plot: 'redline'})
                  .addSeries("Series B", [{x:14,y:5},{x:16,y:14},{x:20,y:4}])
                  .addSeries("Series C", [{x:14,y:8},{x:16,y:7},{x:20,y:15}])
                    .render();
//                  console.debug(dc.action2d.Tooltip);
                console.debug(dojox.charting.action2d.Tooltip);
                  new Tooltip(mychart, "default", {
                   text: function(o){
                       alert("Comes");
                      return "Element at index: "+o.index;
                   }
                });
                new Legend({chart: mychart}, "legendArea");
                });
            });
    </script>
  </body>
</html>

1 个答案:

答案 0 :(得分:0)

在定义工具提示后,我会尝试渲染您的图表。这应该可以使您的代码正常工作。