cancel
Showing results for 
Search instead for 
Did you mean: 

create a bar graph viz:bar using dynamic data

krushii
Explorer
0 Kudos
268

Hello team,

creating a Example Like " https://stackoverflow.com/questions/69455760/chart-js-data-values-from-textbox-input-only-load-once "

the problem is in controller.js "Uncaught ReferenceError: Chart is not defined"

Here is my controller code

crtGraph: function(oEvent) {

var R = this.getView().byId("IdRed").getValue("");

var B = this.getView().byId("IdBlue").getValue("");

var G = this.getView().byId("IdGreen").getValue("");

if (Chart.getChart("myChart") === undefined) {

var ctx = this.getView().byId("myChart").getContext("2d");

myChart = new Chart(ctx, {

type: "bar",

data: {

labels: ["Red", "Blue", "Green"],

datasets: [{

label: "# of Votes",

data: [R, B, G],

backgroundColor: [

"rgba(255, 99, 132, 0.2)",

"rgba(54, 162, 235, 0.2)",

"rgba(255, 206, 86, 0.2)"

],

borderColor: [

"rgba(255, 99, 132, 1)",

"rgba(54, 162, 235, 1)",

"rgba(255, 206, 86, 1)"

],

borderWidth: 1

}]

},

options: {

scales: {

y: {

beginAtZero: true

}

}

}

});

} else {

myChart.data.datasets[0].data = [R, B, G];

myChart.update();

}

}

Accepted Solutions (0)

Answers (0)