Skip to content

Unable to override default tree delimiter #1849

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

Closed
thenbe opened this issue Sep 7, 2023 · 2 comments · Fixed by #1850
Closed

Unable to override default tree delimiter #1849

thenbe opened this issue Sep 7, 2023 · 2 comments · Fixed by #1850
Labels
bug Something isn’t working

Comments

@thenbe
Copy link

thenbe commented Sep 7, 2023

The custom delimiter should replace the default delimiter, instead of being appended to it.

Repro: https://observablehq.com/d/96ac483a54482567

Code

data = [
	'foo;bar;http://www.example.com',
	'foo;bar;https://www.example.com/posts/1',
	'foo;baz;https://www.example.com/posts/2',
];

Plot.plot({
	axis: null,
	height: 100,
	margin: 10,
	marginLeft: 40,
	marginRight: 120,
	marks: [Plot.tree(data, { delimiter: ';' })],
});

Expected

In Plot.tree, declaring a custom delimiter ; should result in a tree where only ; is used as a delimiter.

Actual

In Plot.tree, declaring a custom delimiter ; results in a tree where both ; and / are used as delimiters.

@Fil Fil added the bug Something isn’t working label Sep 7, 2023
Fil added a commit that referenced this issue Sep 7, 2023
(note: I don't think this is the correct fix! But at least it gives a unit test)

closes #1849
@Fil
Copy link
Contributor

Fil commented Sep 7, 2023

Thanks for the report! See #1850 for a potential fix

@mbostock
Copy link
Member

mbostock commented Sep 7, 2023

Oh, yikes. Good report! Thank you.

mbostock pushed a commit that referenced this issue Sep 12, 2023
(note: I don't think this is the correct fix! But at least it gives a unit test)

closes #1849
mbostock added a commit that referenced this issue Sep 12, 2023
* ignore / if the delimiter is something else

(note: I don't think this is the correct fix! But at least it gives a unit test)

closes #1849

* avoid string.replaceAll

* add delimiter test

* \/ needs three (six) backslashes!

* pass tests, but still not complete

* proper escape/unescape

* refactor logic

* lift delimiter code

* tweak error message

* refactor logic slightly

---------

Co-authored-by: Mike Bostock <[email protected]>
Fil added a commit that referenced this issue Sep 13, 2023
* ignore / if the delimiter is something else

(note: I don't think this is the correct fix! But at least it gives a unit test)

closes #1849

* avoid string.replaceAll

* add delimiter test

* \/ needs three (six) backslashes!

* pass tests, but still not complete

* proper escape/unescape

* refactor logic

* lift delimiter code

* tweak error message

* refactor logic slightly

---------

Co-authored-by: Mike Bostock <[email protected]>
chaichontat pushed a commit to chaichontat/plot that referenced this issue Jan 14, 2024
* ignore / if the delimiter is something else

(note: I don't think this is the correct fix! But at least it gives a unit test)

closes observablehq#1849

* avoid string.replaceAll

* add delimiter test

* \/ needs three (six) backslashes!

* pass tests, but still not complete

* proper escape/unescape

* refactor logic

* lift delimiter code

* tweak error message

* refactor logic slightly

---------

Co-authored-by: Mike Bostock <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants