首页 前端知识 echarts 散点图拟合曲线

echarts 散点图拟合曲线

2024-10-29 11:10:01 前端知识 前端哥 673 129 我要收藏

echarts版本需5以上,vue安装ecStat,js需引入ecStat.js

echarts.registerTransform(ecStat.transform.regression);

var ehart001 = echarts.init(echart001);
var option001 ={
  dataset: [
    {
      source: [[2.0,771.0], [1.0,760.0], [1.0,772.0], [1.0,766.0], [2.0,763.0], [2.0,778.0], [2.0,761.0], [1.0,820.0], [1.0,755.0], [1.0,783.0], [1.0,736.0], [1.0,744.0], [1.0,745.0], [1.0,754.0], [2.0,739.0], [2.0,766.0], [2.0,757.0], [2.0,753.0], [1.0,801.0], [2.0,777.0], [3.0,778.0], [4.0,740.0], [5.0,780.0], [7.0,927.0], [8.0,1164.0], [12.0,774.0], [14.0,776.0], [16.0,770.0], [17.0,811.0], [19.0,933.0], [21.0,1099.0], [24.0,1218.0], [27.0,1292.0], [29.0,1327.0], [30.0,1364.0], [26.0,900.0], [23.0,825.0], [16.0,803.0], [9.0,767.0], [7.0,753.0], [5.0,749.0], [4.0,703.0], [5.0,770.0], [6.0,774.0], [6.0,783.0], [6.0,754.0], [7.0,788.0], [7.0,779.0], [7.0,716.0], [7.0,761.0], [8.0,725.0], [8.0,751.0], [9.0,663.0], [11.0,769.0], [8.0,753.0], [6.0,753.0], [5.0,751.0], [4.0,753.0], [3.0,751.0], [3.0,837.0], [5.0,782.0], [8.0,788.0], [11.0,933.0], [13.0,1102.0], [15.0,1246.0], [18.0,1388.0], [19.0,1431.0], [20.0,1349.0], [19.0,1177.0], [18.0,728.0], [18.0,734.0], [16.0,732.0], [13.0,765.0], [12.0,936.0], [13.0,1172.0], [16.0,1432.0], [20.0,1675.0], [24.0,1551.0], [25.0,712.0], [25.0,1179.0], [26.0,1325.0], [29.0,1465.0], [33.0,1599.0], [38.0,1756.0], [37.0,1612.0], [36.0,1591.0], [36.0,1566.0], [35.0,1554.0]]
    },
    {
      transform: {
        type: 'ecStat:regression',
        config: { method: 'polynomial', order: 3 }
      }
    }
  ],
 
         title:{
           text:"",
           top:10,
           x: 'center',
           y: 'center',
       },
        grid: {
          top: "10%",
          right: '20%',
        },
  xAxis: {
    name:'',
    data:null,
    nameLocation:'center',
    nameGap:30,
    axisTick: {
      alignWithLabel: true,
    },
    splitLine: {
      lineStyle: {
        type: 'dashed'
      }
    }
  },
  yAxis: {
    splitLine: {
      lineStyle: {
        type: 'dashed'
      }
    },
    name:'',
    nameLocation:'center',
    nameGap:30,
    axisTick: {
      alignWithLabel: true,
    },
  },
  series: [
    {
      name: 'scatter',
      type: 'scatter',
      datasetIndex: 0,
       animation: false,
    },
    {
      name: 'line',
      type: 'line',
      smooth: true,
      datasetIndex: 1,
      symbolSize: 0.1,
      symbol: 'circle',
      label: { show: true, fontSize: 16 },
      labelLayout: { dx: -20 },
      encode: { label: 2, tooltip: 1 },
       animation: false,
    }
  ],
  progressive:0
};
;
if(option001 !=null){
ehart001.setOption(option001);
}
 

转载请注明出处或者链接地址:https://www.qianduange.cn//article/19484.html
标签
评论
发布的文章
大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!