jtblin / angular-chart.js

Reactive, responsive, beautiful charts for AngularJS using Chart.js: http://jtblin.github.io/angular-chart.js
Other
2.67k stars 759 forks source link

Dynamic chart type seems to be broken with bar,line #216

Closed ravitez closed 9 years ago

ravitez commented 9 years ago

Dynamic chart type doesn't seem to be working with bar,line..throws TypeError: (intermediate value)[type] is not a function Or Am I missing anything ? Here's the fiddle https://jsfiddle.net/ravitej/4Lzc2cr7/

mikedevita commented 9 years ago

seems to be broken for doughnut too :(

http://plnkr.co/edit/hdjO6CFY6aHmqR4dXICY?p=preview

danwellman commented 9 years ago

+1 any news on this? Seeing the same issue in an ng-repeat

mikedevita commented 9 years ago

I think this boiled down to a data issue for me.

Sent from my iPhone

On Oct 5, 2015, at 3:13 PM, Dan Wellman notifications@github.com wrote:

+1 any news on this? Seeing the same issue in an ng-repeat

— Reply to this email directly or view it on GitHub.

danwellman commented 9 years ago

I'm pretty sure it's not data, I'll post some actual code later, but by changing the class from chart-base to chart-doughnut, the chart worked as expected

mikedevita commented 9 years ago

Ah yes you are corrrect. I was mistaken.

Sent from my iPhone

On Oct 5, 2015, at 3:13 PM, Dan Wellman notifications@github.com wrote:

+1 any news on this? Seeing the same issue in an ng-repeat

— Reply to this email directly or view it on GitHub.

danwellman commented 9 years ago

After some testing, I find this works and produces the desired graph:

<div class="chart" ng-repeat="chart in charts">
    <canvas id="charts[$index].type" 
                  class="chart chart-doughnut" 
                  chart-data="charts[$index].data" 
                  chart-labels="charts[$index].labels">
    </canvas>
</div>

But this doesn't work:

<div class="chart" ng-repeat="chart in charts">
    <canvas id="charts[$index].type" 
                  class="chart chart-base" 
                  chart-type="charts[$index].type"
                  chart-data="charts[$index].data"
                  chart-labels="charts[$index].labels">
    </canvas>
</div>

The latter snippet results in the following console error:

TypeError: (intermediate value)[type] is not a function

draconteus commented 9 years ago

Got the same error message. I figured out, that the types start with capital letters and it worked after that. type: 'line' => type: 'Line'

danwellman commented 9 years ago

Great, thanks for the info!

jtblin commented 9 years ago

As @draconteus said, the chart type is case sensitive.

brunoserralheiro commented 8 years ago

Still does not seem to fix with capital letter.

dnadrshin commented 8 years ago

use https://github.com/gor181/react-chartjs-2 for chart v2.0