ChartJS 如何在Y轴上所有分类值与X轴上的值相同的情况下绘制以下值

bfnvny8b  于 2022-11-06  发布在  Chart.js
关注(0)|答案(1)|浏览(199)

error image click here

伪数组示例:
工厂地址= [“abc”,“dbc”,“asd”]
opr_no_arr = [“公司1,““公司2,““公司3”]
draft_arr = [0:{x:“abc”,y:“公司1”},1:{x:“bds”,y:“公司2”},2:{x:“数据库”,y:“公司3”}]

等待创建= [0:{x:“abc”,y:“公司1”},1:{x:“bds”,y:“公司2”},2:{x:“dbc”,y:“公司3”}]
创建时间= [0:{x:“abc”,y:“公司1”},1:{x:“bds”,y:“公司2”},2:{x:“数据库”,y:“公司3”}]

name: "Pending For Creation",
        data: draft_arr,
        color:"#000000"
      },{
        name: "Created",
        data: created_arr,
        color:'#FF0000'
      },{
        name: "Execution In Progress",
        data: execution_arr,
        color:'#FFAE42'
      },
      {
        name: "Completed",
        data: completed_arr,
        color:'#28a745'
      }],
      chart: {
        height: 350,
        type: 'scatter',
        zoom: {
          enabled: true,
          type: 'xy'
        },
      },
      xaxis: {
        type: 'category',
        //tickAmount: 10,
        categories: plant_arr,
      }, this is working 
      yaxis:
        {
          //type: 'category',
          // tickAmount:1,
          // categories : opr_no_arr,
          labels: {
            maxWidth: "auto",
            formatter: (val : string, index) => opr_no_arr[index], //error cant show particaular labels 
          }, 
          title: {
            text: "OPR",
            style: {
              colors: "#000000"
            }
          }
        },
      legend: {
        position: "top",
        horizontalAlign: "right"
      }
    };
    this.first_chartRef = new ApexCharts(document.getElementById('first'), chartOptions);
    this.first_chartRef.render();
 }

this the image of the output red line are output required

osh3o9ms

osh3o9ms1#

y轴:{类型:'类别',勾选金额:6,类别:opr_no_arr,标签:{最大宽度:“auto”,},}保持这样并检查?

相关问题