chart.js |如何检测折线图数据中的峰值/峰值

时间:2017-08-08 05:24:53

标签: javascript charts linechart chartjs-2.6.0

  

Chart.js 2.6.0

预期产出

我有一个问题要解决,我需要用数据生成这个图表:

enter image description here

我设法生成了这张图表。

enter image description here

问题

  • 我正在寻找检测数据山峰/峰值的最佳方法,以便我可以在顶部放置一个点(<ReferenceDataItems CodeType="AboriginalOrTorresStraitIslanderOrigin"> <Item> <CodeValue>NO</CodeValue> <CodeDescription>No</CodeDescription> <OrderNumber>1</OrderNumber> </Item> <Item> <Item> <CodeValue>TSI</CodeValue> <CodeDescription>Torres Strait Islander</CodeDescription> <OrderNumber>3</OrderNumber> </Item> <Item> <CodeValue>BOTH</CodeValue> <CodeDescription>Aboriginal and Torres Strait Islander</CodeDescription> <OrderNumber>4</OrderNumber> </Item> <Item> <CodeValue>NOTSTATED</CodeValue> <CodeDescription>Not stated/Inadequately described</CodeDescription> <OrderNumber>5</OrderNumber> </Item> </ReferenceDataItems> <ReferenceDataItems CodeType="AccommodationType"> <Item> <CodeValue>BOARDING</CodeValue> <CodeDescription>Boarding house</CodeDescription> <OrderNumber>1</OrderNumber> </Item> <Item> <CodeValue>TRANSITION</CodeValue> <CodeDescription>Crisis, emergency or transition</CodeDescription> <OrderNumber>2</OrderNumber> </Item> <Item> <CodeValue>LIVINGUNIT</CodeValue> <CodeDescription>Independent living unit</CodeDescription> <OrderNumber>3</OrderNumber> </Item> <Item> <CodeValue>COMMUNITY</CodeValue> <CodeDescription>Indigenous community/settlement</CodeDescription> <OrderNumber>4</OrderNumber> </Item> <Item> <CodeValue>INSTITUTION</CodeValue> <CodeDescription>Institutional setting (i.e. residential aged care, hospital)</CodeDescription> <OrderNumber>5</OrderNumber> </Item> <Item> <CodeValue>CLIENTOWNED</CodeValue> <CodeDescription>Private residence - client or family owned/purchasing</CodeDescription> <OrderNumber>6</OrderNumber> </Item> <Item> <CodeValue>PRIVATERENTAL</CodeValue> <CodeDescription>Private residence - private rental</CodeDescription> <OrderNumber>7</OrderNumber> </Item> <Item> <CodeValue>PUBLICRENTAL</CodeValue> <CodeDescription>Private residence - public rental</CodeDescription> <OrderNumber>8</OrderNumber> </Item> <Item> <CodeValue>PUBLICSHELTER</CodeValue> <CodeDescription>Public shelter</CodeDescription> <OrderNumber>9</OrderNumber> </Item> <Item> <CodeValue>SUPPORTED</CodeValue> <CodeDescription>Supported accommodation</CodeDescription> <OrderNumber>10</OrderNumber> </Item> <Item> <CodeValue>NOTSTATED</CodeValue> <CodeDescription>Not stated</CodeDescription> <OrderNumber>11</OrderNumber> </Item> <Item> <CodeValue>OTHER</CodeValue> <CodeDescription>Other</CodeDescription> <OrderNumber>12</OrderNumber> </Item> </ReferenceDataItems> )。
  • 有没有办法将标签放在x轴上,如上图所示?我的意思是每arc秒后都有标签。

到目前为止的代码

要点:https://gist.github.com/shivabhusal/efb48db79128ffd926cc25960a1d875c

我覆盖了21的{​​{1}}函数,并自行绘制了线条和点。

任何帮助将不胜感激,谢谢。

  

注意:我的数据不能保证在峰会上有点尖锐;有时它可以达到稳定水平。

必要的CodePen是https://codepen.io/shivabhusal/pen/LjWyMe?editors=0010

0 个答案:

没有答案