javascript - Working with many data points in ECharts.js - Stack Overflow

I need help to improve the number of points displayed on the chart line.With the current code, for 100

I need help to improve the number of points displayed on the chart line. With the current code, for 100000 points, only 20 drawn in the graph line.

var elements = new Array(100000);

for (i = 0; i < elements.length; i++) {
    elements[i] = i;
}

var myChart = echarts.init(document.getElementById('main'));
var option = {
    title: {
        text: 'ECharts entry example'
    },
    tooltip: {},
    legend: {
        data:['Sales']
    },
    xAxis: {
        data: elements
    },
    yAxis: {},
    series: [{
        name: 'Sales',
        type: 'line',
        data: elements
    }]
};
myChart.setOption(option);

I need help to improve the number of points displayed on the chart line. With the current code, for 100000 points, only 20 drawn in the graph line.

var elements = new Array(100000);

for (i = 0; i < elements.length; i++) {
    elements[i] = i;
}

var myChart = echarts.init(document.getElementById('main'));
var option = {
    title: {
        text: 'ECharts entry example'
    },
    tooltip: {},
    legend: {
        data:['Sales']
    },
    xAxis: {
        data: elements
    },
    yAxis: {},
    series: [{
        name: 'Sales',
        type: 'line',
        data: elements
    }]
};
myChart.setOption(option);

Share Improve this question edited Jan 24, 2018 at 14:02 Jeffrey Roosendaal 7,1578 gold badges43 silver badges58 bronze badges asked Jan 22, 2018 at 5:13 Sávio RairesSávio Raires 1592 gold badges5 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You have to modify the xAxis for this. You should take a look at the axisTicks, and play around with the interval option. It either supports auto, a number or a function.


Alternatively, you can also manually show/hide the datapoints, by telling the data elements to display them, but maybe this only works when there's an axis tick available.

For displaying every datapoint, set showAllSymbol to true in the series data.

series: [{
    name: 'Sales',
    type: 'line',
    showAllSymbol: true,
    data: elements
}]

However, 20.000 datapoints may be a lot, so you can also create an interval by setting showSymbol within the data elements

for(i = 0; i < elements.length; i++){
    elements[i] = {
        value: i,
        symbol: (i % 100 === 0) ? 'circle' : 'none'
    }
}

This will set showSymbol to true for every 100th iteration. You may have to bine this with showAllSymbol: true in the series data to work properly.

Note: % is the modulus operator

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745540488a4632105.html

相关推荐

  • javascript - Working with many data points in ECharts.js - Stack Overflow

    I need help to improve the number of points displayed on the chart line.With the current code, for 100

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信