我试图让我的仪表按扇区显示颜色(即在var g1上我想要绿色0-10,橙色11-22和红色23-34).
有一个选项可以做到这一点,但没有明确的指示像我这样的新手.
任何帮助,将不胜感激.
<script> var g1 = new JustGage({ id: "score",value: <?PHP print $content['field_anger_score'][0]['#markup']; ?>,min: 0,max: 34,title: "Your Anger score",levelColorsGradient: false }); var g2 = new JustGage({ id: "passive-aggressive",value: <?PHP print $content['field_passive_aggressive_score'][0]['#markup']; ?>,max: 14,title: "Passive Aggressive" }); var g3 = new JustGage({ id: "aggressive",value: <?PHP print $content['field_aggressive_score'][0]['#markup']; ?>,max: 6,title: "Aggressive" }); var g4 = new JustGage({ id: "assertive",value: <?PHP print $content['field_assertive_score'][0]['#markup']; ?>,max: 4,title: "Assertive" }); </script>
DFG
解决方法
当你设置第一个量具(g1)时,我发现你正在使用levelColorsGradient:false.这应该根据文档来做.
文件说
choose sector-based color representation of the displayed value. It
means color will stay green for all values below 33%,yellow from 34%
up until 66%. Take it over 67% and your gauge will glow red. These
three are the default colors.
如果你想定义自己的颜色,文件说
// levelColors : string[]
// colors of indicator,from lower to upper,in RGB format
因此,创建自己的颜色变量,将下面的RGB值更改为您想要的颜色.
var myColors = [ "#a9d70b","#f9c802","#ff0000" ]
然后在设置仪表时设置此选项.
levelColors : myColors
或者如果你想将它们保存在一起,跳过变量并执行此操作.我将中间值更改为橙色.
levelColors : [ "#a9d70b","#F27C07","#ff0000" ]
仪表现在是否显示默认颜色?我不认为你可以改变行业,它们是基于百分比.