how to hide delta value on number+delta indicator in plotly.js?

46 views Asked by At

I'm having a hard time figuring out is there is a way to hide delta's number value on a indicator chart and only show increasing and decreasing symbol?

I went through the documentation, but doesn't look like delta object has an option to hide the number value. I'm thinking perhaps there's a way to do it with d3-format? Documentation Link: https://plotly.com/javascript/reference/indicator/#indicator-delta-valueformat

Current Config:

[
    {
        "mode": "number+delta",
        "type": "indicator",
        "delta": {
            "position": "right",
            "reference": 0,
        },
        "value": 225,
        "number": {
            "prefix": "$",
            "valueformat": ",.2f"
        }
    }
]

Below is image of when I'm trying to achieve, any pointers are much appreciated!

enter image description here

1

There are 1 answers

0
DN0300 On

I ended up using REGEX to replace the delta value in the DOM.

   let chart = document.getElementById(id);
   let deltaElement = chart.getElementsByClassName("delta");
   deltaElement[0].textContent = deltaElement[0].textContent.replace(/\d+/, "");

Shout out to @EricLavault for pointing me in this direction.