ecomfe / echarts-stat

Statistics tool for Apache ECharts
595 stars 309 forks source link

opt.dimensions not working #51

Closed kingyue737 closed 4 months ago

kingyue737 commented 1 year ago

According to the docs, we can specify config.dimensions with strings. But it seems that only data with type number[][] takes effect. Reproduction: replacing the official online example with the following code, and you will find the regression line disappear:

// See https://github.com/ecomfe/echarts-stat
echarts.registerTransform(ecStat.transform.regression);
const data = [
  {x:0.067732, y:3.176513},
  {x:0.42781, y:3.816464},

];
option = {
  dataset: [
    {
      source: data
    },
    {
      transform: {
        type: 'ecStat:regression',
        // 'linear' by default.
        // config: { method: 'linear', formulaOn: 'end'}
        config:{
          dimensions:['x','y'],
        }
      }
    }
  ],
  title: {
    text: 'Linear Regression',
    subtext: 'By ecStat.regression',
    sublink: 'https://github.com/ecomfe/echarts-stat',
    left: 'center'
  },
  legend: {
    bottom: 5
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross'
    }
  },
  xAxis: {
    splitLine: {
      lineStyle: {
        type: 'dashed'
      }
    }
  },
  yAxis: {
    splitLine: {
      lineStyle: {
        type: 'dashed'
      }
    }
  },
  series: [
    {
      name: 'scatter',
      type: 'scatter'
    },
    {
      name: 'line',
      type: 'line',
      datasetIndex: 1,
      symbolSize: 0.1,
      symbol: 'circle',
      label: { show: true, fontSize: 16 },
      labelLayout: { dx: -20 },
      encode: { label: 2, tooltip: 1 }
    }
  ]
};
kingyue737 commented 4 months ago

CLosing as this repo is not maintained