Git Product home page Git Product logo

echarts-stat's Introduction

ecStat

A statistical and data mining tool for Apache ECharts. You can use it to analyze data and then visualize the results with ECharts, or just use it to process data.

It works both in node.js and in the browser.

Read this in other languages: English, 简体中文.

Installing

If you use npm, you can install it with:

npm install echarts-stat

Otherwise, download this tool from dist directory:

<script src='./dist/ecStat.js'></script>
<script>

var result = ecStat.clustering.hierarchicalKMeans(data, clusterNumber, false);

</script>

If using bundler (like webpack, rollup, etc.), for example:

npm install echarts-stat
npm install echarts
import * as echarts from 'echarts';
import {transform} from 'echarts-stat';

echarts.registerTransform(transform.histogram);

var myChart = echarts.init(document.getElementById('main0'));

var option = {
    dataset: [{
        source: [
            [8.3, 143], [8.6, 214], [8.8, 251], [10.5, 26], [10.7, 86], [10.8, 93], [11.0, 176], [11.0, 39], [11.1, 221], [11.2, 188], [11.3, 57], [11.4, 91], [11.4, 191], [11.7, 8], [12.0, 196], [12.9, 177], [12.9, 153], [13.3, 201], [13.7, 199], [13.8, 47], [14.0, 81], [14.2, 98], [14.5, 121], [16.0, 37], [16.3, 12], [17.3, 105], [17.5, 168], [17.9, 84], [18.0, 197], [18.0, 155], [20.6, 125]
        ]
    }, {
        transform: {
            type: 'ecStat:histogram'
        }
    }],
    tooltip: {
    },
    xAxis: {
        type: 'category',
        scale: true
    },
    yAxis: {},
    series: {
        name: 'histogram',
        type: 'bar',
        barWidth: '99.3%',
        label: {
            show: true,
            position: 'top'
        },
        datasetIndex: 1
    }
};

myChart.setOption(option);

API Reference

Histogram

A histogram is a graphical representation of the distribution of numerical data. It is an estimate of the probability distribution of a quantitative variable. It is a kind of bar graph. To construct a histogram, the first step is to "bin" the range of values - that is, divide the entire range of values into a series of intervals - and then count how many original sample values fall into each interval. The bins are usually specified as consecutive, non-overlapping intervals of a variable. Here the bins(intervals) must be adjacent, and are of equal size.

Syntax

  • Used as echarts transform (since echarts 5.0)
    echarts.registerTransform(ecStat.transform.histogram);
    chart.setOption({
        dataset: [{
            source: data
        }, {
            type: 'ecStat:histogram',
            config: config
        }],
        ...
    });
  • Standalone
    var bins = ecStat.histogram(data, config);
    // or
    var bins = ecStat.histogram(data, method);
Parameter
  • data - number[] | number[][]. Data samples of numbers.

    // One-dimension array
    var data = [8.6, 8.8, 10.5, 10.7, 10.8, 11.0, ... ];

    or

    // Two-dimension array
    var data = [[8.3, 143], [8.6, 214], ...];
  • config - object.

    • config.method - 'squareRoot' | 'scott' | 'freedmanDiaconis' | 'sturges'. Optional. Methods to calculate the number of bin. There is no "best" number of bin, and different bin size can reveal different feature of data.

      • squareRoot - This is the default method, which is also used by Excel histogram. Returns the number of bin according to Square-root choice:

        var bins = ecStat.histogram(data);
      • scott - Returns the number of bin according to Scott's normal reference Rule:

        var bins = ecStat.histogram(data, 'scott');
      • freedmanDiaconis - Returns the number of bin according to The Freedman-Diaconis rule:

        var bins = ecStat.histogram(data, 'freedmanDiaconis');
      • sturges - Returns the number of bin according to Sturges' formula:

        var bins = ecStat.histogram(data, 'sturges');
    • config.dimensions - (number | string). Optional. Specify the dimensions of data that are used to regression calculation. By default 0, which means the column 0 and 1 is used in the regression calculation. In echarts transform usage, both dimension name (string) and dimension index (number) can be specified. In standalone usage, only dimension index can be specified (not able to define dimension name).

Return Value (only for standalone usage)
  • Used as echarts transform (since echarts 5.0)
    dataset: [{
        source: [...]
    }, {
        transform: 'ecStat:histogram'
        // // The result data of this dataset is like:
        // [
        //     // MeanOfV0V1, VCount, V0, V1, DisplayableName
        //     [  10,         212           8,  12, '8 - 12'],
        //     ...
        // ]
        // // The rest of the input dimensions that other than
        // // config.dimensions specified are kept in the output.
    }]
  • Standalone
    • result - object. Contain detailed messages of each bin and data used for ECharts to draw the histogram.
      • result.bins - BinItem[]. An array of bins, where each bin is an object (BinItem), containing three attributes:
        • x0 - number. The lower bound of the bin (inclusive).
        • x1 - number. The upper bound of the bin (exclusive).
        • sample - number[]. Containing the associated elements from the input data.
      • result.data - [MeanOfV0V1, VCount, V0, V1, DisplayableName][]. Used for bar chart to draw the histogram, where the length of sample is the number of sample values in this bin. For example:
        var bins.data = [
            // MeanOfV0V1, VCount, V0, V1, DisplayableName
            [  10,         212,          8,  12, '8 - 12'],
            ...
        ];
        // The rest of the input dimensions that other than
        // config.dimensions specified are kept in the output.
      • result.customData - [V0, V1, VCount][]. Used for custom chart to draw the histogram, where the length of sample is the number of sample values in this bin.

Examples

test/transform/histogram_bar.html

test/standalone/histogram_bar.html

histogram

Run

Clustering

Clustering can divide the original data set into multiple data clusters with different characteristics. And through ECharts, you can visualize the results of clustering, or visualize the process of clustering.

Syntax

  • Used as echarts transform (since echarts 5.0)
    echarts.registerTransform(ecStat.transform.clustering);
    chart.setOption({
        dataset: [{
            source: data
        }, {
            type: 'ecStat:clustering',
            config: config
        }],
        ...
    });
  • Standalone
    var result = ecStat.clustering.hierarchicalKMeans(data, config);
    // or
    var result = ecStat.clustering.hierarchicalKMeans(data, clusterCount, stepByStep);
Parameter
  • datanumber[][]. Two-dimensional numeric array, each data point can have more than two numeric attributes in the original data set. In the following example, data[0] is called data point and data[0][1] is one of the numeric attributes of data[0].

    var data = [
        [232, 4.21, 51, 0.323, 19],
        [321, 1.62, 18, 0.139, 10],
        [551, 11.21, 13, 0.641, 15],
        ...
    ];
  • config - object.

    • config.clusterCountnumber. Mandatory. The number of clusters generated. Note that it must be greater than 1.
    • config.dimensions - (number | string)[]. Optional. Specify which dimensions (columns) of data will be used to clustering calculation. The other columns will also be kept in the output data. By default all of the columns of the data will be used as dimensions. In echarts transform usage, both dimension name (string) and dimension index (number) can be specified. In standalone usage, only dimension index can be specified (not able to define dimension name).
    • config.stepByStepboolean. Optional. Control whether doing the clustering step by step. By default false.
    • config.outputType - 'single' | 'multiple'. Optional. Specify the format of the output. In "standalone" usage, it is by default 'multiple'. In "transform" usage, it can not be specified, always be 'single'.
    • config.outputClusterIndexDimension - (number | {index: number, name?: string}). Mandatory. It only works in config.outputType: 'single'. In this mode, the cluster index will be written to that dimension index of the output data. If be a number, it means dimension index. Dimension index is mandatory, while dimension name is optional, which only enables the downstream refer this dimension by name.
    • config.outputCentroidDimensions - (number | {index: number, name?: string})[] Optional. It only works in config.outputType: 'single'. If specify, the cluster centroid will be written to those dimensions of the result data. By default the centroids will not be written to the result data. If be a number, it means dimension index. Dimension index is mandatory, while dimension name is optional, which only enables the downstream refer this dimension by name.
Return Value

For example, the input data is:

var data = [
    // dimensions:
    // 0    1      2    3      4
    [ 232,  4.21,  51,  0.323, 'xxx'],
    [ 321,  1.62,  18,  0.139, 'xzx'],
    [ 551,  11.21, 13,  0.641, 'yzy'],
    ...
];

And we specify the config as:

config = {
    dimensions: [2, 3],
    outputClusterIndexDimension: 5
}

The result will be:

  • Used as echarts transform (since echarts 5.0)
    dataset: [{
        source: [ ... ],
    }, {
        transform: 'ecStat:clustering',
        config: {
            clusterCount: 6,
            outputClusterIndexDimension: 5,
            outputCentroidDimensions: [6, 7]
        }
        // The result data of this dataset will be:
        // [
        //    // dim2, dim3 are used in clustering.
        //    // All of the input data are kept in the output.
        //    // dim5 is the output cluster index.
        //    // dim6 is the output distance value.
        //    // dimensions:
        //    // 0    1      2    3       4       5   6   7
        //    [ 232,  4.21,  51,  0.323,  'xxx',  0,  14, 0.145 ],
        //    [ 321,  1.62,  18,  0.139,  'xzx',  2,  24, 0.321 ],
        //    [ 551,  11.21, 13,  0.641,  'yzy',  0,  14, 0.145 ],
        //    ...
        // ]
    }, {
        fromDatasetIndex: 1,
        fromTransformResult: 1
        // The result data of this dataset will be:
        // centroids: [
        //     // center of cluster0
        //     [14, 0.145],
        //     // center of cluster1
        //     [24, 0.321],
        //     ...
        // ]
    }]
  • Standalone
    • outputType: 'single':
      • result - object. For example:
        result = {
            data: [
                // dim2, dim3 are used in clustering.
                // All of the input data are kept in the output.
                // dim5 is the output cluster index.
                // dim6 is the output distance value.
                // dimensions:
                // 0    1      2    3      4      5  6
                [ 232,  4.21,  51,  0.323, 'xxx', 0, 89 ],
                [ 321,  1.62,  18,  0.139, 'xzx', 2, 23 ],
                [ 551,  11.21, 13,  0.641, 'yzy', 0, ?? ],
                ...
            ],
            centroids: [
                // center of cluster0
                [14, 0.145],
                // center of cluster1
                [24, 0.321],
                ...
            ]
        }
    • outputType: 'multiple':
      • resultobject. Including the centroids, and pointsInCluster. For example:
        result = {
            pointsInCluster: [
                // points in cluster0
                [
                    [ 232,  4.21,  51,  0.323, 'xxx' ],
                    [ 551,  11.21, 13,  0.641, 'yzy' ],
                    ...
                ],
                // points in cluster1
                [
                    [ 321,  1.62,  18,  0.139, 'xzx' ],
                    ...
                ],
                ...
            ],
            centroids: [
                // center of cluster0
                [14, 0.145],
                // center of cluster1
                [24, 0.321],
                ...
            ]
        };

Examples

You can not only do cluster analysis through this interface, but also use ECharts to visualize the results.

Note: the clustering algorithm can handle multiple numeric attributes, but for the convenience of visualization, two numeric attributes are chosen here as an example.

Directly visualize the final results of clustering

test/transform/clustering_bikmeans.html

test/standalone/clustering_bikmeans.html

static clustering

Run

Visualize the process of clustering

test/standalone/clustering_animation.html

dynamic clustering

Run

Regression

Regression algorithm can according to the value of the dependent and independent variables of the data set, fitting out a curve to reflect their trends. The regression algorithm here only supports two numeric attributes.

Syntax

  • Used as echarts transform (since echarts 5.0)
    echarts.registerTransform(ecStat.transform.regression);
    chart.setOption({
        dataset: [{
            source: data
        }, {
            type: 'ecStat:regression',
            config: {
                method: regressionType,
                ...opt
            }
        }],
        ...
    });
  • Standalone
    var myRegression = ecStat.regression(regressionType, data, opt);
    // or
    var myRegression = ecStat.regression('polynomial', data, order);
Parameters
  • regressionType - string. Mandatory. There are four types of regression, which are 'linear', 'exponential', 'logarithmic', 'polynomial'.
  • data - number[][]. Two-dimensional numeric array, Each data object should have two numeric attributes in the original data set. For Example:
    var data = [
        [1, 2],
        [3, 5],
        ...
    ];
  • opt - object.
    • opt.dimensions - (number | string)[] | (number | string). Optional. Specify the dimensions of data that are used to regression calculation. By default [0, 1], which means the column 0 and 1 is used in the regression calculation. In echarts transform usage, both dimension name (string) and dimension index (number) can be specified. In standalone usage, only dimension index can be specified (not able to define dimension name).
    • opt.order - number. Optional. By default 2. The order of polynomial. If you choose other types of regression, you can ignore it.
Return Value (only for standalone usage)
  • Used as echarts transform (since echarts 5.0)
    dataset: [{
        source: [...]
    }, {
        transform: 'ecStat:regression',
        // // The result of this dataset is like:
        // [
        //     // ValueOnX, ValueOnY
        //     [  23,       51      ],
        //     [  24,       62      ],
        //     ...
        // ]
        // // The rest of the input dimensions that other than
        // // config.dimensions specified are kept in the output.
    }]
  • Standalone
    • myRegression - object. Including points, parameter, and expression. For Example:

      myRegression.points = [
          // ValueOnX, ValueOnY
          [  23,       51      ],
          [  24,       62      ],
          ...
      ];
      // The rest of the input dimensions that other than
      // config.dimensions specified are kept in the output.
      
      // This is the parameter of linear regression,
      // for other types, it should be a little different
      myRegression.parameter = {
          gradient: 1.695,
          intercept: 3.008
      };
      
      myRegression.expression = 'y = 1.7x + 3.01';

Examples

You can not only do regression analysis through this interface, you can also use ECharts to visualize the results.

Linear Regression

test/transform/regression_linear.html

test/standalone/regression_linear.html

linear regression

Run

Exponential Regression

test/transform/regression_exponential.html

test/standalone/regression_exponential.html

exponential regression

Run

Logarithmic Regression

test/transform/regression_logarithmic.html

test/standalone/regression_logarithmic.html

logarithmic regression

Run

Polynomial Regression

test/transform/regression_polynomial.html

test/standalone/regression_polynomial.html

polynomial regression

Run

Statistics

This interface provides basic summary statistical services.

ecStat.statistics.deviation()

Syntax
var sampleDeviation = ecStat.statistics.deviation(dataList);
Parameter
  • dataList : number[]
Return Value
  • sampleDeviation: number. Return the deviation of the numeric array dataList. If the dataList is empty or the length less than 2, return 0.

ecStat.statistics.sampleVariance()

Syntax
var varianceValue = ecStat.statistics.sampleVariance(dataList);
Parameter
  • dataList : number[]
Return Value
  • varianceValue: number. Return the variance of the numeric array dataList. If the dataList is empty or the length less than 2, return 0.

ecStat.statistics.quantile()

Syntax
var quantileValue = ecStat.statistics.quantile(dataList, p);
Parameter
  • dataList : number[]. Sorted array of numbers.
  • p: number. where 0 =< p <= 1. For example, the first quartile at p = 0.25, the seconed quartile at p = 0.5(same as the median), and the third quartile at p = 0.75.
Return Value
  • quantileValue: number. Return the quantile of the sorted array of numbers. If p <= 0 or the length of dataList less than 2, return the first element of the sorted array dataList; if p >= 1, return the last element of the sorted array dataList; If dataList is empty, return 0.

ecStat.statistics.max()

Syntax
var maxValue = ecStat.statistics.max(dataList);
Parameter
  • dataList : number[]
Return Value
  • maxValue: number. The maximum value of the dataList.

ecStat.statistics.min()

Syntax
var minValue = ecStat.statistics.min(dataList);
Parameter
  • dataList : number[]
Return Value
  • minValue: number. The minimum value of the dataList.

ecStat.statistics.mean()

Syntax
var meanValue = ecStat.statistics.mean(dataList);
Parameter
  • dataList : number[]
Return Value
  • meanValue: number. The average of the dataList.

ecStat.statistics.median()

Syntax
var medianValue = ecStat.statistics.median(dataList);
Parameter
  • dataList : number[]. Sorted array of numbers
Return Value
  • medianValue: number. The median of the dataList.

ecStat.statistics.sum()

Syntax
var sumValue = ecStat.statistics.sum(dataList);
Parameter
  • dataList : number[]
Return Value
  • sumValue: number. The sum of the dataList.

Notice

The Apache Software Foundation Apache ECharts, ECharts, Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the Apache Software Foundation.

echarts-stat's People

Contributors

100pah avatar deqingli avatar fbambi avatar ovilia avatar pissang avatar roblav96 avatar tdkdhilip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

echarts-stat's Issues

Missing type for transform regression.

How to use transform regression in echarts (ngx-echarts) TypeScript? Missing type?

import * as echarts from 'echarts';
import * as ecStat from 'echarts-stat';
echarts.registerTransform(ecStat.transform.regression);

image

ecStat.d.ts

// node_modules\echarts-stat\src\ecStat.d.ts

declare namespace EChartsStat {
  type InputData = Array<Array<number>>;
  type OutputData = Array<Array<number>>;

  interface HistogramBins {
    bins: Array<HistogramBinsBin>;
    data: OutputData;
    customData: OutputData;
  }
  interface HistogramBinsBin {
    x0: number;
    x1: number;
    sample: Array<number>;
  }
  function histogram(
    data: Array<number>,
    binMethod: 'squareRoot' | 'scott' | 'freedmanDiaconis' | 'sturges'
  ): HistogramBins;

  namespace clustering {
    interface Result {
      centroids: OutputData;
      clusterAssment: OutputData;
      pointsInCluster: OutputData;
    }
    function hierarchicalKMeans(
      data: InputData,
      clusterNumer: number,
      stepByStep: boolean
    ): Result;
    function kMeans(data: InputData, clusterNumer: number): Result;
  }

  interface RegressionResult {
    points: OutputData;
    expression: string;
    gradient: number;
    intercept: number;
  }
  function regression(
    regreMethod: 'linear' | 'exponential' | 'logarithmic' | 'polynomial',
    data: InputData,
    order: number
  ): RegressionResult;

  namespace statistics {
    function deviation(data: Array<number>): number;
    function sampleVariance(data: Array<number>): number;
    function quantile(data: Array<number>, p: number): number;
    function max(data: Array<number>): number;
    function mean(data: Array<number>): number;
    function median(data: Array<number>): number;
    function min(data: Array<number>): number;
    function sum(data: Array<number>): number;
  }
}

declare module 'echarts-stat' {
  export = EChartsStat;
}

Goal: https://echarts.apache.org/examples/en/editor.html?c=scatter-linear-regression

{
    "echarts": "^5.0.2",
    "echarts-stat": "^1.2.0",
    "ngx-echarts": "^6.0.1",
}

尝试修改了一些bug

master...liangaili:patch-1

try to fix some bugs in ecStat.js. details below …

  1. Sometimes precision will become negavite value (I don't know why), set it to -precision or 0 (I don't know why, but my code works for me) if this happens.
    有的时候precision这个值会变成负数,导致出错,根据其他issue里的建议,我修改了部分precision的值,有的时候设成了-precision,有时设成了0,总之现在我这里不再出这个报错了。

  2. Doing rangeArray[i - 1] + step is not right, rangeArray is an array of floats while step is a string, which makes 20 + '0.1' become '200.1', change it to (rangeArray[i - 1] + parseFloat(step));
    在计算bins的x0和x1的时候,计算到最后一个元素需要计算rangeArray[i - 1] + step,这时前项是float而后项是string,导致计算结果错误。

  3. +((bin.x0 + bin.x1) / 2).toFixed(precision) will produce depulicated value, try this in your console: ((1.4+1.5)/2).toFixed(1) and ((1.3+1.4)/2).toFixed(1) will both produce 1.4
    计算bins的最后,toFixed导致了部分相邻项目会重叠。

  4. var ret = +((stop >= start ? step1 : -step1).toFixed(precision)); sometimes ret will be 0 (I don't know and why), but when this happens, just return 0.1
    有时返回的step会变成0,不知道为什么,但是强行设置成了0.1可以避免出错。

多项式回归算得的公式好像不对

官方多项式回归示例,公式算得y=0.0003x^{3}-0.066x^{2}+4.73*x-40.63
但是这个函数画出来的曲线跟echarts上的曲线是不一样的
如图,在200的时候,示例的y值才300,但是实际函数的y值已经是600了
image
image

Histogram range 出现计算精度误差

Histogram方法在对float数值进行计算过程中出现精度不一致的问题, 例如range的宽度是0.02, 计算出来的range会出现类似下面的情况 0.5,0.52, 0.54000000000001, 0.56, 0.58000000000001, 0.6

对于在x轴上显示带来问题。
能否根据Range计算过程中step的精度来决定histogram range数值的精度,比如做如下修改:
range.js

return function (start, stop, step) {

        var len = arguments.length;

        if (len < 2) {
            stop = start;
            start = 0;
            step = 1;
        }
        else if (len < 3) {
            step = 1;
        }
        else {
            step = +step;
        }

        var n = Math.ceil((stop - start) / step);
        var range = new Array(n + 1);

        for (var i = 0; i < n + 1; i++) {
            // range[i] = start + i * step;
            // 示例,根据step的精度来确定range的精度,使最终计算的结果中range的范围精度保持一致
            var decimalPart  = step.toString().split('.')[1];
            var precision = decimalPart ? decimalPart.length : 0;
            range[i] = Number((start + i * step).toFixed(precision));
        }
        return range;
    };

result includes origin data object

input: [[11, obj01], [22, obj02]]

config: {dimensions: 0}

result.bins.bins[n].sample: [11, obj01]

I need origin data obj to show data in tooltips.

ecstat 使用 histogram时,计算分组起始值时 存在0.1+0.2 != 0.3的

如源代码中出现的rangeArray[i - 1] + step,

`function computeBins(data, optOrMethod) {
var opt = typeof optOrMethod === 'string'
? { method: optOrMethod }
: (optOrMethod || {});

    var threshold = opt.method == null
        ? thresholdMethod.squareRoot
        : thresholdMethod[opt.method];
    var dimensions = normalizeDimensions(opt.dimensions);

    var values = dataPreprocess(data, {
        dimensions: dimensions,
        toOneDimensionArray: true
    });
    var maxValue = max(values);
    var minValue = min(values);
    var binsNumber = threshold(values, minValue, maxValue);
    var tickStepResult = tickStep(minValue, maxValue, binsNumber);
    var step = tickStepResult.step;
    var toFixedPrecision = tickStepResult.toFixedPrecision;

    // return the xAxis coordinate for each bins, except the end point of the value
    var rangeArray = range(
        // use function toFixed() to avoid data like '0.700000001'
        +((Math.ceil(minValue / step) * step).toFixed(toFixedPrecision)),
        +((Math.floor(maxValue / step) * step).toFixed(toFixedPrecision)),
        step,
        toFixedPrecision
    );

    var len = rangeArray.length;

    var bins = new Array(len + 1);

    for (var i = 0; i <= len; i++) {
        bins[i] = {};
        bins[i].sample = [];
        bins[i].x0 = i > 0
            ? rangeArray[i - 1]
            : (rangeArray[i] - minValue) === step
            ? minValue
            : _(rangeArray[i] - step);_
        bins[i].x1 = i < len
            ? rangeArray[i]
            : (maxValue - rangeArray[i-1]) === step
            ? maxValue
            : _rangeArray[i - 1] + step;_
    }

    for (var i = 0; i < values.length; i++) {
        if (minValue <= values[i] && values[i] <= maxValue) {
            bins[bisect(rangeArray, values[i], 0, len)].sample.push(values[i]);
        }
    }

    var data = map(bins, function (bin) {
        // use function toFixed() to avoid data like '6.5666638489'
        return [
            +((bin.x0 + bin.x1) / 2).toFixed(toFixedPrecision),
            bin.sample.length,
            bin.x0,
            bin.x1,
            bin.x0 + ' - ' + bin.x1
        ];
    });

    var customData = map(bins, function (bin) {
        return [bin.x0, bin.x1, bin.sample.length];
    });

    return {
        bins: bins,
        data: data,
        customData: customData
    };
}`

数据精度问题

我们的数据源是都是在0到1之间的三位小数,但是使用bins方法,只返回了4个分组,无法查看直方图规律

Linear regression fails on Date format

Hi there,

I'm currently looking into an implementation of the default available regressions, it seems like the chart does not draw regression models (just the Linear function) when the input data (source) is containing either a Date object or a timestamp.

Given a source input as dataset with the following structure:

source: [
    [
        Mon Dec 07 2020 00:00:00 GMT+0000 (Greenwich Mean Time),  // This is a valid Date object,
        50.90
    ],
    [
        Wed Oct 30 2019 00:00:00 GMT+0000 (Greenwich Mean Time),  // This is a valid Date object,
        97.90
    ],
]

When I push into the dataset a new transform with the type as ecStat:regression and method as linear no line gets drawn.

note:
The same behaviour happens when the Date object gets converted into a timestamp using the standard Date getTime() method.

note 2:
Regression models like exponential, logarithmic and polynomial draw perfectly fine using both Date object or timestamp, so I believe there must be something wrong within the linear function.

Type error: Property 'next' does not exist on type 'Result'.

In the file clustering.js (line 303), there is a call to result.next() but the type Interface for Result in ecStat.d.ts (line 21) does not provide a type definition for the next function. This causes a compilation error when using the example code in clustering_animation.html (line 64).

Please add a type definition for the next() function to the Result interface to avoid the following error:

error TS2339: Property 'next' does not exist on type 'Result'.

统计百分率时出现的一个问题,麻烦大佬看一下

var datas = [98, 97.69, 98.95, 98.15, 96.79, 99.8, 98.45, 91.72, 92.46, 98.68, 97.8, 97.71, 98.23, 99.28, 98.73, 99.18, 99.84, 99.47, 87.2, 98.89, 98.46, 97.69, 99.22, 98.4, 99.37, 96.53, 94.86, 78.02, 99.67, 71.25, 92.27, 100, 97.49, 99.25, 95.14, 96.81, 92.03, 95.63, 96.98, 91.72, 47.66, 99.97, 99.8, 99.97, 99.84, 99.57, 99.7, 99.78, 99.93, 97.89, 96.56, 66.1, 91.14, 81.42, 94.84, 98.61, 84.32, 40.2, 98.64, 97.06, 95.9, 90.66, 86.47, 92.71, 98.13, 34.19, 53.47, 56.97, 73.09, 60.07, 85.26, 38.63, 54.93, 91.78, 84.35, 94.58, 91.32, 87.14, 68.9, 37.53, 45.07, 89.61]
// 这个是百分数,里面有一个通过率是100%
var bins = ecStat.histogram(datas);
/*结果
0: (2) [33, 1]
1: (2) [38, 2]
2: (2) [43, 1]
3: (2) [48, 2]
4: (2) [53, 2]
5: (2) [58, 1]
6: (2) [63, 1]
7: (2) [68, 2]
8: (2) [73, 2]
9: (2) [78, 1]
10: (2) [83, 3]
11: (2) [88, 5]
12: (2) [93, 13]
13: (2) [98, 45]
14: (2) [103, 1] 《==== 这个就尴尬了 , 柱状图上会出现一个超过100%的存在 Orz
*/
var myChart = echarts.init(window.document.getElementById('chart'));
var option = {
title: {
text: '',
left: 'center',
top: 5
},
color: ['rgb(25, 183, 207)'],
grid: {
left: '1.5%',
right: '1.5%',
bottom: '01.5%',
containLabel: true
},
xAxis: [{
type: 'value',
scale: true,
}],
yAxis: [{
type: 'value',
}],
series: [{
name: 'height',
type: 'bar',
barWidth: '99.3%',
label: {
normal: {
show: true,
position: 'insideTop',
formatter: function (params) {
return params.value[1];
}
}
},
data: bins.data
}]
};
myChart.setOption(option);
})

// 而且最终的图表按示例绘制后,x轴还是有一定概率出现对不齐的现象。。
// 求大佬看一下

Linear , Polynomial series plotting

I want to plot a line chart with one Linear/Polynomial line series. But there is no proper documentation for using one Category axis.

import * as echarts from 'echarts';

import ecStat from 'echarts-stat';

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

// See https://github.com/ecomfe/echarts-stat
echarts.registerTransform(ecStat.transform.regression);
const data = [
{ name: 'Mon', value: 150 },
{ name: 'Tue', value: 230 },
{ name: 'Wed', value: 224 },
{ name: 'Thu', value: 218 },
{ name: 'Fri', value: 135 },
{ name: 'Sat', value: 147 },
{ name: 'Sun', value: 260 }
];
option = {
dataset: [
{
source: data
},
{
transform: {
type: 'ecStat:regression'
}
}
],
xAxis: {
type: 'category'
},
yAxis: {
type: 'value'
},
series: [
{
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 }
}
]
};

option && myChart.setOption(option);

精度报错:RangeError: toFixed() digits argument must be between 0 and 20

version: 1.1.1

使用的代码:

const bins = ecStat.histogram(day.listValue);

        const config = {
          backgroundColor: '#fff',
          color: ['#F15A5A', '#9FCFFF', '#FFD96C'],
          tooltip: {
            trigger: 'axis'
          },
          grid: {
            containLabel: true
          },
          xAxis: {
            type: 'category',
            scale: true,
            splitLine: {
              lineStyle: {
                color: '#eee'
              }
            },
            data: bins.bins.map(item => {
              return `[${item.x0}, ${item.x1})`;
            }),
            axisLabel: {
              rotate: 20,
            },
          },
          yAxis: {
            type: 'value',
            splitLine: {
              lineStyle: {
                color: '#eee'
              }
            }
          },
          series: [
            {
              type: 'bar',
              name: '因子分布',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  /* formatter: function(params) {
                    return params.value[1];
                  } */
                },
              },
              // data: bins.data,
              data: bins.bins.map(item => {
                return item.sample.length;
              }),
              // barWidth: '99.3%',
              barCategoryGap: '0%',
            },
          ]
        };

其中 day.listValue 的值为

[
  "46.1122",
  "79.9441",
  "65.9859",
  "25.3935",
  "42.7866",
  "305.0315",
  "18.1025",
  "33.8013",
  "54.5712",
  "814.8929",
  "49.9332",
  "106.3157",
  "47.7458",
  "244.226",
  "49.0097",
  "29.0577",
  "31.1753",
  "43.3136",
  "58.5335",
  "22.4288",
  "-11.6769",
  "20.6866",
  "331.7812",
  "11.5116",
  "14.6281",
  "30.9462",
  "291.3254",
  "1952.1139",
  "42.5726",
  "51.8977",
  "13.1309",
  "101.5074",
  "67.969",
  "580.0693",
  "39.1682",
  "39.9857",
  "15.4187",
  "19.0435",
  "453.9382",
  "34.3246",
  "21.0266",
  "8.5466",
  "-337.494",
  "74.0159",
  "20.9999",
  "38.1729",
  "14.4369",
  "73.7471",
  "16.1754",
  "18.4142",
  "29.2798",
  "36.5281",
  "44.2856",
  "23.2042",
  "-1055.9283",
  "60.4042",
  "13.3311",
  "143.9589",
  "20.8098",
  "55.519",
  "-6.6047",
  "347.5278",
  "129.5079",
  "37.6373",
  "5016.1411",
  "66.5109",
  "130.0112",
  "-13.2207",
  "76.0309",
  "22.7796",
  "36.9493",
  "-60.8982",
  "43.0935",
  "34.3241",
  "18.7641",
  "-16.9989",
  "56.3742",
  "-14.2415",
  "152.7147",
  "48.0559",
  "69.9903",
  "43.1559",
  "95.5448",
  "67.8536",
  "67.5987",
  "236.68200000000003",
  "40.4911",
  "19.5773",
  "31.5195",
  "27.7471",
  "26.8844",
  "128.9933",
  "50.9519",
  "32.1314",
  "47.5839",
  "31.6497",
  "153.8752",
  "42.7797",
  "36.2301",
  "29.0493",
  "19.4439",
  "32.8508",
  "-26.0843",
  "993.6406",
  "20.2155",
  "42.4152",
  "158.721",
  "76.5177",
  "64.5483",
  "74.1889",
  "20.4185",
  "48.2014",
  "66.1414",
  "22.8513",
  "125.2946",
  "45.5809",
  "89.7309",
  "33.7619",
  "110.0395",
  "38.8518",
  "87.5813",
  "20.3838",
  "45.3373",
  "245.2003",
  "33.7077",
  "45.5985",
  "21.6263",
  "21.2772",
  "16.9991",
  "48.5743",
  "32.7595",
  "84.5881",
  "124.8476",
  "58.4178",
  "157.689",
  "92.9167",
  "70.3227",
  "57.2383",
  "37.1941",
  "67.9477",
  "59.4279",
  "25.6653",
  "37.5302",
  "65.7551",
  "27.281",
  "60.2499",
  "144.5758",
  "677.7747",
  "36.7851",
  "37.5982",
  "172.9186",
  "44.4609",
  "72.5558",
  "-234.8506",
  "46.8691",
  "65.8725",
  "183.3086",
  "52.7152",
  "59.7837",
  "143.5452",
  "68.926",
  "57.8861",
  "36.7907",
  "66.49",
  "49.1127",
  "234.544",
  "79.9554",
  "52.174",
  "-139.5203",
  "-76.9621",
  "84.6753",
  "25.0969",
  "82.3473",
  "26.2366",
  "33.6382",
  "88.6027",
  "43.4883",
  "18.6724",
  "41.1948",
  "44.0906",
  "54.5789",
  "43.4056",
  "67.9087",
  "1701.2148",
  "54.4143",
  "117.9243",
  "41.8927",
  "136.248",
  "16.9029",
  "33.3713",
  "91.4584",
  "23.2714",
  "53.7191",
  "38.2199",
  "39.5026",
  "81.5323",
  "70.4219",
  "76.0257",
  "98.609",
  "88.8738",
  "36.0991",
  "44.7578",
  "91.9082",
  "17.9169",
  "56.0444",
  "47.4194",
  "47.2381",
  "54.7681",
  "44.3932",
  "49.3933",
  "66.2575",
  "58.1567",
  "112.9541",
  "35.4673",
  "85.0974",
  "28.6041",
  "84.7982",
  "30.67",
  "26.8869",
  "59.1792",
  "59.565",
  "39.9466",
  "42.0397",
  "60.7055",
  "37.9327",
  "31.8398",
  "62.5273",
  "69.1902",
  "53.5739",
  "29.2794",
  "42.9863",
  "45.2294",
  "41.9355",
  "71.9677",
  "31.0083",
  "216.8302",
  "65.428",
  "32.6606",
  "39.0246",
  "68.0098",
  "78.6268",
  "406.37699999999998",
  "88.5604",
  "61.7179",
  "74.5056",
  "40.6728",
  "12.4336",
  "60.2621",
  "68.3484",
  "22.3193",
  "26.6332",
  "22.3673",
  "25.6934",
  "13.2255",
  "35.1222",
  "27.5046",
  "-5.6767",
  "14.3282",
  "24.2138",
  "12.9862",
  "31.1639",
  "31.9648",
  "59.3972",
  "21.1512",
  "23.1336",
  "152.0642",
  "23.8739",
  "41.8323",
  "53.3303",
  "-215.9784",
  "35.7411",
  "145.9405",
  "-347.0922",
  "353.6866",
  "269.1379",
  "47.3668",
  "20.8251",
  "-11.7946",
  "176.7098",
  "-110.5078",
  "27.0835",
  "310.2762",
  "-136.8502",
  "35.0555",
  "37.6381",
  "31.4114",
  "15.2714",
  "345.2995",
  "94.9969",
  "-46.7537",
  "108.9767",
  "16.8032",
  "328.1013",
  "15.5718",
  "469.8549",
  "41.2185",
  "-96.3313",
  "105.0974",
  "34.0746",
  "68.1926",
  "-5.9197",
  "18.6305",
  "10.4123",
  "227.8507",
  "56.4311",
  "19.793",
  "31.2876",
  "30.7491",
  "30.2273",
  "-298.2306",
  "9.1886",
  "13.8888",
  "45.7195",
  "23.159000000000004",
  "-236.7455",
  "141.4538",
  "159.1012",
  "27.3736",
  "364.4178",
  "107.2776",
  "21.6099",
  "23.5347",
  "21.9842",
  "-85.7228",
  "617.7026",
  "49.3958",
  "83.6289",
  "17.6152",
  "-119.9347",
  "39.1311",
  "79.347",
  "102.7694",
  "28.7748",
  "23.6301",
  "47.1984",
  "33.8534",
  "232.2258",
  "235.6648",
  "-61.3977",
  "30.2815",
  "22.9648",
  "45.3414",
  "63.111000000000007",
  "82.1559",
  "14.5941",
  "44.2605",
  "24.2673",
  "-467.9343",
  "46.2747",
  "26.34",
  "34.3235",
  "24.6902",
  "28.6183",
  "130.659",
  "162.8182",
  "51.8934",
  "38.3788",
  "36.7753",
  "522.1838",
  "14.5283",
  "34.5246",
  "30.8602",
  "35.4004",
  "27.8597",
  "42.8646",
  "18.2249",
  "15.1134",
  "10.6581",
  "26.6319",
  "73.5008",
  "13.9021",
  "28.9988",
  "24.6413",
  "72.3369",
  "43.1009",
  "14.6119",
  "27.0754",
  "272.0576",
  "321.4032",
  "-40.5621",
  "-57.195",
  "136.1924",
  "507.4119",
  "30.4673",
  "103.7315",
  "-17.136",
  "30.8467",
  "7.7334",
  "37.3364",
  "15.7205",
  "-20.9888",
  "83.75299999999999",
  "111.8565",
  "59.5535",
  "38.9489",
  "36.7761",
  "33.6698",
  "52.2114",
  "-124.5301",
  "61.8157",
  "32.9585",
  "53.687",
  "30.0752",
  "52.2502",
  "65.6443",
  "39.9863",
  "-1158.2663",
  "17.3679",
  "-20.4349",
  "24.6134",
  "36.6528",
  "37.7252",
  "15.4751",
  "-26.5158",
  "93.4245",
  "150.6037",
  "17.5651",
  "44.0352",
  "29.1785",
  "27.8849",
  "32.9195",
  "25.7838",
  "-54.7277",
  "23.2095",
  "38.6302",
  "110.07",
  "43.8521",
  "47.1684",
  "41.4805",
  "21.6672",
  "81.7812",
  "22.6599",
  "25.9397",
  "-247.3548",
  "91.1875",
  "84.1449",
  "65.4708",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0",
  "0.0"
]

执行报错:

image

image

opt.dimensions not working

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 }
    }
  ]
};

R2

有没有返回R平方的值?

Expose options for bin width and bin count in histogram function

The methods available in the histogram function work for many cases, but not all. It would be helpful to be able to pass in a bin width or bin count to override the result of the bin calc function:

ecStat.histogram(data, binWidth=50)
// OR
ecStat.histogram(data, binCount=10)
// OR
ecStat.histogram(data, method='freedmanDiaconis')

This would allow a lot more flexibility in how to use the histogram function (e.g., you could add a slider component to a histogram chart to let a user play around with the bin count or width on a page).

Datasets with one value break freedmanDiaconis and scott methods

Occasionally, I need to show a histogram that contains only one value (the dataset below is an example):

[
{a: 5},
{a: 5},
{a: 5},
{a: 5},
{a: 5},
{a: 5},
{a: 5}
]

This works with the default bin method (square root) and works with sturges, but does not work with freedmanDiaconis or scott. For the two methods where it does not work, I receive an "Invalid array length" error.

While the chart itself isn't meaningful when it only has 1 value, it is a use case that will come up occasionally.

Need a README.zh-CN.md

The README is difficult for those who has't learned data processing, but actually this repository could be easier to learn and use.

Update README, documentation with Echarts v5.0 examples

Hi there,

First of all, thanks for creating and maintaining this library.

This issue is to request the possibility to update the documentation.

It seems like registerTransform doesn't exists in the newer version of Echarts - see url: Echarts API search page

Also, could you please write down some example of how to import the single functionalities rather than importing the whole package?

e.g. (not sure it exists, so the below is just an example to help you understand my request)

import { histogram } from 'ecstat/transform'

Optimization Suggestion

When I use dotted line style , the display line is lopsidedness.
My suggestion code (take linear regression for example)
`var predata = dataPreprocess(data);
var sumX = 0;
var sumY = 0;
var sumXY = 0;
var sumXX = 0;
var len = predata.length;

                        var min = 0;
                        var max = 0;

                        for (var i = 0; i < len; i++) {
                            sumX += predata[i][0];
                            sumY += predata[i][1];
                            sumXY += predata[i][0] * predata[i][1];
                            sumXX += predata[i][0] * predata[i][0];

                            if (max <= predata[i][0]) {
                                max = predata[i][0];
                            }
                            if (min >= predata[i][0]) {
                                min = predata[i][0];
                            }
                        }

                        var gradient = ((len * sumXY) - (sumX * sumY)) / ((len * sumXX) - (sumX * sumX));
                        var intercept = (sumY / len) - ((gradient * sumX) / len);

                        var result = [];
                        for (var j = Math.floor(min); j < Math.ceil(max); j++) {
                            var coordinate = [j, gradient * j + intercept];
                            result.push(coordinate);
                        }`

It works~~

precision -1 out of range

I got the error from this line, may I know what's the reason there's a negative number for the precision?

// echarts-stat/dist/ecStat.js:1393
return + ((stop >= start ? step1 : -step1).toFixed(-precision));

These are the arguments in the function triggered the error: start=1199, stop=1953, count=9

This is how I initialize the graph:

data = [1701, 1585, 1669, 1953, 1429, 1593, 1641, 1638, 1768, 1524, 1608, 1679, 1731, 1254, 1232, 1238, 1661, 1199, 1921, 1731, 1570, 1548, 1521, 1548, 1620, 1811, 1696, 1527, 1771, 1477, 1775, 1672, 1330, 1400, 1780, 1716, 1811, 1626, 1519, 1395, 1677, 1295, 1317, 1411, 1524, 1291, 1570, 1540, 1690, 1616, 1707, 1748, 1631, 1569, 1557, 1602, 1530, 1811, 1606, 1480, 1528, 1277, 1638, 1579, 1580, 1493]
const bins = ecStat.histogram(data)

Edited: Just notice there's existing PR and issues #16, #21 addressing this, hence closing. Any maintainers care to merge the PR and release it?

关于expression和points返回结果出错

data:[
[1, "0.5"],[2, "0.75"],[3, "1"],[4, "1.25"],[5, "1.5"],[6, "1.75"],[7, "2"],[8, "2.25"],
]

返回错误数值:

myRegression.expression返回结果为:y = NaNx + NaN,
myRegression.points二维数组返回结果为:
 [
[1, NaN],[2, NaN],[3, NaN],[4, NaN],[5, NaN],[6, NaN],[7, NaN],[8, NaN]
]

所有数据都为0的时候报错

const data = [0, 0, 0, ..., 0]
ecStat.histogram(data)

类似这样所有数据都相等的情况,就会报错:
RangeError: toFixed() digits argument must be between 0 and 100

是不是应该特殊处理一下这种情况?

【建议】单测 + 移除 define

  • 这个模块是一个纯 js 数学统计和计算的模块,应该需要一个单测来保证代码的正确性。
  • 移除 define 定义文件模块的方式,通过打包,生成最终的 dist 支持 amd(这个也是因为在 jest 环境无法引入 amd 模块文件,无法进行测试)。

Missing quantile in statistics

in "echarts-stat/src/statistics.js":
statistics.max = require('./statistics/quantile');
statistics.max = require('./statistics/sampleVariance');

and also sampleVariance

关于直方图间隔个数

现在, 直方图提供了四种计算小区间间隔个数的方法,分别是 squareRoot, scott, freedmanDiaconis 和 sturges,
可不可以自定义间隔区间?
比如:[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 我想按2 或 3 或 4 或 6来间隔bins

polynomial expression precision

echarts-stat/src/regression.js

if (i > 1) {
	string += Math.round(coeArray[i] * Math.pow(10, i + 1)) / Math.pow(10, i + 1) + 'x^' + i + ' + ';
}

this result in dispaly as 0x^2 + -0.01x + 36.58, the expected expression is -0.0005x^2 + -0.01x + 36.58
graph used echarts-stat
image
graph used excel
image

ecstat 处理分bin时报错

在画直方图之前进行ecStat.histogram(height,'scott')数据分箱。但是报错
数据如下:
var height = [200,70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 69, 75, 74, 85, 86, 71, 64, 78, 80, 74, 72, 77, 81, 82, 80, 80, 80, 87];
var bins = ecStat.histogram(height,'scott');
报错函数:
return function (start, stop, count) {
var step0 = Math.abs(stop - start) / count;
var precision = Math.floor(Math.log(step0) / Math.LN10);
var step1 = Math.pow(10, precision);
var error = step0 / step1;
if (error >= Math.sqrt(50)) {
step1 *= 10;
}
else if (error >= Math.sqrt(10)) {
step1 *= 5;
}
else if(error >= Math.sqrt(2)) {
step1 *= 2;
}
return +((stop >= start ? step1 : -step1).toFixed(-precision));

报错提示: toFix 函数输入值在0-1之间,而-precision为-1

Tooltip integration on regression lines

Hi there,

I'm currently looking into displaying a tooltip showing the regression calculation when the user goes on hover the regression line.

As far as I can tell there is no way to achieve it.

given a series of objects such as:

series: [
    {
     type: 'scatter',
     xAxisIndex: 0,
     yAxisIndex: 0, 
     emphasis: {
        focus: 'series',
      },
     data: [
        {
         name: 'point',
         value: [
            0.69,
            97.843, '...'
          ]
        }
      ]
    },
    {
     type: 'scatter',
     xAxisIndex: 0,
     yAxisIndex: 0,
     emphasis: {
        focus: 'series',
      },
     data: [
        {
         name: 'point',
         value: [
            0.89,
            107.343, '...'
          ]
        }
      ]
    },
    {
     name: 'Regression',
     type: 'line',
     datasetIndex: 1,
     symbolSize: 0,
    }
]

The tooltip works for the datasetIndex: 0 which is the list of dots but doesn't show for the index 1

tooltip parameter is set at the root of the configuration as:

tooltip: {
    trigger: 'item'
}

Looking forward to find a solution
Thanks in advance.

聚类图和回归图什么情况下不显示点?

如题,项目中同样options在echarts官方环境中显示点而在自己项目中不显示点,x和y的axis属性的data都设置为了null,其他还有哪个设置项会影响点的渲染呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.