eCharts 中图例滑块中的小数点分隔符
Decimal Separator in legend slider in eCharts
参考 https://echarts.apache.org/examples/en/editor.html?c=map-usa (see also screenshot 上的示例图表,我如何使用 小数分隔符 在右侧的滑块中显示数字(如地图中的例如 德州)?
我发现了。我的解决方案:
用这个代码片段替换visualMap:{}
:
visualMap: {
left: 'right',
min: 500000,
max: 38000000,
inRange: {
color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
},
text:['High','Low'], // 文本,默认为数值文本
calculable: true,
formatter: function (value) {
value = Math.round(value);
let _count=value+"";
let _st=""
_count.split("").reverse().forEach((a,b)=>{
_st+=a;
b%3===2&&b!=_count.length-1?_st+=",":null;
})
_st=_st.split("").reverse().join("");
return _st;
}
},
给你this solution
参考 https://echarts.apache.org/examples/en/editor.html?c=map-usa (see also screenshot 上的示例图表,我如何使用 小数分隔符 在右侧的滑块中显示数字(如地图中的例如 德州)?
我发现了。我的解决方案:
用这个代码片段替换visualMap:{}
:
visualMap: {
left: 'right',
min: 500000,
max: 38000000,
inRange: {
color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
},
text:['High','Low'], // 文本,默认为数值文本
calculable: true,
formatter: function (value) {
value = Math.round(value);
let _count=value+"";
let _st=""
_count.split("").reverse().forEach((a,b)=>{
_st+=a;
b%3===2&&b!=_count.length-1?_st+=",":null;
})
_st=_st.split("").reverse().join("");
return _st;
}
},
给你this solution