84Echarts - 散点图(Polynomial Regression)

简介: 84Echarts - 散点图(Polynomial Regression)
效果图

源代码
var data = [
    [96.24, 11.35],
    [33.09, 85.11],
    [57.60, 36.61],
    [36.77, 27.26],
    [20.10, 6.72],
    [45.53, 36.37],
    [110.07, 80.13],
    [72.05, 20.88],
    [39.82, 37.15],
    [48.05, 70.50],
    [0.85, 2.57],
    [51.66, 63.70],
    [61.07, 127.13],
    [64.54, 33.59],
    [35.50, 25.01],
    [226.55, 664.02],
    [188.60, 175.31],
    [81.31, 108.68]
];
// See https://github.com/ecomfe/echarts-stat
var myRegression = ecStat.regression('polynomial', data, 3);
myRegression.points.sort(function(a, b) {
    return a[0] - b[0];
});
option = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross'
        }
    },
    title: {
        text: '18 companies net profit and main business income (million)',
        subtext: 'By ecStat.regression',
        sublink: 'https://github.com/ecomfe/echarts-stat',
        left: 'center',
        top: 16
    },
    xAxis: {
        type: 'value',
        splitLine: {
            lineStyle: {
                type: 'dashed'
            }
        },
        splitNumber: 20
    },
    yAxis: {
        type: 'value',
        min: -40,
        splitLine: {
            lineStyle: {
                type: 'dashed'
            }
        }
    },
    grid: {
        top: 90
    },
    series: [{
        name: 'scatter',
        type: 'scatter',
        label: {
            emphasis: {
                show: true,
                position: 'right',
                textStyle: {
                    color: 'blue',
                    fontSize: 16
                }
            }
        },
        data: data
    }, {
        name: 'line',
        type: 'line',
        smooth: true,
        showSymbol: false,
        data: myRegression.points,
        markPoint: {
            itemStyle: {
                normal: {
                    color: 'transparent'
                }
            },
            label: {
                normal: {
                    show: true,
                    position: 'left',
                    formatter: myRegression.expression,
                    textStyle: {
                        color: '#333',
                        fontSize: 14
                    }
                }
            },
            data: [{
                coord: myRegression.points[myRegression.points.length - 1]
            }]
        }
    }]
};
目录
相关文章
81Echarts - 散点图(Scatter Nutrients Matrix)
81Echarts - 散点图(Scatter Nutrients Matrix)
46 0
81Echarts - 散点图(Scatter Nutrients Matrix)
78Echarts - 散点图(Logarithmic Regression)
78Echarts - 散点图(Logarithmic Regression)
71 0
77Echarts - 散点图(Linear Regression)
77Echarts - 散点图(Linear Regression)
92 0
74Echarts - 散点图(Exponential Regression)
74Echarts - 散点图(Exponential Regression)
59 0
80Echarts - 散点图(Scatter Nutrients)
80Echarts - 散点图(Scatter Nutrients)
39 0
241Echarts - 3D 散点图(Scatter3D)
241Echarts - 3D 散点图(Scatter3D)
200 0
242Echarts - 3D 散点图(3D Scatter with Dataset)
242Echarts - 3D 散点图(3D Scatter with Dataset)
138 0
117Echarts - 热力图(Heatmap - 2w data)
117Echarts - 热力图(Heatmap - 2w data)
69 0
90Echarts - 散点图(Scatter Matrix)
90Echarts - 散点图(Scatter Matrix)
39 0
116Echarts - 热力图(Heatmap on Cartesian)
116Echarts - 热力图(Heatmap on Cartesian)
64 0