简体   繁体   English

在旧版浏览器中显示sankey

[英]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.

相关问题 浏览器缓存-版本文件-但是如果浏览器使用旧版本怎么办? - Browser cache - versioning files - but what if browser uses old version? 如何在旧版浏览器中获取输入文件的数据 - How to get input file 's data in old version browser 使用git push更新网站,浏览器仍会加载旧的缓存版本 - Updating site with git push, browser still loads old cached version Sankey:在sankey之外显示标签并提供拖放功能 - Sankey: Display label outside of sankey and provide drag & drop functionality 浏览器不显示 JavaScript 中的更改。它保留旧版本 - Browser does not show changes in JavaScript. It keeps the old version 加载新版本后,Service Worker 可能会显示旧版本的应用程序的情况? - Situations in which service worker may display old version of app even after new version is loaded? 在AngularJS中检测浏览器类型和版本,如果不支持,则显示一条消息 - Detect browser type and version in AngularJS and display a message if is not supported d3-sankey 按组显示并拖动不起作用 - d3-sankey display by groups and drag doesn't work NPM 版本太旧 - Version too old of the NPM 在 R 中,如何在 Sankey Graph 的链接/路径上显示值? - In R, how to display value on the links/paths of Sankey Graph?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM