首页 文章

将标签添加到图表js饼图

提问于
浏览
0

我正在使用Chart.js添加饼图 . 我可以显示图表,但想显示标签,百分比和图例 .

有谁知道如何做到这一点?

这是我如何生成饼图:

dashboardRegion: (survey) ->
      male = 0
      female = 0
      survey.get('responses').each (response) ->
        if response.get('completed')
          if response.get('gender') == "male"
            male += 1
          else
            female += 1 

      genderData = [
        {
            value: male,
            color:"#9A3334",
            highlight: "#9A3334",
            label: "Male",
            labelFontFamily : "Arial",
            labelFontStyle : "normal",
            labelFontSize : 24,
            labelFontColor : "#666"
        },
        {
            value: female,
            color: "#217C7E",
            highlight: "#217C7E",
            label: "Female",
            labelFontFamily : "Arial",
            labelFontStyle : "normal",
            labelFontSize : 24,
            labelFontColor : "#666"
        }

      ];

1 回答

相关问题