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
1 Answer
Reset to default 5You 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
评论列表(0条)