I have the following JS code:
data: [40, 60, 30, 65, 60, 95, 90, 100, 96, 120, 105, 134]
This represents a curve in a graph on HTML.
I want to draw a line (same value 12 times), and this value is brought by Django.
The value is 100. I tried the following:
in Django: limit = [mylimit for i in range(1,12)]
in JS: data: {{ limit }}
didn't work.
I even tried creating the list manually on Django: limit = f"{limit}, {limit}, ...."
and doing this on JS: data: [{{ limit }}]
and nothing works.
My goal is to take whatever limit I have (aka: 100), and have the following JavaScript: data: [100, 100, 100.....
Here is the full JavaScript code:
// sales analytics Chart
let situationSocieteChart = {
labels: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jun", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"],
legend: true,
lineTension: .4,
ticksValue: 'k',
ticksColor: '#9CA3AF',
ticksFontSize: 11,
ticksFontWeight: 100,
gridBorderDash: [8, 4],
maxTicksLimit: 10,
xAxis: true,
gridColorX: NioApp.Colors.white,
gridColorY: NioApp.Colors.gray100,
gridBorderColorX: NioApp.Colors.white,
gridBorderColorY: NioApp.Colors.white,
datasets: [
{
borderWidth: 3,
color: NioApp.Colors.yellow,
backgroundGradient: NioApp.Colors.yellow,
pointBorderColor: 'transparent',
pointBackgroundColor: 'transparent',
pointHoverBackgroundColor: NioApp.Colors.yellow,
label: "Transactions",
data: [40, 60, 30, 65, 60, 95, 90, 100, 96, 120, 105, 134]
},
{
borderWidth: 2,
pointBorderColor: 'transparent',
pointBackgroundColor: 'transparent',
color: NioApp.Colors.danger,
pointHoverBackgroundColor: NioApp.Colors.danger,
label: "Plafond",
borderDash: [8, 4],
data: document.getElementById("situation") <<<<<<<<<-------------------
},
]
};