Angular UI-Grid and D3 graph in a row

做~自己de王妃 提交于 2019-12-05 02:34:35

问题


I am wondering if any of you had any experience with injecting a graph into a ui-grid. What I am doing, is I have a row defined as follows:

  { name:'Column Name', cellTemplate: '<spark-line-chart values="grid.appScope.valuesStacked"></spark-line-chart>'}

Spark-line-chart directive is responsible for creating a D3 chart (actually, nvd3 to be precise). This creates svg graph.

Now, each time I am trying to sort my table, all of the values within the table get sorted, apart from the graphs. So far, I am mocking up data, and use one array of values for all of the graphs.

Anyone had similar issues, and knows the answer to this question?


回答1:


At first which kind of Angular module for nvd3.js are you using?

If you use angular-nvd3 you can check this example:

http://plnkr.co/edit/XESqEPwfXF3ulQkfuBOE

Pay attention that in your cell templates you must wrap the nvd3 graphic inside a <DIV> with .ui-grid-cell-contents CSS class:

<div class="ui-grid-cell-contents">
  <nvd3 options="row.entity.spark.options" data="row.entity.spark.data"></nvd3>
</div>


来源:https://stackoverflow.com/questions/34809128/angular-ui-grid-and-d3-graph-in-a-row

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