I am currently using a Django REST API to transmit data to a VueJS front-end for display purposes. My goal is to showcase daily counts through a ChartJS graph.
import { HorizontalBar } from '../BaseCharts'
export default {
extends: HorizontalBar,
data() {
return{
}
},
mounted () {
/* The API call for fetching chart data needs to be implemented here. */
this.$store.dispatch("DailyCountAction")
this.renderChart({
labels: [this.$store.state.DailyCount],
datasets: [
{
label: 'Existing Patients',
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1,
data: [4,8,2,]
},
The "label" field in the code snippet above retrieves the data:
{
"Check_In_Count": "7",
"Average_Time_Spent": "3",
"Average_Wait_Time": "2",
"Cancelations": "0",
"New_Patient_Count": "4",
"Existing_Patient_Count": "3",
"Current_Cycle_Date": "2062019"
},
{
"Check_In_Count": "4",
"Average_Time_Spent": "8",
"Average_Wait_Time": "6",
"Cancelations": "0",
"New_Patient_Count": "1",
"Existing_Patient_Count": "3",
"Current_Cycle_Date": "2072019"
},
{
"Check_In_Count": "7",
"Average_Time_Spent": "3",
"Average_Wait_Time": "9",
"Cancelations": "0",
"New_Patient_Count": "0",
"Existing_Patient_Count": "7",
"Current_Cycle_Date": "2082019"
},
{
"Check_In_Count": "8",
"Average_Time_Spent": "8",
"Average_Wait_Time": "1",
"Cancelations": "0",
"New_Patient_Count": "4",
"Existing_Patient_Count": "4",
"Current_Cycle_Date": "2092019"
},
My objective is to extract only the Current_Cycle_Date values and convert them into an array to populate the "labels" field. I'm uncertain about the approach to achieve this.
The expected format for the "labels" field should be: labels: ['2092019', '2082019', '2072019', '2062019']
I have attempted using MAP functions in getters without success. Would it be feasible to achieve this using a Method with conditional logic?
Any suggestions or guidance on resolving this issue would be highly appreciated!