dojo和Jquery混用 chart

https://github.com/cjolif/dojo-samples/blob/master/jquery-dojo-amd/chart.html

dojo通过packages加载jquery

<!DOCTYPE HTML>
<html>
<head>
    <script type="text/javascript"
            src="libs/dojo/dojo.js"
            data-dojo-config="async: true, packages: [
                { name: 'jquery', location:'http:10.88.123.228:680',main:'jquery-1.7.1.min'}
             ]">
    </script>

    <script type="text/javascript">
        define.amd.jQuery = true;
        var sales = [
            { month: "Jan",  revenues: 12435, profit: 53, America:40, Europe:35, Asia:25},
            { month: "Feb",  revenues: 11425, profit: 67, America:35, Europe:35, Asia:30},
            { month: "Mar",  revenues: 13534, profit: 130, America:45, Europe:25, Asia:30},
            { month: "Apr",  revenues: 12001, profit: 54, America:60, Europe:20, Asia:20},
            { month: "May",  revenues: 14334, profit: 140, America:40, Europe:30, Asia:30},
            { month: "Jun",  revenues: 12400, profit: 121, America:60, Europe:20, Asia:20},
            { month: "Jul",  revenues: 12212, profit: 50, America:40, Europe:30, Asia:30},
            { month: "Aug",  revenues: 14424, profit: 101, America:40, Europe:35, Asia:25},
            { month: "Nov",  revenues: 14134, profit: 72, America:35, Europe:35, Asia:30},
            { month: "Oct",  revenues: 13242, profit: 85, America:45, Europe:25, Asia:30},
            { month: "Nov",  revenues: 16312, profit: 264, America:60, Europe:20, Asia:20},
            { month: "Dec",  revenues: 19132, profit: 124, America:50, Europe:25, Asia:25}
        ];
        require(["jquery", "dojox/charting/Chart", "dojox/charting/axis2d/Default",
            "dojox/charting/plot2d/Default", "dojox/charting/plot2d/Columns", "dojox/charting/Theme",
            "dojox/charting/plot2d/Grid", "dojox/charting/StoreSeries", "dojo/store/Memory"],
                function($, Chart, Axis, Line, Columns, Theme, Grid, StoreSeries, Memory){
            var store = new Memory({ data: sales });
            var monthLabel = function(index){
                    if(index>12 || index<1){
                        return "";
                    }
                    return sales[index-1].month;
                };
            var theme = new Theme({
                chart: {
                    fill: { type: "linear", x1: 0, y1: 0, x2: 0, y2: 240, colors: [
                            { offset: 0, color: "#ececec" },
                            { offset: 0.5, color: "#cecece" },
                            { offset: 1, color: "#ececec" }
                        ]
                    }
                },
                plotarea: {
                    fill: { type: "linear", x1: 0, y1: 0, x2: 0, y2: 240, colors: [
                            { offset: 0, color: "#ececec" },
                            { offset: 0.5, color: "#cecece" },
                            { offset: 1, color: "#ececec" }
                        ]
                    }
                },
                marker: {
                    symbol: Theme.defaultMarkers.CIRCLE
                }
            });
            $(document).ready(function(){
                $("p").click(function(){
                    var chart = new Chart("chart").
                        setTheme(theme).
                        addAxis("x", { majorTickStep: 1, minorTicks: false, labelFunc: monthLabel, minorLabels: false}).
                        addAxis("ry", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true, majorTickStep: 10000, max: 30000, title: "Revenues"  }).
                        addAxis("py", { vertical: true, fixLower: "major", fixUpper: "major", includeZero: true, leftBottom: false, majorTickStep: 100, max: 300, title: "Profit" }).
                        addPlot("profit", {type: Line, vAxis: "py", tension: "X", markers: true, stroke: {color:"yellow"}, fill: "yellow", animate: true}).
                        addPlot("revenues", {type: Columns, gap: 5, vAxis: "ry", stroke: {color:"white"}, fill: "#2a6ead", animate: true}).
                        addPlot("grid", { type: Grid, vMajorLines: false, vAxis: "ry"}).
                        addSeries("data1", new StoreSeries(store, {}, function(item){
                            return item.revenues;
                        }), { plot: "revenues"}).
                        addSeries("data2", new StoreSeries(store, {}, function(item){
                            return item.profit;
                        }), {plot: "profit"});
                    chart.render();
                });
            });
        });
    </script>
</head>
<body>
  <p>Click on me to get a chart displayed</p>
  <div id="chart" style="width:480;height:320"></div>
</body>
</html>
    Contact GitHub API Training Shop Blog About
    © 2017 GitHub, Inc. Terms Privacy Security Status Help

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值