spooky$mulder
New Coder
Hello, hope this is the right place for this kind of threads.
So I am finding chart.js pretty well, but i can't handle this case:
I have a Doughnut chart with dynamic data.
Here the problem `isn't related with the elixir tags or the data itself`. Loading the page, the default datasets of the charts are `1` and `1` as my "something" is nil. Then, after hitting a button that gets data from psql, the datasets changes and this could be seen in `inspect` tool in the browser:
You can see it - 0 and 3. But the chart still remains 1-1. Doesn't change to 0-3. Why?
So I am finding chart.js pretty well, but i can't handle this case:
I have a Doughnut chart with dynamic data.
Code:
const dataDoughnut = {
labels: ["JavaScript", "Python"],
datasets: [
{
label: "My First Dataset",
data: [<%= if is_nil(something) do 1 else something %> , <%= if is_nil(something2) do 1 else something2 %>],
backgroundColor: [
"rgb(133, 105, 241)",
"rgb(164, 101, 241)",
],
hoverOffset: 4,
},
],
};
Here the problem `isn't related with the elixir tags or the data itself`. Loading the page, the default datasets of the charts are `1` and `1` as my "something" is nil. Then, after hitting a button that gets data from psql, the datasets changes and this could be seen in `inspect` tool in the browser:
Code:
const dataDoughnut = {
labels: ["JavaScript", "Python"],
datasets: [
{
label: "My First Dataset",
data: [0 , 3],
backgroundColor: [
"rgb(133, 105, 241)",
"rgb(164, 101, 241)",
],
hoverOffset: 4,
},
],
};
# other stuff
You can see it - 0 and 3. But the chart still remains 1-1. Doesn't change to 0-3. Why?