Adding extra information to dygraph legend?

孤者浪人 提交于 2019-12-11 04:56:31

问题


Is there an easy way to be able to add extra data to the dygraph legend?

I obviously want to display the x & y data values, but the underlying data point holds extra information that I want to show to the user.

I can obviously use the callback option to find out what point has been moused over . So is the only option to use the callback and then have my own div which shows this information rather than using the dygraph legend?


回答1:


The easiest way to do this is with the legendFormatter option in the upcoming 2.0.0 release:

function legendFormatter(data) {
  if (data.x == null) return '';  // no selection
  return data.xHTML +
      data.series
      .map(v => v.labelHTML + ': ' + v.yHTML)  // modify as needed
      .join(' ');
}

new Dygraph(div, data, { legendFormatter });


来源:https://stackoverflow.com/questions/41536131/adding-extra-information-to-dygraph-legend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!