高图排序堆积的酒吧 [英] Highcharts sort stacked bar

查看:49
本文介绍了高图排序堆积的酒吧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到与在Highcharts中遇到的确切情况相匹配的解决方案,因此我将发现的信息发布在这里.

I didn't see any solutions matching the exact scenario I was hitting in Highcharts so I'm posting my find here.

我在Highcharts中有堆积的条形图,需要按最大到最小的值对条形进行排序,并保持它们的类别关系.通常,首选的解决方案是在将数据发送到Highcharts之前对数据进行排序,但这在我的方案中不是一种选择.

I have a stacked bar chart in Highcharts and needed the bars to be sorted by value greatest to smallest and maintain their category relationship. Normally the preferred solution would be to sort the data before sending it in to Highcharts but that wasn't an option in my scenario.

记下我在其中找到解决方案的原始海报

Credit to the original poster where I found the solution here

推荐答案

在所有setData操作完成后,您应该只执行一次Chart.redraw():

You should perform the Chart.redraw() only once after all setData operations are finished: http://jsfiddle.net/BlackLabel/2mLg7235/

$.each(series, function(seriesIndex, ser) {
  (...)
  ser.setData(data, false);
});
chartSource.redraw();

在您的代码中,每次setData操作后都会发生重绘.

In your code the redraw happens after every setData operation.

在我的示例中,排序功能的执行速度提高了两倍左右(这要归功于此修改).

In my example the sorting function executes two times faster or so (thanks to this modification).

这篇关于高图排序堆积的酒吧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆