charts

minimum height to a chart


I have made a bar char which have two columns per category. Does anyone know how to set a minimum height for column?

I wanted it to have a minimum pixel height in value as sometimes the data varies and you can only see very little of the value depending on how it is rendered on the ranges.


Solution

  • You could add an additional transform like this:

    {"type": "formula", "expr": "datum.value2 < 0 && datum.value2 > -1 ? -1: datum.value2 > 0 && datum.value2 < 1 ? 1: datum.value2", "as": "value2"}
    

    So:

    If the value is between -1 and 0 then it will be: -1

    If the value is between 0 and 1 it will be: 1

    Also add a note at the bottom of the chart because it can be misleading:)