问题描述
我正在散点图上绘制一大组数据点(大约2000个点),但是其中许多数据点组合在图形的一小部分,这会损害图形的性能,开始变慢并冻结。有没有一种方法可以限制一次渲染的数据点数量?
我正在使用Jupyter和javascript用echart进行绘图。
这是我的代码:
myChart.setoption({
animation: false,backgroundColor: new echarts.graphic.RadialGradient(0.3,0.3,0.8,[{
offset: 0,color: '#f7f8fa'
},{
offset: 1,color: '#cdd0d5'
}]),title: {
text: 'Receita e Patrimonio de Clientes',left: 'center'
},grid: {
left: '3%',right: '4%',bottom: '3%',containLabel: true
},xAxis: {
type: 'value',name: 'ROA',nameLocation: 'center',nameTextStyle: {
lineHeight: 25
},scale: true,axisLabel: {
formatter: '{value}%'
},//min: 0,//max: 1.2
},yAxis: {
type: 'value',name:'Patrimonio',nameTextStyle: {
lineHeight: 130
},axisLabel: {
formatter: 'R${value}'
},//min:0,//max:600000
},dataZoom: [
{
type: 'slider',show: true,xAxisIndex: [0],start: 0,end: 35
},{
type: 'slider',yAxisIndex: [0],left: '93%',end: 35000000
},/*{
type: 'inside',start: 1,{
type: 'inside',start: 29,end: 36
}*/
],series: [{
data: data_points,type: 'scatter',symbolSize: 20,emphasis: {
label: {
show: true,formatter: function (param) {
return param.data[2];
},position: 'top'
}
},itemStyle: {
shadowBlur: 10,shadowColor: 'rgba(120,36,50,0.5)',shadowOffsetY: 5,color: new echarts.graphic.RadialGradient(0.4,1,[{
offset: 0,color: 'rgb(251,118,123)'
},{
offset: 1,color: 'rgb(204,46,72)'
}])
},markLine: {
linestyle: {
type: 'solid'
},data: [
{yAxis: 300000},{ xAxis: 0.6 }
]
},large: true,largeThreshold: 100
}] // We just need to create this
})
解决方法
您很可能需要采样之类的东西。我没有在Echarts上看到它,但是我通过数据截断解决了这个问题:您只需从you数组中插入第二,第三或第四个数据点。它基于精确的划分和数据索引。
请查看以下解决方案:Have series label displaying only once per series in eCharts