首页 > 解决方案 > 使用时间戳时 APEX 图表不显示任何内容

问题描述

var options = {
            chart: {
                height: 150,
                type: 'rangeBar',
            },
            plotOptions: {
                bar: {
                        horizontal: true,
                        endingShape: 'flat',
                        columnWidth: '70%',
                        barHeight: '70%',
                        distributed: false,
                        colors: {
                            ranges: [{
                                from: 0,
                                to: 0,
                                color: undefined
                            }],
                            backgroundBarColors: [],
                            backgroundBarOpacity: 1,
                        },
                        dataLabels: {
                            position: 'top',
                            maxItems: 100,
                            hideOverflowingLabels: true,
                        }
                    }
            },
            dataLabels: {
              enabled: true
            },
            tooltip: {
                    y: {
                        formatter: function(value) {
                        return moment(new Date(value)).format("HH : mm : ss :") 
                    }
                }
            },
            series: [{
                    data: [{
                        x: 'TEAM A',
                        y: [1358447400000, 1358620200000]
                    }]
            }],
            xaxis: {
                labels: {
                    formatter: function (value, timestamp) {
                        return timestamp//moment(new Date(value)).format("HH : mm : ss :")

                    }, 
                }
            }
            //  [{
            //     data: [{
            //       x: 'Team A',
            //       y: [1, 5]
            //     }, {
            //       x: 'Team B',
            //       y: [4, 6]
            //     }, {
            //       x: 'Team C',
            //       y: [5, 8]
            //     }, {
            //       x: 'Team D',
            //       y: [3, 11]
            //     }]
            // }, {
            //     data: [{
            //       x: 'Team A',
            //       y: [2, 6]
            //     }, {
            //       x: 'Team B',
            //       y: [1, 3]
            //     }, {
            //       x: 'Team C',
            //       y: [7, 8]
            //     }, {
            //       x: 'Team D',
            //       y: [5, 9]
            //     }]
            // }],

        }

        var chart = new ApexCharts(
                document.querySelector(el),
                options
            );

使用Apex Chart我想绘制时间戳。以上代码来自文档。但是当我运行它时,当我更改为数字时它不起作用。我的代码中缺少什么

标签: chartsapexcharts

解决方案


推荐阅读