Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Add two values statically into Y axis, which will always stay there

I have a chart with two Y axises. Left one is for numeric values and right one is for binary values - true or false.

How can I insert “true” and “false” value into the second y axis? Without data values etc. Just statically.

At this moment, it works almost fine. But the one problem is, that at first cycle of loading data, only one binary value appears on the axis, according which one came from server response first.

For example, if in the first response binary value is “false”, only “false” appears on the axis. And the another one value “true” appears only when it comes from server. If server doesn’t returns “true”, it never shows in the plot, on the axis. So this is not really good.

I want to make them stay there for good, before loading data.

My code for the Axis with binaries:

this.chartLayout = {
    yaxis2: {
        titlefont: {color: '#000'},
        tickfont: {color: '#aa00ff'},
        overlaying: 'y',
        side: 'right',
        showticklabels: true,
        gridcolor: '#eeccff'
    }
};

Thank you!

This what happens, when opposite value doesn’t come from the server. Only one value is appearing on the axis - “false”.

Unsetting the yaxis2 autorange with

this.chartLayout.yaxis2.range = [0, 1]

should do the trick.

Thank you my dear friend, but it didn’t help. It just narrowed my chart. Look at the image:

I expect it to look like:

this.chartLayout = {
  yaxis2: {
    titlefont: {
        color: '#000'
    },
    tickfont: {
        color: '#aa00ff'
    },
    overlaying: 'y',
    side: 'right',
    showticklabels: true,
    gridcolor: '#eeccff',
    axisvalues: ['false', 'true']    //something like this <---=
}
};

Topic refresh. I still have problems with adding these values statically into Y axis. :frowning: