reactjs - How to align the legends in reactjs Highcharts
问题描述
Hello , the above is the image I am getting output as , but I want the output as the below image:
I want all the 1.1 together in a line all the 1.2 in a line all the 1.3 and 1.4 in a line. I have stored all these data in a map , and applying loop as , where map is the map of all the entries and xlabels are the labels for plotting the graph.
for (const entries of map.entries()) {
for (const values of entries[1].entries()) {
var dataValue = [] // array
for (const entry of values[1].entries()) {
for (var key in labelMap) {
if (key === entry[0]) {
dataValue.push(entry[1])
}
}
}
seriesDataValue.push(
{
name: entries[0] +" "+values[0],
data: dataValue,
})
}
this.setState({
options: {
series: seriesDataValue,
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'vertical',
align: 'center',
}
}
}]
},
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
width:800,
},
xAxis: {
categories: xlabels
},
}
});
Can someone please help me to get the output ? Thank you
解决方案
您需要以正确的顺序排列系列,例如使用index
属性:
series: [{
name: '1.1 wjEE',
data: [1],
index: 0
}, {
name: '1.1 w DOTNET',
data: [1],
index: 4
}, {
name: '1.1 i J2EE',
data: [1],
index: 8
}, {
name: '1.2 wjEE',
data: [1],
index: 1
}, ...]
现场演示:http: //jsfiddle.net/BlackLabel/6m4e8x0y/4893/
API 参考: https ://api.highcharts.com/highcharts/series.column.index
推荐阅读
- google-cloud-dataflow - 数据流作业 - update_if_exists?
- azure - 警告:ansible 2.10.3 不提供额外的“天蓝色”
- javascript - 通过反应性方式更新组件
- ansible - Ansible - 从动态变量中设置事实
- python - 如何替换文件中的列表?
- java - 重新启动春季批处理作业
- java - 在 Java 中执行 while 循环以捕获异常
- apache-spark - PySpark 从其数组对象值中获取相关记录
- javascript - 为蛇游戏生成一个新的随机画布点
- python - 属性错误:'dict' 对象没有属性 find_all 错误