1

我正在使用ChartKick ruby​​ gem,想知道如何传入一个参数来调整百分比字体大小并隐藏第二个百分比的文本。

 <%= pie_chart({"Watched" => 45.9, nil => 54.1}, :library => {:colors => ["#1ac6ff", "#ECECEB"], :legend => 'none', :fontSize => '35px'}) %>

我正在引用这个并且可以通过这样做来隐藏两个百分比,pieSliceText: 'none'但无法弄清楚如何让它只适用于第二个百分比。fontSize 参数也没有调整字体大小。有什么建议么?

我希望蓝色右侧的百分比文本更大,左侧的百分比文本被隐藏。

在此处输入图像描述

4

1 回答 1

0

fontSize必须指定为数字。尝试:fontSize => 10, :fontSize => 20等,以使蓝色右侧右侧的百分比文本更大。

看起来不可能在显示另一个百分比文本时完全隐藏一个百分比文本。

以下使其显示具有不同字体的两个文本。不幸的是,将 0 设置为字体大小不起作用。

<%= pie_chart({"Watched" => 45.9, nil => 54.1}, 
    :library => {
       :legend => 'none', 
       :slices => [
         {color: "#1ac6ff", textStyle: {fontSize: 20}}, 
         {color: "#ECECEB", textStyle: {fontSize: 10}}
       ]
    }) 
%>

不同大小的字体

transparent您可以通过如下设置颜色来隐藏整个切片:

<%= pie_chart({"Watched" => 45.9, nil => 54.1}, 
       :library => {
         colors: ["#1ac6ff", "transparent"],
         legend: 'none',    
         fontSize: 20
  }) 
%>

透明切片

于 2015-03-22T01:25:06.217 回答