5
Guys I’m developing an application that helps me build graphics, and I was thinking about doing it in a way where the graph is built dynamically as the user inserts information, the first of them would be the type of chart (if it’s line, bar, pizza, etc.) I made a test with fixed values and the graph is generated perfectly, so I started to make it dynamic, but when I choose the type of graph the system does not update with the exchange of classes, it follows my code:
Controller
$scope.grafico = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
series: ['Series A', 'Series B'],
data: [
[65, 59, 80, 81, 56, 55, 40],
[28, 48, 40, 19, 86, 27, 90]
]
}
$scope.tipoGrafico = "";
HTML
<div class="bloco grafico">
<canvas
class="chart {{tipoGrafico}}"
chart-data="grafico.data"
chart-labels="grafico.labels"
chart-series="grafico.series"
chart-legend="false">
</canvas>
</div>
<label>
Tipo de Gráfico
<select ng-model="tipoGrafico">
<option value="chart-line">Linha</option>
<option value="chart-bar">Barra</option>
<option value="chart-pie">Pizza</option>
</select>
</label>
I’m a novice at angular programming so any criticism of the code or suggestion of some other way to do what I want is always welcome! thank you in advance