carlcraig / tc-angular-chartjs

AngularJS directives for Chart.js
http://carlcraig.github.io/tc-angular-chartjs/
Other
233 stars 83 forks source link

Usage inside ng-repeat? #27

Closed RPieter closed 9 years ago

RPieter commented 9 years ago

How do you use this inside a repeater? I've tried both

<div class="panel chart-box" ng-repeat="chart in stats.charts">
    <canvas tc-chartjs-line chart-options="chartoptions" chart-data="chart.data" auto-legend></canvas>
</div>

as

<div class="panel chart-box" ng-repeat="chart in stats.charts" ng-init="chartdata=chart.data">
    <canvas tc-chartjs-line chart-options="chartoptions" chart-data="chartdata" auto-legend></canvas>
</div>

but in all cases, no charts are shown (debugging shows that there is no data). Am I doing something wrong or is this not possible?

carlcraig commented 9 years ago

not sure on this, try:

<div class="panel chart-box" ng-repeat="chart in stats.charts" >
    <canvas tc-chartjs-line chart-options="chart.options" chart-data="chart.data" auto-legend>
    </canvas>
</div>

Where options and data are properties on your stats.charts objects

RPieter commented 9 years ago

sorry, my bad. in php, I returned the data-section as a nameless object. By simply adding the name-value this worked. Should have seen this far sooner!