【问题标题】:Plot Bar Chart using Dojo使用 Dojo 绘制条形图
【发布时间】:2013-01-07 05:32:21
【问题描述】:

如何使用 Dojo 绘制条形图?我有一个包含 2 列 empidempsalary 的数据库。我想在道场中绘制一个条形图,empid 作为 x 轴,empsalary 作为 y 轴。请提出建议。

提前致谢
拉胡尔库马尔

【问题讨论】:

    标签: java dojox.charting


    【解决方案1】:

    这是一个使用 Dojo 图表绘制条形图的脚本:

    <script>
    require([
        // Require the basic chart class
        "dojox/charting/Chart",
    
        // Require the theme of our choosing
        "dojox/charting/themes/MiamiNice",
    
        // Charting plugins:
    
        //  We want to plot Columns
        "dojox/charting/plot2d/Columns",
    
        //  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) {
    
        // Define the data
        var chartData = [10000,9200,11811,12000,7662,13887,14200,12222,12000,10009,11288,12099];
    
        // 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: "Columns",
            markers: true,
            gap: 5
        });
    
        // Add axes
        chart.addAxis("x");
        chart.addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major" });
    
        // Add the series of data
        chart.addSeries("Monthly Sales",chartData);
    
        // Render the chart!
        chart.render();
    
    });
    
    </script>
    
    <div id="chartNode" style="width:800px;height:400px;"></div>
    

    详细解释请看here in Dojo tutorials

    【讨论】:

      猜你喜欢
      • 2017-09-27
      • 2021-07-28
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-04
      相关资源
      最近更新 更多