Skip to content

Commit 33a9d40

Browse files
feat: update to latest Highcharts (#2433)
* feat: bump Highcharts version Add missing updates from highcharts.css Add workaround for HC issue * test: update tests to latest dom structure of HC * test: fix post stub causing failure in FF
1 parent f7990dc commit 33a9d40

6 files changed

Lines changed: 58 additions & 24 deletions

File tree

‎packages/vaadin-charts/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@vaadin/vaadin-element-mixin": "^22.0.0-alpha5",
3030
"@vaadin/vaadin-license-checker": "^2.1.0",
3131
"@vaadin/vaadin-themable-mixin": "^22.0.0-alpha5",
32-
"highcharts": "8.1.2"
32+
"highcharts": "9.2.2"
3333
},
3434
"devDependencies": {
3535
"@esm-bundle/chai": "^4.3.4",

‎packages/vaadin-charts/test/chart-element.test.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('vaadin-chart', () => {
4444
chart.setAttribute('title', 'Custom title');
4545
document.body.appendChild(chart);
4646
await oneEvent(chart, 'chart-load');
47-
const title = chart.$.chart.querySelector('.highcharts-title > tspan');
47+
const title = chart.$.chart.querySelector('.highcharts-title');
4848
expect(title).to.be.ok;
4949
expect(title.textContent).to.equal('Custom title');
5050
});
@@ -53,7 +53,7 @@ describe('vaadin-chart', () => {
5353
chart.updateConfiguration({ title: { text: 'Awesome chart' } });
5454
document.body.appendChild(chart);
5555
await oneEvent(chart, 'chart-load');
56-
expect(chart.$.chart.querySelector('.highcharts-title > tspan').textContent).to.equal('Awesome chart');
56+
expect(chart.$.chart.querySelector('.highcharts-title').textContent).to.equal('Awesome chart');
5757
});
5858

5959
it('should support adding chart series', async () => {
@@ -81,7 +81,7 @@ describe('vaadin-chart', () => {
8181
it('should set chart title using configuration', () => {
8282
config.setTitle({ text: 'Custom title' });
8383

84-
const title = chart.$.chart.querySelector('.highcharts-title > tspan');
84+
const title = chart.$.chart.querySelector('.highcharts-title');
8585
expect(title).to.be.ok;
8686
expect(title.textContent).to.equal('Custom title');
8787
});
@@ -119,7 +119,7 @@ describe('vaadin-chart', () => {
119119
it('should set chart title using update', async () => {
120120
chart.updateConfiguration({ title: { text: 'Custom title' } });
121121
await oneEvent(chart, 'chart-redraw');
122-
const title = chart.$.chart.querySelector('.highcharts-title > tspan');
122+
const title = chart.$.chart.querySelector('.highcharts-title');
123123
expect(title).to.be.ok;
124124
expect(title.textContent).to.equal('Custom title');
125125
});
@@ -352,16 +352,16 @@ describe('vaadin-chart', () => {
352352
it('should apply configuration update when attached to a new parent', async () => {
353353
chart.updateConfiguration({ title: { text: 'Awesome title' }, credits: { enabled: false } });
354354
await oneEvent(chart, 'chart-redraw');
355-
expect(chart.$.chart.querySelector('.highcharts-title > tspan').textContent).to.equal('Awesome title');
355+
expect(chart.$.chart.querySelector('.highcharts-title').textContent).to.equal('Awesome title');
356356
expect(chart.$.chart.querySelector('.highcharts-credits')).to.be.null;
357357

358358
wrapper.removeChild(chart);
359359
chart.updateConfiguration({ subtitle: { text: 'Awesome subtitle' }, credits: { enabled: true, text: 'Vaadin' } });
360360

361361
inner.appendChild(chart);
362362
await oneEvent(chart, 'chart-redraw');
363-
expect(chart.$.chart.querySelector('.highcharts-title > tspan').textContent).to.equal('Awesome title');
364-
expect(chart.$.chart.querySelector('.highcharts-subtitle > tspan').textContent).to.equal('Awesome subtitle');
363+
expect(chart.$.chart.querySelector('.highcharts-title').textContent).to.equal('Awesome title');
364+
expect(chart.$.chart.querySelector('.highcharts-subtitle').textContent).to.equal('Awesome subtitle');
365365
expect(chart.$.chart.querySelector('.highcharts-credits').textContent).to.equal('Vaadin');
366366
});
367367
});

‎packages/vaadin-charts/test/chart-properties.test.js‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ describe('vaadin-chart properties', () => {
1818
});
1919

2020
it('should have custom subtitle', () => {
21-
expect(chartContainer.querySelector('.highcharts-subtitle > tspan').textContent).to.be.equal('My subtitle');
21+
expect(chartContainer.querySelector('.highcharts-subtitle').textContent).to.be.equal('My subtitle');
2222
});
2323

2424
it('should not reset subtitle on update', async () => {
2525
chart.updateConfiguration({ title: { text: 'Awesome chart' } });
2626
await oneEvent(chart, 'chart-redraw');
27-
expect(chartContainer.querySelector('.highcharts-title > tspan').textContent).to.equal('Awesome chart');
28-
expect(chartContainer.querySelector('.highcharts-subtitle > tspan').textContent).to.equal('My subtitle');
27+
expect(chartContainer.querySelector('.highcharts-title').textContent).to.equal('Awesome chart');
28+
expect(chartContainer.querySelector('.highcharts-subtitle').textContent).to.equal('My subtitle');
2929
});
3030
});
3131

@@ -75,19 +75,21 @@ describe('vaadin-chart properties', () => {
7575
});
7676

7777
it('should not overwrite top-level element properties', () => {
78-
expect(chartContainer.querySelector('.highcharts-title > tspan').textContent).to.be.equal('My title');
78+
expect(chartContainer.querySelector('.highcharts-title').textContent).to.be.equal('My title');
7979
});
8080

8181
it('should react to additionalOptions object change', async () => {
8282
chart.additionalOptions = { title: { text: 'Updated title' } };
8383
await oneEvent(chart, 'chart-redraw');
84-
expect(chartContainer.querySelector('.highcharts-title > tspan').textContent).to.be.equal('Updated title');
84+
// await oneEvent(chart, 'chart-redraw');
85+
expect(chartContainer.querySelector('.highcharts-title').textContent).to.be.equal('Updated title');
8586
});
8687

8788
it('should react to additionalOptions sub property change', async () => {
8889
chart.set('additionalOptions.title.text', 'Reindeer statistics');
8990
await oneEvent(chart, 'chart-redraw');
90-
expect(chartContainer.querySelector('.highcharts-title > tspan').textContent).to.be.equal('Reindeer statistics');
91+
// await oneEvent(chart, 'chart-redraw');
92+
expect(chartContainer.querySelector('.highcharts-title').textContent).to.be.equal('Reindeer statistics');
9193
});
9294
});
9395

@@ -497,7 +499,7 @@ describe('vaadin-chart properties', () => {
497499

498500
it('should show a message when emptyText property is set', () => {
499501
chart.emptyText = 'Empty Vaadin Chart';
500-
const message = chart.$.chart.querySelector('.highcharts-no-data > text > tspan');
502+
const message = chart.$.chart.querySelector('.highcharts-no-data > text');
501503
expect(message.textContent).to.be.equal(chart.emptyText);
502504
});
503505
});
@@ -520,7 +522,7 @@ describe('vaadin-chart properties', () => {
520522
const series = chart.querySelectorAll('vaadin-chart-series');
521523
series.forEach((element) => chart.removeChild(element));
522524
await oneEvent(chart, 'chart-redraw');
523-
const message = chart.$.chart.querySelector('.highcharts-no-data > text > tspan');
525+
const message = chart.$.chart.querySelector('.highcharts-no-data > text');
524526
expect(message.textContent).to.be.equal('Empty Vaadin Chart');
525527
});
526528

@@ -529,7 +531,7 @@ describe('vaadin-chart properties', () => {
529531
chart.removeChild(series[0]);
530532
chart.removeChild(series[1]);
531533
await oneEvent(chart, 'chart-redraw');
532-
const message = chart.$.chart.querySelector('.highcharts-no-data > text > tspan');
534+
const message = chart.$.chart.querySelector('.highcharts-no-data > text');
533535
expect(message.textContent).to.be.equal('Empty Vaadin Chart');
534536
});
535537
});

‎packages/vaadin-charts/test/exporting.test.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styl
55
import { fixtureSync, oneEvent, nextRender } from '@vaadin/testing-helpers';
66
import { chartDefaultTheme } from '../theme/vaadin-chart-default-theme.js';
77
import Highcharts from 'highcharts/es-modules/masters/highstock.src.js';
8+
import HttpUtilities from 'highcharts/es-modules/Core/HttpUtilities.js';
9+
810
import '../vaadin-chart.js';
911

1012
const chart = css`
@@ -55,7 +57,7 @@ describe('vaadin-chart exporting', () => {
5557

5658
before(() => {
5759
// Prevent form submit
58-
sinon.stub(Highcharts, 'post');
60+
sinon.stub(HttpUtilities, 'post');
5961
// Hook into Highcharts events
6062
fireEventSpy = sinon.spy(Highcharts, 'fireEvent');
6163
});
@@ -90,7 +92,7 @@ describe('vaadin-chart exporting', () => {
9092
observer.observe(document.body, { childList: true });
9193

9294
// Reveal exporting menu items
93-
chartContainer.querySelector('.highcharts-contextbutton').onclick();
95+
chartContainer.querySelector('button.highcharts-a11y-proxy-button.highcharts-no-tooltip').click();
9496

9597
// Simulate a PNG export
9698
const pngExportButton = chartContainer.querySelectorAll('.highcharts-menu-item')[2];
@@ -119,7 +121,7 @@ describe('vaadin-chart exporting', () => {
119121
observer.observe(document.body, { childList: true });
120122

121123
// Reveal exporting menu items
122-
chartContainer.querySelector('.highcharts-contextbutton').onclick();
124+
chartContainer.querySelector('button.highcharts-a11y-proxy-button.highcharts-no-tooltip').click();
123125

124126
// Simulate a PNG export
125127
const pngExportButton = chartContainer.querySelectorAll('.highcharts-menu-item')[2];

‎packages/vaadin-charts/theme/vaadin-chart-default-theme.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const chartDefaultTheme = css`
2828
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
2929
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Helvetica, sans-serif;
3030
font-size: 12px;
31+
user-select: none;
32+
touch-action: manipulation;
33+
outline: none;
3134
}
3235
3336
.highcharts-container svg {
@@ -202,6 +205,12 @@ const chartDefaultTheme = css`
202205
stroke-linejoin: round;
203206
}
204207
208+
.highcharts-empty-series {
209+
stroke-width: 1px;
210+
fill: none;
211+
stroke: #cccccc;
212+
}
213+
205214
.highcharts-state-hover .highcharts-graph {
206215
stroke-width: 3;
207216
}
@@ -790,6 +799,21 @@ const chartDefaultTheme = css`
790799
fill: #fff;
791800
}
792801
802+
.highcharts-hollowcandlestick-series .highcharts-point-down {
803+
fill: #f21313;
804+
stroke: #f21313;
805+
}
806+
807+
.highcharts-hollowcandlestick-series .highcharts-point-down-bearish-up {
808+
fill: #06b535;
809+
stroke: #06b535;
810+
}
811+
812+
.highcharts-hollowcandlestick-series .highcharts-point-up {
813+
fill: transparent;
814+
stroke: #06b535;
815+
}
816+
793817
.highcharts-ohlc-series .highcharts-point-hover {
794818
stroke-width: 3px;
795819
}
@@ -979,6 +1003,12 @@ const chartDefaultTheme = css`
9791003
:host([dir='rtl']) .highcharts-menu {
9801004
box-shadow: -3px 3px 10px #888;
9811005
}
1006+
1007+
/* https://github.com/highcharts/highcharts/issues/16282 */
1008+
/* without this __mutationCallback always calls __reflow */
1009+
ul[aria-hidden='false'] {
1010+
margin: 0px;
1011+
}
9821012
`;
9831013

9841014
registerStyles('vaadin-chart', chartDefaultTheme, { moduleId: 'vaadin-chart-default-theme' });

‎yarn.lock‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6095,10 +6095,10 @@ header-case@^2.0.4:
60956095
capital-case "^1.0.4"
60966096
tslib "^2.0.3"
60976097

6098-
highcharts@8.1.2:
6099-
version "8.1.2"
6100-
resolved "https://registry.yarnpkg.com/highcharts/-/highcharts-8.1.2.tgz#a4e7d74a6140028e676a3a54f5fd0ea6ccbcc90e"
6101-
integrity sha512-Q124Lj+2+bVY2MKMd7d8uSVAmhZVzWgknUUzUBEC27S94dCyK6PBgahuwiMP/ET4w7qSFBBi4OC77ZUb0Vnuyg==
6098+
highcharts@9.2.2:
6099+
version "9.2.2"
6100+
resolved "https://registry.yarnpkg.com/highcharts/-/highcharts-9.2.2.tgz#4ace4aa7c4d2b4051115d9be70bfd2038559d656"
6101+
integrity sha512-OMEdFCaG626ES1JEcKAvJTpxAOMuchy0XuAplmnOs0Yu7NMd2RMfTLFQ2fCJOxo3ubSdm/RVQwKAWC+5HYThnw==
61026102

61036103
homedir-polyfill@^1.0.1:
61046104
version "1.0.3"

0 commit comments

Comments
 (0)