Skip to content

Commit c37b0ed

Browse files
fix: set empty title option to avoid default title (#2789)
The same null text title is part of the _baseConfig in the WC to avoid the default title from Highcharts. Fixes #2743
1 parent e37a8c3 commit c37b0ed

4 files changed

Lines changed: 42 additions & 3 deletions

File tree

‎vaadin-charts-flow-parent/vaadin-charts-flow-svg-generator/jsdom-exporter.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const inflateFunctions = (jsonConfiguration) => {
193193
const jsdomExporter = ({ chartConfiguration, outFile = 'chart.svg', exportOptions }) => {
194194
return new Promise((resolve, reject) => {
195195

196-
// Disable all animation
196+
// Disable all animation and default title
197197
Highcharts.setOptions({
198198
plotOptions: {
199199
series: {
@@ -204,7 +204,8 @@ const jsdomExporter = ({ chartConfiguration, outFile = 'chart.svg', exportOption
204204
}
205205
},
206206
credits: { enabled: false },
207-
exporting: { enabled: false }
207+
exporting: { enabled: false },
208+
title: { text : null }
208209
});
209210

210211
let isTimeline = false;

‎vaadin-charts-flow-parent/vaadin-charts-flow-svg-generator/src/test/java/com/vaadin/flow/component/charts/export/SVGGeneratorTest.java‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ public void generateSVGFromValidConfiguration()
104104
assertEquals(replaceIds(expectedSVG), replaceIds(svg));
105105
}
106106

107+
@Test
108+
public void generateSVGFromChartWithoutTitle()
109+
throws IOException, InterruptedException {
110+
Configuration conf = createColumnWithoutTitle();
111+
String svg = svgGenerator.generate(conf);
112+
Path pieChartPath = Paths.get("src", "test", "resources",
113+
"column-without-title.svg");
114+
String expectedSVG = readUtf8File(pieChartPath);
115+
assertEquals(replaceIds(expectedSVG), replaceIds(svg));
116+
}
117+
107118
@Test
108119
public void exportWithCustomWidth()
109120
throws IOException, InterruptedException {
@@ -226,6 +237,32 @@ private Configuration createPieChartConfiguration() {
226237
return conf;
227238
}
228239

240+
private Configuration createColumnWithoutTitle() {
241+
Configuration configuration = new Configuration();
242+
configuration.getChart().setType(ChartType.COLUMN);
243+
244+
configuration.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4,
245+
129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4));
246+
configuration.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5,
247+
93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3));
248+
configuration.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4,
249+
47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2));
250+
configuration.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7,
251+
52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1));
252+
253+
XAxis x = new XAxis();
254+
x.setCategories("January is a long month", "February is rather boring",
255+
"Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
256+
"Dec");
257+
configuration.addxAxis(x);
258+
259+
YAxis y = new YAxis();
260+
y.setTitle("Rainfall (mm)");
261+
configuration.addyAxis(y);
262+
263+
return configuration;
264+
}
265+
229266
private Configuration createAreaChartConfiguration() {
230267
Configuration configuration = new Configuration();
231268
configuration.setTitle("First Chart for Flow");

0 commit comments

Comments
 (0)