先上图

使用highcharts绘制趋势图


难点在于,两种数据使用不同的表现形式,一种是column,一种是spline(平滑曲线)

/**
 * 绘制趋势图
 * id HTML Canvas 的ID
 * title 标题
 * subtitle 子标题
 * yTitle 纵轴标题
 * labels 横轴坐标值数组
 * val 第一组数据
 * avg 第二组数据
 */
var draw=function(id,title,subtitle,yTitle,labels,val,avg){
      //常规配置,使用column布局
      $('#'+id).highcharts({
          chart:{
              type:'column'
          },
          title:{text:title},
          subtitle:{text:subtitle},
          xAxis:{categories:labels,crosshair:true},
          yAxis:[
              { opposite: true   },
              { }
          ],
          tooltip: {
              headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
              pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
              '<td style="padding:0"><b>{point.y:.1f} </b></td></tr>',
              footerFormat: '</table>',
              shared: true,
              useHTML: true
          },
          plotOptions: {
              column: {
                  pointPadding: 0.2,
                  borderWidth: 0
              }
          },
          series:[
              { name:yTitle ,yAxis:0,data:val,type: 'column',color: '#AA4643'},
              { name:'avg3',yAxis:1,data:avg,type: 'spline',color: '#89A54E'}
          ]
      })
};


相关文章:

  • 2021-12-19
  • 2021-12-03
  • 2022-03-10
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-11
  • 2022-01-10
  • 2021-11-07
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案