-
Notifications
You must be signed in to change notification settings - Fork 355
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
Legend bindto page element throws error #2780
Comments
Hi @KindarConrath, can you provide reproducible code? |
If we use the TooltipTemplate example here: https://naver.github.io/billboard.js/demo/#Tooltip.TooltipTemplate // for ESM environment, need to import modules as:
// import bb, {line} from "billboard.js";
var chart = bb.generate({
data: {
columns: [
["data1", 120, 200, 300, 100, 150, 250],
["data2", 250, 129, 217, 240, 315, 225],
["data3", 100, 320, 210, 340, 215, 125]
],
type: "line", // for ESM specify as: line()
},
legend: {
contents: {
bindto: "#tooltip",
}
},
bindto: "#tooltipTemplate"
}); you will see it fail with the same error. |
@KindarConrath legend: {
contents: {
bindto: "#tooltip",
template: "<span style='color:#fff;padding:10px;background-color:{=COLOR}'>{=TITLE}</span>"
}
}, I'll be adding more detailed description on API doc. |
Add legend.contents.template value to not break when only legend.contents.bindto is specified. Ref naver#2780
# [3.6.0-next.1](3.5.1...3.6.0-next.1) (2022-09-15) ### Bug Fixes * **area:** Fix unnecessary area element generation ([d43a1a7](d43a1a7)), closes [#2826](#2826) * **axis:** fix undefined error reading generatedTicks ([4f3c101](4f3c101)), closes [#2786](#2786) * **data:** Fix idConverter error ([98f7103](98f7103)), closes [#2808](#2808) * **gauge:** Fix size mismatch w/o gauge multi label text is hidden ([6ee8a1e](6ee8a1e)), closes [#2799](#2799) * **grid:** Remove grid.y.ticks default value ([4818e44](4818e44)), closes [#2809](#2809) * **legend:** Add default for legend.contents.template ([55fbb02](55fbb02)), closes [#2780](#2780) * **type:** Add missing polar module export ([a950abd](a950abd)), closes [#2833](#2833) * **typescript:** update entry point in tsconfig ([ab4d98d](ab4d98d)), closes [#2855](#2855) * **types:** Fix the type declarations for the y tick format ([1d378e0](1d378e0)), closes [#2790](#2790) ### Features * **module:** Support dual CJS/ESM package ([437c007](437c007)), closes [#2202](#2202) * **options:** Intent to ship data.groupsZeroAs ([3de8e7a](3de8e7a)), closes [#2813](#2813) * **packages:** Intent to ship React wrapper ([4cef6ad](4cef6ad)), closes [#2838](#2838) * **plugin:** Intent to ship TableView plugin ([215b611](215b611)), closes [#1873](#1873)
# [3.6.0](3.5.1...3.6.0) (2022-09-29) ### Bug Fixes * **area:** Fix unnecessary area element generation ([d43a1a7](d43a1a7)), closes [#2826](#2826) * **axis:** fix undefined error reading generatedTicks ([4f3c101](4f3c101)), closes [#2786](#2786) * **data:** Fix idConverter error ([98f7103](98f7103)), closes [#2808](#2808) * **gauge:** Fix size mismatch w/o gauge multi label text is hidden ([6ee8a1e](6ee8a1e)), closes [#2799](#2799) * **grid:** Remove grid.y.ticks default value ([4818e44](4818e44)), closes [#2809](#2809) * **legend:** Add default for legend.contents.template ([55fbb02](55fbb02)), closes [#2780](#2780) * **type:** Add missing polar module export ([a950abd](a950abd)), closes [#2833](#2833) * **typescript:** update entry point in tsconfig ([ab4d98d](ab4d98d)), closes [#2855](#2855) * **types:** Fix legend.item.tile.type literal type typo ([de9781f](de9781f)) * **types:** Fix the type declarations for the y tick format ([1d378e0](1d378e0)), closes [#2790](#2790) * **types:** Fix the type declarations for the y tick format ([#2865](#2865)) ([2e38dee](2e38dee)) ### Features * **api:** Enhance .config() to return generation options ([455944e](455944e)), closes [#2864](#2864) * **options:** Intent to ship bar.linearGradient ([3a9989f](3a9989f)), closes [#397](#397) * **options:** Intent to ship bar.overlap ([046aedb](046aedb)), closes [#2839](#2839) * **options:** Intent to ship data.groupsZeroAs ([3de8e7a](3de8e7a)), closes [#2813](#2813) * **options:** Intent to ship legend.item.tile.type ([c379c9f](c379c9f)), closes [#2874](#2874) * **packages:** Intent to ship React wrapper ([4cef6ad](4cef6ad)), closes [#2838](#2838)
Description
The Tooltip.TooltipTemplate example shows how you can bind the tooltip to an HTML element outside the chart.
I was hoping to put my legend above the chart, but that is not an option, so I tried to bind the legend to an element above the
graph similar to how the TooltipTepmlate example did with the tooltip. This resulted in the following error message: Uncaught TypeError: Cannot read properties of null (reading 'selectAll')
Is there a way to put the Legend above the graph or to successfully attach it to an external element without causing errors?
Steps to check or reproduce
The text was updated successfully, but these errors were encountered: