chart.js多Y轴图表

在这里插入图片描述

<canvas class="full-height  info" 
        [chartType]="chartTemplate.chartType"
        [datasets]="chartTemplate.chartData"
        [labels]="chartTemplate.chartLabels"
        [options]="chartTemplate.chartOptions"
        [legend]="chartTemplate.chartlegend"
       >
</canvas> 
 chartTemplate = {
    chartOptions : {
      title: {
        display: true,
        padding:15,
        text: ['Rotation deg','Extention %','Bend deg'],
        fontSize:14,
        position:'left',
        fontColor:'#6f7173',
        fontFamily:'Arial',
        fontStyle:'normal'
    },
      scaleShowVerticalLines: false,
      responsive: true,
      // 大小自适应
      animation: false,
      scales: {
        yAxes: [{
          id: 'Rotation',
          type: 'linear',
          position: 'left',
          ticks: {
            max: 20,
            stepSize:5,
            fontColor:'#0000ff',
            min:-20
          },
          gridLines: {
            display: true,
            color:"#2b323b"
          }
          
        }, {
          id: 'Extention',
          type: 'linear',
          position: 'left',
          borderColor:'#f00',
          ticks: {
            max: 10,
            stepSize:0.5,
            fontColor:'#00cd00',
            min: 0
          },
          gridLines: {
            display: false,
          }
        },
        {
          id: 'Bend',
          type: 'linear',
          position: 'left',
          ticks: {
            max:15,
            stepSize:2,
            fontColor:'#ff3030',
            min: -10
          },
          gridLines: {
            display: false,
          }
        }
      ]
      },
      legend: {
        display: true,
        position:'top',
        fullWidth:true,
        labels:
        {
          fontSize: 18,
          fontColor:'#797a7b',
          fontFamily:'Arial',
          boxWidth:9,
          usePointStyle: true,
          padding:40
        },
      }
     },
     chartData : [
      {
        data: [0,0,0,0,0,0,0,0],
        label: 'Rotation',
        backgroundColor: [
          'transparent'
        ],
        yAxisID: 'Rotation',
        pointRadius: 0,
        pointHoverRadius: 0,
        borderColor: [
          'rgba(0, 0, 254,1)'
      ],
      pointBackgroundColor: [
          'rgba(0, 0, 254,1)'
      ],
       
        borderWidth: 0,
      },
      {
        data: [0,0,0,0,0,0,0,0],
        label: 'Extention',
        yAxisID: 'Extention',
        backgroundColor: [
          'transparent'
        ],
        pointRadius: 0,
        pointHoverRadius: 0,
        borderColor: [
            'rgba(0, 205, 0,1)'
        ],
        pointBackgroundColor: [
          'rgba(0, 205, 0,1)'
        ],
        borderWidth: 0,
      },
      {
        data: [0,0,0,0,0,0,0,0],
        label: 'Bend',
        yAxisID: 'Bend',
        backgroundColor: [
            'transparent',
        ],
        pointRadius: 0,
        pointHoverRadius: 0,
        borderColor: [
          'rgba(231, 0, 18,1)'
        ],
        pointBackgroundColor: [
          'rgba(231, 0, 18,1)'
        ],
        borderWidth: 0,
      },
     
    ],
    chartlegend:true,
    chartType: 'line',
    chartLabels: [],
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值