Dojo-Chart:Demo: Monthly Sales with Legend, Tooltips, and Magnify


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Demo: Monthly Sales with Legend, Tooltips, and Magnify</title>
        <link rel="stylesheet" href="style.css" media="screen">
    </head>
    <body class="claro">
        <h1>Demo: Monthly Sales with Legend, Tooltips, and Magnify</h1>
        
        <div id="chartNode" style="width:800px;height:400px;"></div>
        <div id="legend"></div>
        
        <!-- load dojo and provide config via data attribute -->
        <script src="dojo/dojo.js" data-dojo-config="isDebug: 1, async: 1, parseOnLoad: 1"></script>
        <script>
        require([
             // Require the basic chart class
            "dojox/charting/Chart",

            // Require the theme of our choosing
            "dojox/charting/themes/Claro",
            
            // Charting plugins: 

            //     We want to plot Lines 
            "dojox/charting/plot2d/Lines",

            // Load the Legend, Tooltip, and Magnify classes
            "dojox/charting/widget/Legend",
            "dojox/charting/action2d/Tooltip",
            "dojox/charting/action2d/Magnify",
            
            //    We want to use Markers
            "dojox/charting/plot2d/Markers",

            //    We'll use default x/y axes
            "dojox/charting/axis2d/Default",

            // Wait until the DOM is ready
            "dojo/domReady!"
        ], function(Chart, theme, LinesPlot, Legend, Tooltip, Magnify) {
            
            // Define the data
            var chartData = [10000,9200,11811,12000,7662,13887,14200,12222,12000,10009,11288,12099];
            var chartData2 = [3000,12000,17733,9876,12783,12899,13888,13277,14299,12345,12345,15763];
            var chartData3 = [3000,12000,17733,9876,12783,12899,13888,13277,14299,12345,12345,15763].reverse();
            
            // Create the chart within it's "holding" node
            var chart = new Chart("chartNode");

            // Set the theme
            chart.setTheme(theme);

            // Add the only/default plot 
            chart.addPlot("default", {
                type: LinesPlot,
                markers: true
            });
            
            // Add axes
            chart.addAxis("x");
            chart.addAxis("y", { min: 5000, max: 30000, vertical: true, fixLower: "major", fixUpper: "major" });

            // Add the series of data
            chart.addSeries("Monthly Sales - 2010",chartData);
            chart.addSeries("Monthly Sales - 2009",chartData2);
            chart.addSeries("Monthly Sales - 2008",chartData3);
            
            // Create the tooltip
            var tip = new Tooltip(chart,"default");
            
            // Create the magnifier
            var mag = new Magnify(chart,"default");
            
            // Render the chart!
            chart.render();
            
            // Create the legend
            var legend = new Legend({ chart: chart }, "legend");
        });
        
        </script>
    </body>
</html>

效果图如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值