使用 ajax 调用修复顶点图表

如何解决使用 ajax 调用修复顶点图表

我使用 https://apexcharts.com/ 作为我的网络,但我发现了一些奇怪的情况

当数据正确但图表不正确时如何修复图表数据?

调用ajax返回时的数组数据

{
    "title": [
        "Aceh","Jabar","Jambi","Jogja","Metro"
    ],"total": [
        0,1
    ]
}

还有我的图表代码

axios.get(route('totalinputan')).then(function(response) {
    buildChart(response.data.title,response.data.total)
}).catch(function(error) {
    //
})

function buildChart(title,total) {
    Apex.tooltip = {
        theme: 'dark'
    }
    
    var options1 = {
        chart: {
            fontFamily: 'Quicksand,sans-serif',height: 365,type: 'area',zoom: {
                enabled: false
            },dropShadow: {
                enabled: true,opacity: 0.3,blur: 5,left: -7,top: 22
            },toolbar: {
                show: false
            },},colors: ['#1490cb'],dataLabels: {
            enabled: false
        },markers: {
            discrete: [{
                seriesIndex: 0,dataPointIndex: 7,fillColor: '#000',strokeColor: '#000',size: 5
            }]
        },subtitle: {
            text: 'Laporan Masuk',align: 'left',margin: 0,offsetX: -10,offsetY: 35,floating: false,style: {
                fontSize: '14px',color: '#888ea8'
            }
        },title: {
            text: '100',offsetY: 0,style: {
                fontSize: '25px',color: '#bfc9d4'
            },noData: {
            text: 'Loading...'
        },stroke: {
            show: true,curve: 'smooth',width: 2,lineCap: 'square'
        },series: total,labels: title,xaxis: {
            axisBorder: {
                show: false
            },axisTicks: {
                show: false
            },crosshairs: {
                show: true
            },labels: {
                offsetX: 0,offsetY: 5,style: {
                    fontSize: '12px',fontFamily: 'Quicksand,cssClass: 'apexcharts-xaxis-title',}
        },yaxis: {
            labels: {
                formatter: function(value,index) {
                    return parseInt(value)
                },offsetX: -15,cssClass: 'apexcharts-yaxis-title',grid: {
            borderColor: '#191e3a',strokeDashArray: 5,xaxis: {
                lines: {
                    show: true
                }
            },yaxis: {
                lines: {
                    show: true,}
            },padding: {
                top: 0,right: 0,bottom: 0,left: -10
            },legend: {
            position: 'top',horizontalAlign: 'right',offsetY: -50,fontSize: '16px',markers: {
                width: 10,height: 10,strokeWidth: 0,strokeColor: '#fff',fillColors: undefined,radius: 12,onClick: undefined,offsetX: 0,offsetY: 0
            },itemmargin: {
                horizontal: 0,vertical: 20
            }
        },tooltip: {
            theme: 'dark',marker: {
                show: true,x: {
                show: false,fill: {
            type: "gradient",gradient: {
                type: "vertical",shadeIntensity: 1,inverseColors: !1,opacityFrom: .28,opacityTo: .05,stops: [45,100]
            }
        },responsive: [{
            breakpoint: 575,options: {
                legend: {
                    offsetY: -30,}]
    }
    
    
    var chartIncomingReport = new ApexCharts(
        document.querySelector("#incoming_report"),options1
    );
    
    chartIncomingReport.render();
}

结果是

enter image description here

如您所见,来自服务器的数据是correct,但图表结果是错误的。

我的数据计数为 5,但始终在图表中显示 8

我错过了什么吗?

请帮忙

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?