[英]Display sankey in old browser version
I have problem with sorting sankey diagram in older version borwser - Chrome v49. 我在旧版本的浏览器-Chrome v49中对sankey图进行排序时遇到问题。 My chart looks like this: sankey 我的图表如下所示: sankey
How to present sankey on familiar design in older borwser? 如何在老钻匠的熟悉设计中展示sankey? In jsfiddle in newer browser version charts looks correctly. 在jsfiddle中,较新的浏览器版本图表看起来正确。 I've implemented sorting function but it doesn't work in older browser. 我已经实现了排序功能,但是在较旧的浏览器中无法使用。 My jsfiddle 我的jsfiddle
function sortData(fixedData) {
return fixedData.sort((a, b) => b[2] - a[2]);
}
//const sortedData = sortData(fixedData);
const chart = Highcharts.chart('container', {
title: {
text: 'Highcharts Sankey Diagram'
},
series: [{
keys: ['from', 'to', 'weight'],
data: fixedData,
type: 'sankey',
name: 'Sankey demo series'
}]
});
I'll be grateful for any solutions! 我将不胜感激!
EDIT 编辑
So my script exactly look like this 所以我的脚本看起来像这样
Correctly works in OPERA v58 . 在OPERA v58中正确工作。 Doesn't correctly works in CHROME v49 在CHROME v49中无法正常工作
You need to sort your data by the sum of the values from the same name, not by individual values: 您需要根据同名值的总和而不是单个值对数据进行排序:
const fixedData = [
...
];
let sum;
fixedData.forEach(function(el1) {
sum = 0;
fixedData.forEach(function(el2) {
if (el2[0] === el1[0]) {
sum += el2[2]
}
});
el1.push(sum);
});
function sortData(arr) {
return [...arr].sort(function(b, a) {
return b[3] - a[3]
});
}
Live demo: http://jsfiddle.net/BlackLabel/td1ob0wg/ 现场演示: http : //jsfiddle.net/BlackLabel/td1ob0wg/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.