在显示饼图时,我会遇到数据集的所有值都为零的情况。现在,当发生这种情况时,饼图没有表现出来。相反,我想在这种情况下将文本显示为空数据。我的骨干代码如下。嗨帮助将不胜感激!
ctx = $(@el).find('#active-goals-status canvas#pie-chartcanvas')[0]
ctx.height = 100%
labels = []
values = []
$.each @status_model.get('goal_status'),(status, value)->
labels.push(status)
values.push(value)
myPieChart = new ChartNew ctx,
type: 'pie',
data:
labels: labels
datasets: [
backgroundColor: ['#DCDCDC','#FF0000','#00FF00','#FFFF00']
data: values
]
options:
responsive: true
title:
display: true,
text: ECL.t('goals_status_upcase', {default_value: 'GOAL
STATUS'})
position: 'bottom'
fontSize: 12
fontColor: '#999'
fontStyle: 'normal'
legend:
display: false
layout:
padding:
left: 0
right: 0
margin:
left: 0
right: 0