在plotly.js中添加百分比符号以量规指标

问题描述

我有一个来自plotly.js的gauge,目前看起来像这样:

enter image description here

我需要在数字上添加百分比符号(在此示例中为96)。试图做到这一点:

enter image description here

我当前的数据和布局是:

var data = [{
    domain: {
      x: [0,1],y: [0,1]
    },value: 96,title: {
      text: "my title"
    },type: "indicator",mode: "gauge+number",gauge: {
      axis: {
        range: [0,100],tickwidth: 0,tickformat: "",tickcolor: "transparent"
      },bar: {
        color: "limegreen"
      },bgcolor: "purple",borderwidth: 2,bordercolor: "white",steps: [{
        range: [0,color: "grey"
      },{
        range: [0,color: "purple"
      }],threshold: {
        line: {
          color: "red",width: 4
        },thickness: 0.75,value: .75
      }
    }
  }];
  var config = {
    responsive: true,"displayModeBar": false
  }
  var layout = {
    width: 280,height: 200,margin: {
      t: 0,b: 0,l: 50,r: 50
    },paper_bgcolor: "transparent",font: {
      color: "whitesmoke",family: "Arial"
    }
  };
  Plotly.newPlot(target_id,data,layout,config)

解决方法

value: 96,下添加number: { suffix: "%" }

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...