如何显示数据库数据中的多个图表?

时间:2019-06-26 15:52:01

标签: javascript node.js charts

我想显示表中每个记录的图表。记录呈现为对象。

我试图为每个数据库元素创建一个循环,但这给了我一个错误:

  

“未处理的承诺拒绝:TypeError:无法读取未定义的属性'labels'”

<script>
    var graph = document.getElementById('graph');

    {{#each items}}

    var options = {
        chart: {
            type: 'area',
            toolbar: {
                show: true,
                tools: {
                    download: true,
                    selection: true,
                    zoom: true,
                    zoomin: true,
                    zoomout: true,
                    pan: true,
                    customIcons: []
                },
                autoSelected: 'zoom'
            },
        },

        stroke: {
            show: true,
            curve: 'smooth',
            lineCap: 'butt',
            colors:  ['#000000'],
            width: 2,
            dashArray: 0,
        },

        dataLabels: {
            enabled: false
        },

        series: [{
            name: 'sensors',
            data: []
        }],
        xaxis: {
            categories: ["410","435","460","485","510","535","560","585","610","645","680", "705", "730","760","810","860","900","940"]
        },
    };
    var w = 1;
    var tableArr = [{{a}},{{b}},{{c}},{{d}},{{e}},{{f}},{{g}},{{h}},{{i}},{{j}},{{k}},{{l}},{{r}},{{s}},{{t}},{{u}},{{w}},{{v}}];
    var canvas = document.createElement("div");
    canvas.setAttribute("id", "myChart"+w);
    graph.append(canvas);
    var chartID = "myChart"+(w);

    var chartapex = new ApexCharts(document.getElementById(chartID), options);

    chartapex.render();
    w++;

    {{/each}}

</script>

我也在寻找其他解决方案。

0 个答案:

没有答案