0

Here is my code (basically you can find the same thing in html dash documents) I would like to make something similar to this: As you can see there are different segments which are named, and below the gauge there is also a segment name.

enter image description here

import dash_daq as daq

daq.Gauge(
    color={"gradient":True,"ranges":{"green":[0,6],"yellow":[6,8],"red":[8,10]}},
    value=2,
    label='Default',
    max=10,
    min=0,
)

currently i have this

enter image description here

Balázs Patai
  • 105
  • 1
  • 9
  • I'm not sure you can do this. Let's say you have small, medium, and large. If you give a 1 to small, 2 to medium, and 3 to large, it kind of makes sense. What if you have apple, pear, and pumpkin. If you give a 1 to apple, 2 to pear, and 3 to banana, does it mean the banana is 3x larger than an apple, or 3x better than an apple, is that correct? No. I'd love to hear what other people think about this. – ASH Sep 22 '21 at 01:53
  • 2
    Have you tried to define a scale with custom dict where the keys are the hauge values and the vales are the custom stringa, that is strong sell, sell, etc. – bpgergo Sep 22 '21 at 18:59

1 Answers1

1

Basic implementation of bpgergo's suggestion of using the scale property.

from dash import Dash, html, dcc
import dash_bootstrap_components as dbc
from dash.dependencies import Output, Input
import dash_daq as daq

app = Dash(__name__)
app.layout = daq.Gauge(
    color={
        "ranges": {
            "red": [0, 2],
            "pink": [2, 4],
            "#ADD8E6": [4, 6],
            "#4169E1": [6, 8],
            "blue": [8, 10],
        },
    },
    scale={
        "custom": {
            1: {"label": "Strong Sell"},
            3: {"label": "Sell"},
            5: {"label": "Neutral"},
            7: {"label": "Buy"},
            9: {"label": "Strong Buy"},
        }
    },
    value=2,
    max=10,
    min=0,
)

if __name__ == "__main__":
    app.run_server()

Result

custom-gauge

You can also hide the ticks with css

.tick {
  display: none;
}
5eb
  • 14,798
  • 5
  • 21
  • 65