我想将Apexcharts库用于我的仪表板。现在,我已经受困于他们的文档中的一个非常简单的示例(repeat(int count)
。
我使用了他们的示例,并尝试通过ID将其链接到我的画布容器,但是当我加载网站时,它根本没有显示。
我在底部的index.html中包含了cdn链接,并且在控制台中没有任何错误。
根据开发者工具,至少发生了一些事情:
这是我的JS:
var options = {
chart: {
type: 'line'
},
series: [{
name: 'sales',
data: [30, 40, 35, 50, 49, 60, 70, 91, 125]
}],
xaxis: {
categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999]
}
};
var chart = new ApexCharts(document.querySelector("#myChart"), options);
chart.render();
这是画布容器:
<div class="column">
<div class="wrapperDoughnut">
<canvas width="220px" height="280px" id="myChart"></canvas>
</div>
</div>
答案 0 :(得分:0)
真幸运,我找到了解决方案。似乎在渲染图表时Apexcharts库本身会创建画布,例如ChartJS除外,后者需要预定义画布容器。因此,我只是删除了画布容器并链接到父容器。
Apex文档很差...
尽管如此,我是否应该再次删除该线程?
工作解决方案:
HTML:
<div class="column">
<div class="wrapperDoughnut" id="myChart">
</div>
</div>
JS:
var options = {
chart: {
type: 'line'
},
series: [{
name: 'sales',
data: [30, 40, 35, 50, 49, 60, 70, 91, 125]
}],
xaxis: {
categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999]
}
};
var chart = new ApexCharts(document.querySelector("#myChart"), options);
chart.render();