Display text inside bar in bar chart with Chartist.js

懵懂的女人 提交于 2019-12-11 04:56:17

问题


So, I'm trying to display some text inside the actual bars of a bar chart using Chartist.js charts. The end result should look something like this:

Which property do I need to set in order to get the text inside the bars?


回答1:


I would use chartist-bar-labels it should provide what you are looking for, with it you can add the following code:

Chartist.plugins.ctBarLabels({
      position: {
        x: function (data) {
          return data.x1 + 50
        }
      },
      labelOffset: {
        y: 7
      },
      labelInterpolationFnc: function (text) { //<--- this adds text to your bards
        return text + '%' 
      }
    })


来源:https://stackoverflow.com/questions/42348622/display-text-inside-bar-in-bar-chart-with-chartist-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!