Dojo官方教程:Charting

23 篇文章 0 订阅

实现了用程序代码来创建饼图,而不是用声明式。教程里面说:建议用代码而不是声明式的,代码的创建方式更稳定更可控。

代码如下:


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Demo: Basic Programmatic Chart</title>
        <link rel="stylesheet" href="css/style.css" media="screen">
    </head>
    <body>
        <h1>Demo: Basic Programmatic Chart</h1>
        
        <!-- create the chart -->
        <div id="chartNode" style="width: 550px; height: 550px;"></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>

            // x and y coordinates used for easy understanding of where they should display
            // Data represents website visits over a week period
            chartData = [
                { x: 1, y: 19021 },
                { x: 1, y: 12837 },
                { x: 1, y: 12378 },
                { x: 1, y: 21882 },
                { x: 1, y: 17654 },
                { x: 1, y: 15833 },
                { x: 1, y: 16122 }
            ];

            require([
                 // Require the basic 2d chart resource
                "dojox/charting/Chart",
                
                // Require the theme of our choosing
                "dojox/charting/themes/Claro",

                // Charting plugins: 

                //     Require the Pie type of Plot 
                "dojox/charting/plot2d/Pie",

                // Wait until the DOM is ready
                "dojo/domReady!"
            ], function(Chart, theme, PiePlot){

                // Create the chart within it's "holding" node
                var pieChart = new Chart("chartNode");
                
                // Set the theme
                pieChart.setTheme(theme);
                
                // Add the only/default plot 
                pieChart.addPlot("default", {
                    type: PiePlot, // our plot2d/Pie module reference as type value
                    radius: 200,
                    fontColor: "black",
                    labelOffset: -20
                });
                
                // Add the series of data
                pieChart.addSeries("January",chartData);

                // Render the chart!
                pieChart.render();

            });
        </script>
    </body>
</html>

实现效果如下:

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
分三个包上传时,第三个包好像传不上去,我给整合了一下,打在一个包里上传了! dojo精品中文教程 Dojo.1.0 Practice Note [1] 什么是dojo 选择dojo的理由 AJAX架构之Dojo篇 Adding Ajax中文版 (DoJo) DOJO学习笔记(七)-日期控件DropdownDatePicker和DatePicker DOJO常用的验证函数 Dojo with Adobe AIR Dojo 工具包教程 Dojo 快速安装 DojoJSON建立无限级AJAX动态加载的功能模块树 Dojo学习笔记( 模块与包) Dojo学习笔记-- djConfig解说 Dojo学习笔记-- dojo.dom Dojo学习笔记-- dojo.event & dojo.event.topic & dojo.event.browser Dojo学习笔记--DateTextbox Dojo学习笔记--Dojo的基础对象和方法 Dojo学习笔记--FisheyeList鱼眼效果 Dojo学习笔记--TabContainer Dojo学习笔记--ValidationTextbox Dojo学习笔记--dijit.Dialog Dojo学习笔记--dijit.Menu Dojo学习笔记--dijit.TitlePane Dojo学习笔记--dijit.Tooltip Dojo学习笔记--dijit.Tree Dojo学习笔记--dojo.graphics.color & dojo.uri.Uri Dojo学习笔记--dojo.string & dojo.lang Dojo学习笔记--动态生成widget Dojo学习笔记--开发自己的TitlePane Dojo学习笔记--页面部分区域遮挡,DialogUnderlay Dojo学习笔记(五)-djConfig详解 dojo data 接口详解 dojo0.9 使用心得 dojo学习笔记(一)-dojo.io.IO & dojo.io.BrowserIO) dojo学习笔记(三) dojo学习笔记(二) dojo.lang.array & dojo.lang.func & dojo.string.extras dojo学习笔记(六)- ContentPane dojo学习笔记(四) dojo的拖拽示例以及疑问! 介绍dojo事件 使用 Dojo 工具包和 JSON-RPC 构建企业 SOA Ajax 客户端 利用Dojo实现拖动(Drag and Drop)效果

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值