我已经创建了一个eCharts条形图,我只想交换x和y轴
我已经尝试过只交换轴的数据对象,但这是行不通的,并且谷歌搜索根本没有出现太多问题。
这是条形图的初始化脚本
var chart = echarts.init(document.getElementById('chart'));
var option = {
yAxis: {
name: '',
data: ''
},
xAxis: {
name: '',
data: ["CARH" , "CDFR" , "HGA" , "O2RG" , "SHLA" , "SHWS"]
},
series: {
name: '',
type: 'bar',
data: [100.29, 101.05, 100.78, 96.3, 101.8, 99.9]
}
};
chart.setOption(option);
答案 0 :(得分:0)
似乎[{
key1: 10,
key2: "a string"
},
{
key1: 20,
key2: "a string"
}].sort((elemN, elemNplus)=> elemNplus.key1 - elemN.key1) :: output => [{
key1: 20,
key2: "a string"
},
{
key1: 10,
key2: "a string"
}]
的所有属性必须包装在数组中,并且option
应该保留为空:
xAxis
我找到了example of an echart horizontal barchart,并删除了不会改变图表“水平度”的选项,从而找到了解决方案。然后,我将这套最少的选项与问题中给出的选项进行了比较。
答案 1 :(得分:0)
尝试一下:
var option = {
yAxis: [{
name: '',
data: ["CARH" , "CDFR" , "HGA" , "O2RG" , "SHLA" , "SHWS"]
}],
xAxis: [{
name: '',
data: ['100.29', '101.05', '100.78', '96.3', '101.8', '50']
}],
series: [{
name: '',
type: 'bar',
data: [1 , 2 , 3 , 4 , 5 , 6]
}]
};