繁体   English   中英

将 highcharts 与 dojo 前端一起使用

[英]Using highcharts with a dojo front-end

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="async: true"></script>
    <script src="https://code.highcharts.com/highcharts.js"></script>
    <title>Tutorial: Hello Dojo!</title>
</head>
<body>
    <h1 id="greeting">Hello</h1>
    <!-- load Dojo -->
    <script>
        require([
            'dojo/dom',
            'dojo/dom-construct'
        ], function (dom, domConstruct) {
            var greetingNode = dom.byId('greeting');
            domConstruct.place('<em> Dojo!</em>', greetingNode);
        });
    </script>
    <div id="container" style="width:100%; height:400px;"></div>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const chart = Highcharts.chart('container', {
                chart: {
                    type: 'bar'
                },
                title: {
                    text: 'Fruit Consumption'
                },
                xAxis: {
                    categories: ['Apples', 'Bananas', 'Oranges']
                },
                yAxis: {
                    title: {
                        text: 'Fruit eaten'
                    }
                },
                series: [{
                    name: 'Jane',
                    data: [1, 0, 4]
                }, {
                    name: 'John',
                    data: [5, 7, 3]
                }]
            });
        });
    </script>
</body>
</html>

有人知道我如何将 highcharts 集成到 dojo 前端吗? 我收到此代码的错误消息是...

Uncaught ReferenceError: Highcharts is not defined at HTMLDocument.<anonymous> dojo.html:24:27

最终,我将不得不为构建在 dojo 上的 ESRI web 应用程序构建器工作,所以我希望 dojo 版本是相同的。 有人会告诉我如何检查吗? 我知道 2014 年为此制作了一个适配器( https://github.com/ben8p/highcharts.com-dojo-adapter )但是我找不到有关如何使用它的文档,并且此 repo 的所有者无法提供进一步的帮助,因为他们已经有一段时间没有在这个项目上工作了。

提前欢呼和感谢

官方不支持将 dojo 与 Highcharts 一起使用。 它似乎适用于 Highcharts 5,但始终建议使用最新版本。

<script src="https://code.highcharts.com/5/highcharts.js"></script>

演示: https ://jsfiddle.net/BlackLabel/wy3mu4pt/

用于 highcharts 的 Dojo 适配器是我们的社区包装器之一。 正如我在 github 项目中注意到的,它使用 Highcharts 3.0.7 版本进行了测试,因此它也可能与我们最新的 highcharts 版本不兼容。 获得特定 dojo 适配器问题答案的唯一可能是联系作者。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM