Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Dynamically change chart type #89

Open
alamsha opened this issue Jul 10, 2017 · 1 comment
Open

Dynamically change chart type #89

alamsha opened this issue Jul 10, 2017 · 1 comment

Comments

@alamsha
Copy link

alamsha commented Jul 10, 2017

	<canvas tc-chartjs chart-type="type" chart-data="chartData" chart-options="options" chart="variable">
	</canvas>

$scope.type = 'bar';

In the above code, chart type is not changing from the controller scope. But this works perfectly in angular-chartjs. How can i change the chart type dynamically by clicking a button?. Thanks.

@abarinoff
Copy link
Contributor

abarinoff commented Aug 10, 2017

I had the same issue and solved it by wrapping type into {{}}. According to source code chart-type attribute handling differs from the one for chart-data and chart-options attributes. Directive scope is defined as follows:

scope: { data: '=chartData', options: '=chartOptions', type: '@chartType', ... }

Working code for me:

<canvas tc-chartjs chart-type="{{$ctrl.chartType}}" chart-data="$ctrl.chartData" chart-options="$ctrl.chartOptions"></canvas>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants