Ich habe dieses Kreisdiagramm, die korrekt mit den richtigen Daten anzeigt:chart.js Coffeescript kann nicht finden, variable
# setup the pieChart
if ($("#pieChart").length)
poll_labels = []
poll_data = []
poll_colors = []
$('.option_text').each (i, obj) ->
poll_labels.push($(obj).text())
return
$('.nb_votes').each (i, obj) ->
poll_data.push($(obj).text())
poll_colors.push('#' + Math.floor(Math.random() * 16777215).toString(16))
return
data =
labels: poll_labels
datasets: [ {
data: poll_data
backgroundColor: poll_colors
hoverBackgroundColor: poll_colors
} ]
ctx = document.getElementById('pieChart')
pollPieChart = new Chart(ctx,
type: 'pie'
data: data
animation: animateRotate:true)
$('#pieChart').on 'data:update', (event, data_id, data) ->
$('.answer_option').each (i, obj) ->
if($(obj).attr('id') == ("option_" + data_id))
this.pollPieChart.data.datasets[0].data[i] = data
this.pollPieChart.update()
jedoch das data:update
Ereignis kann nicht die pollPieChart Variable finden, sie zu aktualisieren? ist es nicht in window.pollPieChart
, ich kann es unter nur pollPieChart
nicht finden. Ist die Variable nach dem neuen "verschwunden"?
hmm ich benutze ich habe gerade versucht, für sich allein diese vor der Veröffentlichung pollPieChart geschworen haben könnte. aber es funktioniert jetzt. Vielen Dank! – AntoineLev