I am attempting to dynamically add values from variables to an array in order to create a bar chart using Vue.js
My initial attempt involved adding values like this: series[0]=ServiceArea1;
.
This is my current progress:
barChart: {
data: {
series [0] : ServiceArea1Total,
series [1] : ServiceArea2Total,
series [2] : ServiceArea3Total,
series [3] : ServiceArea4Total,
series [4] : ServiceArea5Total,
labels: ['Western', 'Northern', 'Eastern', 'Southern', 'Central'],
series: [ ]
}
}
When I input the values as follows:
series: [[542, 443, 320, 780, 553],]
The output displays correctly. However, since I need to fetch values from a database, I cannot hardcode them.
Below is the relevant HTML code:
<div class="row">
<div class="col-md-6">
<chart-card :chart-data="barChart.data"
:chart-options="barChart.options"
:chart-responsive-options="barChart.responsiveOptions"
chart-type="Bar">
<template slot="header">
<h4 class="card-title">Statewide Service Area Kids</h4>
<p class="card-category">Click on a service area to view more information</p>
</template>
<template slot="footer">
<div class="legend">
<i class="fa fa-circle text-info"></i> Service Area
</div>
<hr>
<div class="stats">
<i class="fa fa-check"></i> Data information certified
</div>
</template>
</chart-card>
</div>