更改 morris.js 中的默认突出显示段

Change default highlighted segment in morris.js

我正在使用 morris.js 作为圆环图。除了以下要求外,我已完成所有要求。

加载页面时默认突出显示一个段。我该如何定位并突出显示其他细分市场?

您可以使用 select 中描述的方法 Morris documentation:

Note: by default, the segment with the greatest value will be initially selected. You can change the selection using the select(index) method on the object returned by Morris.Donut.

尝试此代码段以查看工作示例:

var morrisDonut = Morris.Donut({
  element: 'donut',
  data: [
    {label: "Download Sales", value: 12},
    {label: "In-Store Sales", value: 30},
    {label: "Mail-Order Sales", value: 20}
  ],
  resize: true
});

morrisDonut.select(2);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css" rel="stylesheet"/>

<div id="donut"></div>