plotly / dash-daq

Control components for Dash
MIT License
141 stars 40 forks source link

gauge custom scale not applying style #40

Closed sdementen closed 3 years ago

sdementen commented 5 years ago

I am using a DAQ gauge as following

daq.Gauge(
            color={"gradient": True, "ranges": {"green": [0, 5], "yellow": [5, 7], "red": [7, 9], "black": [9, 10]}},
            value=2,
            max=10,
            min=0,
            scale={
                "custom": {
                    0.14: {"style": {"color": "red"}, "label": "Hello"},
                    4.14: {"style": {"color": "red"}, "label": "Foo"},
                    4.95: {"style": {"color": "red"}, "label": "Baz"},
                    8.12: {"style": {"color": "red"}, "label": "Jeez<br>bom"},
                }
            },
        ),

and I have the issues:

If style did work, would it be possible to have the text of the scale outside the gauge instead of inside ?

jdyerrhg commented 4 years ago

I ran into this issue too and just came across this post. After some playing around, I figured out you need "fill" instead of "color" in your custom scale styles.

Karan-S-Mittal commented 3 years ago

as mentioned by @jdyerrhg, this will be your solution. I have modified some colors

Output

chrome_aAfsu474L0

Code

daq.Gauge(
            color={"gradient": True, "ranges": {"green": [0, 5], "yellow": [5, 7], "red": [7, 9], "black": [9, 10]}},
            value=2,
            max=10,
            min=0,
            scale={
                "custom": {
                    0.14: {"style": {"fill": "red"}, "label": "Hello"},
                    4.14: {"style": {"fill": "turquoise"}, "label": "Foo"},
                    4.95: {"style": {"fill": "blue"}, "label": "Baz"},
                    8.12: {"style": {"fill": "red"}, "label": "Jeez<br>bom"},
                }
            },
        ),