billboard.js icon indicating copy to clipboard operation
billboard.js copied to clipboard

Long column names overlap in legend with equally=true

Open kmatarese opened this issue 4 years ago • 2 comments

Description

When setting legend.equally=true the legend item titles can overlap. I noticed in testing this that if all of the column names are exactly the same length it behaves better. Using equally would be really helpful for me because I can have cases with many many legend items, but the overlap issue makes it a no-go.

Steps to check or reproduce

You'll either need to add a lot of columns or shrink down your screen width, but this example reproduced it for me:

Screen Shot 2020-08-12 at 10 44 22 AM
// base css
import "billboard.js/dist/theme/insight.css";
import bb from "billboard.js";

var chart = bb.generate({
  data: {
    columns: [
    	["very long column name 1", 30, 200, 100, 400, 150, 250],
  	["very long column name 2", 130, 100, 140, 200, 150, 50],
        ["long column name 3", 130, 100, 140, 200, 150, 50],
        ["long column name 4", 130, 100, 140, 200, 150, 50],
        ["long column name 5", 130, 100, 140, 200, 150, 50],
        ["long column name 6", 130, 100, 140, 200, 150, 50],
    ],
    type: "bar"
  },
  legend: {
    equally: true,
  },
  bar: {
    width: {
      ratio: 0.5
    }
  },
  bindto: "#barChart"
});

kmatarese avatar Aug 12 '20 14:08 kmatarese

Maybe this issue is somehow attached with the #1601.

netil avatar Aug 13 '20 05:08 netil

To work around this I've started using a custom legend template, have a fixed width per legend item, and use CSS to set overflow: hidden on each item. This leads to longer items just getting truncated instead of running over each other. I then add overflow: visible on hover over the legend item so the full value is visible. I'm also no longer using equally=true though, and am relying on an external library (Vuetify) to manage the spacing via flex.

kmatarese avatar Aug 13 '20 16:08 kmatarese