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

fix(core): title string contains html ascii characters #547

Merged
merged 6 commits into from
Apr 9, 2020
Merged
4 changes: 2 additions & 2 deletions packages/core/demo/data/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const lineData = {
]
},
{
label: "Dataset 6",
label: "Dataset's 6",
data: [
0,
20000,
Expand All @@ -65,7 +65,7 @@ export const lineData = {
};

export const lineOptions = {
title: "Line (discrete)",
title: "Line (discrete) - long long long long long long long long long long long long long long time format ('MMM d, hh a and 'hh a')",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should just keep this short like before. as long as it works we're good

axes: {
bottom: {
title: "2018 Annual Sales Figures",
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/components/essentials/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ export class Title extends Component {
const substringIndex = this.getSubstringIndex(title.node(), 0, titleString.length - 1, truncatedSize);

// use the substring as the title
title.text(titleString.substring(0, substringIndex - 1))
title.html(titleString.substring(0, substringIndex - 1))
.append("tspan")
.text("...");

// add events for displaying the tooltip with the title
const self = this;
title
.on("mouseenter", function() {
.on("mouseenter", function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.on("mouseenter", function () {
.on("mouseenter", function() {

self.services.events.dispatchEvent("show-tooltip", {
hoveredElement: title,
type: TooltipTypes.TITLE
});
})
.on("mouseout", function() {
.on("mouseout", function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.on("mouseout", function () {
.on("mouseout", function() {

self.services.events.dispatchEvent("hide-tooltip", {
hoveredElement: title,
hoveredElement: title
});
});
}
Expand All @@ -62,7 +62,7 @@ export class Title extends Component {
const text = DOMUtils.appendOrSelect(svg, "text.title");
text.attr("x", 0)
.attr("y", 20)
.text(this.model.getOptions().title);
.html(this.model.getOptions().title);

// title needs to first render so that we can check for overflow
this.truncateTitle();
Expand Down