ChartKick在PIE和折线图中显示原始值而不是百分比 [英] ChartKick Show original value rather percentage in PIE and line chart

查看:132
本文介绍了ChartKick在PIE和折线图中显示原始值而不是百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

graph_data = {
  "Commercial"=>364,
  "Residential"=>463,
  "Hospitality"=>150,
  "Industrial"=>20,
  "Laboratory"=>1
}
pie_chart graph_data

当我将其添加到饼图中时,它将显示带有百分比的图表每个选项,我都想显示值而不是百分比,我该怎么做,

when I add this in the pie chart, it displays the chart with percentage of each option, I wan to display the value rather percentage, How i can do this,

我正在将Chartkick宝石与红宝石放在轨道上4

I'm using Chartkick gem with ruby on rails 4

推荐答案

这是我发现有效的语法:

Here is the syntax I found that worked:

<%= pie_chart @my_data, library: { pieSliceText: 'value' } %>

我在 https://stackoverflow.com/a/35199044 并成功对其进行了测试。

I found this answer over at https://stackoverflow.com/a/35199044 and tested it successfully.

这篇关于ChartKick在PIE和折线图中显示原始值而不是百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆