Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty datum name breaks chart generation #2807

Open
piotrp opened this issue Aug 2, 2022 · 4 comments
Open

Empty datum name breaks chart generation #2807

piotrp opened this issue Aug 2, 2022 · 4 comments
Labels

Comments

@piotrp
Copy link

piotrp commented Aug 2, 2022

Description

Bug 1: using empty string as datum name breaks chart generation ("Uncaught TypeError: box is undefined").
Bug 2: using space character (0x20) as datum name makes legend item almost unclickable:
obraz

Using empty name makes little sense, but when using external data it may appear. Currently I'm guarding against it by replacing empty string with non-breaking space (\u00a0).

Steps to check or reproduce

JSFiddle: https://jsfiddle.net/tdnp2hfv/

Running:

bb.generate({
  data: {
    columns: [
	["data1", 30, 200, 100, 400, 150, 250],
	["", 50, 20, 10, 40, 15, 25]
    ],
    type: "line"
  },
  bindto: "#lineChart"
});

Results in:

Uncaught TypeError: box is undefined
updatePositions https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:7522
updateLegendElement https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:7688
each https://d3js.org/d3.v7.min.js:2
updateLegendElement https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:7687
updateLegend https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:7128
initLegend https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:7098
initWithData https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:11270
initToRender https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:11095
runFn https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:4071
convertData https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:4362
initToRender https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:11092
init https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:11054
Chart https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:13125
generate https://naver.github.io/billboard.js/release/3.5.1/dist/billboard.js:26013
https://fiddle.jshell.net/_display/?editor_console=true:114

@netil
Copy link
Member

netil commented Aug 2, 2022

Hi @piotrp, thanks for the report. But what will be the use case of it?
Every data should have name to be distinguished among multiple data series. Is kinda counter intuitive.

@piotrp
Copy link
Author

piotrp commented Aug 2, 2022

I'm displaying values coming from server logs, e.g. counts of HTTP Referer header. Empty string is not a sane value, but it may appear, and I hit this error when testing various edge cases.

I fully agree that this is not something that should be present in data. My main issue here is that a valid string input breaks chart completely (empty string) or causes degraded user experience (space).

@netil
Copy link
Member

netil commented Aug 2, 2022

well, in that case to not break, data.idConverter option can be used.
But, unfortunately there's bug(#2808) for now. When the issue is fixed, you can handle empty data name as:

data: {
   idConverter: function(id) {
       return id === "" ? " " : id;
   }
}

@netil netil added the question label Aug 2, 2022
@piotrp
Copy link
Author

piotrp commented Aug 2, 2022

Thanks, that's certainly a better workaround, but even then an empty string shouldn't completely break the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants