I'm currently in the process of integrating a Google line chart and attempting to incorporate variable values. However, I've encountered an issue where replacing numeric values with JS variables results in them evaluating to 0.
Here's my JavaScript code:
import { GChart } from 'vue-google-charts'
export default {
name: 'linegraph',
props: ['dates', 'stats'],
data() {
return {
test: 5,
items: {
},
chartData: [
['Date', 'Items Sold'],
[this.dates.monday, 1],
[this.dates.tuesday, 50],
[this.dates.wednesday, 3],
[this.dates.thursday, 2],
[this.dates.friday, 6],
[this.dates.saturday, 8],
[this.dates.sunday, parseInt(this.test)]
],
chartOptions: {
width: 600,
height: 400,
curveType: 'function',
legend: { position: 'bottom' },
animation: {
duration: 1000,
easing: 'inAndOut',
startup: true
},
colors: ['#74D698'],
}
}
},
I've experimented with various methods like leaving the variable as is, wrapping it in parseFloat, parseInt, number(), etc. Unfortunately, none of these solutions are working, nor are they generating any errors. I would greatly appreciate any assistance or suggestions. Thank you! :)