javascript - canvas chart height AngularJS -


i want render chart in angularjs

this part of html code chart:

<div style="overflow: auto;">     <div id="parentdivchart" style="{{changewidth()}}; height:350px;">         <canvas id="bar"  class="chart chart-bar" chart-data="datta" chart-labels="labels" chart-legend="true">         </canvas>     </div> </div> 

and controller function changewidth():

function changewidth(trendvalues) {     elem = document.getelementbyid('parentdivchart');     elem.style.width = $scope.values.length*20 +"px"; } 

the idea want able change width dynamically according data receive. when fix height 350px canvas not inherit value , instead stretches canvas , sets value height not suitable. me ? why canvas not inherit parent divs height, inherit width changes. how set fixed height canvas ?

thanks in advance!

along elem.style.width = $scope.values.length*20 +"px"; use elem.setattribute('width', $scope.values.length*20);.

this because canvas element depends on width attribute , not width style width of drawing area.

reference


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -