scatter3D 使用category(文本)作为一个数轴,Visualmap颜色映射存在问题
配置项如下
var data = [
['Distance', 'RSSI', 'Mark'],
[0.1, 1, 'corridor'],
[0.2, 1.1, 'lobby'],
[0.3, 1.2, '0'],
[0.4, 1.3, '1'],
[0.5, 1.4, 0],
[0.6, 1.5, 1],
];
var tips = ['corridor', 'lobby', '0', '1'];
var colors = {
'corridor':'#ff4000', 'lobby':'#7f00ff',
'0':'#0040ff', '1':'#ffbf00',
}
var _colors = [
'#ff4000', '#7f00ff',
'#0040ff', '#ffbf00',
];
option = {
visualMap: [{
top: 10,
tooltip: {
trigger: 'item'
},
type: 'piecewise',
dimension: 2,
categories: tips,
inRange: {
color: _colors,
},
textStyle: {
color: '#000'
}
}],
grid3D: {
},
xAxis3D: {
name: 'Distance',
},
yAxis3D: {
name: 'Mark',
type: 'category',
data: tips,
},
zAxis3D: {
name: 'RSSI'
},
dataset: {
dimensions: [
'Distance',
'RSSI',
{
name: 'Mark',
type: 'ordinal'
},
],
source: data,
},
series: [{
id: 'scatter3D',
name: 'scatter3D',
type: 'scatter3D',
symbolSize: 3.5,
encode: {
x: 'Distance',
y: 'Mark',
z: 'RSSI',
tooltip: [0, 1, 2],
}
},
],
toolbox: {
feature: {
dataView: {},
},
},
};
myChart.setOption(option);