0

我正在尝试用 Highcharts 表示帕累托图,如您在此处看到的
水平线显示80% 的值,但现在我想显示一条垂直线,其中 80% 水平线与“累积”图表系列相交。

这是我想要实现的一个例子: 在此处输入图像描述

有没有办法做到这一点?

另一种选择是获取“累积”样条曲线的“x”值,其中“y”值为“80”,这样我就可以手动绘制线。
这甚至可以通过Highcharts API实现吗?

我知道可以获得系列中一个点的值,但在这种情况下还不够:

var point = chart.get('accumulated').data[2];
4

2 回答 2

1

我已经找到它用于 80:20 的计算。

首先,我从样条数据中找到了大于或等于 80 的系列中的第一个值。

i.e. >= 80

假设它是DataX 然后找出数组中的那个索引加上一个 for DataX

i.e. DataX location is DataIndex = index+1

(因为数组从第 0 个计算开始需要加一)

公式是
DataX : DataIndex :: 80: ?

let the question mark is xIndexOf80

然后 xIndexOf80 = (DataIndex *80)/(DataX )。

xIndexOf80 is nothing but position of 80 on X axis.

它会在 X 轴上为您提供准确的标记

function findInetrSectionPoint(arrSplineData) {

    var intLen = arrSplineData.length;

    for (var index = 0; index < intLen; index++) {

      if (arrSplineData[index] >= 80) {

        interSectPoint = ((index + 1) * 80) / arrSplineData[index] - 1;
        break;
      }

    }

    return interSectPoint;
  }

这是Plunker

于 2015-08-31T04:27:54.733 回答
0

您可以计算 80% 点的位置,然后使用http://api.highcharts.com/highstock#Renderer rect。除此之外,您还可以检查此选项http://api.highcharts.com/highstock#Axis.addPlotLine() / http://api.highcharts.com/highstock#yAxis.plotLines

于 2013-02-13T12:49:01.333 回答