Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion src/__tests__/pie-series.visual.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,36 @@ import React from 'react';
import {expect, test} from '@playwright/experimental-ct-react';

import {pieBasicData} from 'src/__stories__/__data__';
import type {ChartData} from 'src/types';

import {ChartTestStory} from '../../playwright/components/ChartTestStory';

test.describe('Bar-y series', () => {
test.describe('Pie series', () => {
test('Basic', async ({mount}) => {
const component = await mount(<ChartTestStory data={pieBasicData} />);
await expect(component.locator('svg')).toHaveScreenshot();
});

test('With special symbols', async ({mount}) => {
const data: ChartData = {
series: {
data: [
{
type: 'pie',
data: [
{name: 'Tom & Jerry', label: 'Tom & Jerry', value: 10},
{name: 'Tom &amp; Jerry', label: 'Tom &amp; Jerry', value: 10},
],
dataLabels: {enabled: true},
},
],
},
legend: {enabled: true},
title: {
text: 'Title: & | &amp;',
},
};
const component = await mount(<ChartTestStory data={data} />);
await expect(component.locator('svg')).toHaveScreenshot();
});
});
24 changes: 24 additions & 0 deletions src/__tests__/treemap.visual.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import {expect, test} from '@playwright/experimental-ct-react';

import {treemapBasicData} from 'src/__stories__/__data__';
import type {ChartData} from 'src/types';

import {ChartTestStory} from '../../playwright/components/ChartTestStory';

Expand All @@ -11,4 +12,27 @@ test.describe('Treemap series', () => {
const component = await mount(<ChartTestStory data={treemapBasicData} />);
await expect(component.locator('svg')).toHaveScreenshot();
});

test('With special symbols', async ({mount}) => {
const data: ChartData = {
series: {
data: [
{
type: 'treemap',
name: '& | &amp;',
data: [
{name: 'Tom & Jerry', value: 1},
{name: 'Tom &amp; Jerry', value: 1},
],
},
],
},
legend: {enabled: true},
title: {
text: 'Title: & | &amp;',
},
};
const component = await mount(<ChartTestStory data={data} />);
await expect(component.locator('svg')).toHaveScreenshot();
});
});
4 changes: 2 additions & 2 deletions src/components/Legend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const Legend = (props: Props) => {
const mods = {selected: d.visible, unselected: !d.visible};
return b('item-text', mods);
})
.text(function (d) {
.html(function (d) {
return ('name' in d && d.name) as string;
})
.style('font-size', legend.itemStyle.fontSize);
Expand Down Expand Up @@ -369,7 +369,7 @@ export const Legend = (props: Props) => {
.attr('font-size', legend.title.style.fontSize ?? null)
.attr('fill', legend.title.style.fontColor ?? null)
.style('alignment-baseline', 'before-edge')
.text(legend.title.text);
.html(legend.title.text);
}

const {left} = getLegendPosition({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Title = (props: Props) => {
...style,
}}
>
<tspan>{text}</tspan>
<tspan dangerouslySetInnerHTML={{__html: text}}></tspan>
</text>
);
};
2 changes: 1 addition & 1 deletion src/hooks/useShapes/pie/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function PieSeriesShapes(args: PreparePieSeriesArgs) {
.selectAll<SVGTextElement, PieLabelData>('text')
.data((pieData) => pieData.labels)
.join('text')
.text((d) => d.text)
.html((d) => d.text)
.attr('class', b('label'))
.attr('x', (d) => d.x)
.attr('y', (d) => d.y)
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useShapes/treemap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const TreemapSeriesShape = (props: ShapeProps) => {
.selectAll<SVGTextElement, typeof labelData>('tspan')
.data(labelData)
.join('text')
.text((d) => d.text)
.html((d) => d.text)
.attr('class', b('label'))
.attr('x', (d) => d.x)
.attr('y', (d) => d.y)
Expand Down
Loading