Skip to content

Commit

Permalink
[COULD BE EXTRACT IN A SEPARATE PULL REQUEST] Add availibility to tes…
Browse files Browse the repository at this point in the history
…t with canvas
  • Loading branch information
jacques-lebourgeois committed Dec 13, 2024
1 parent 7e2942d commit 258b347
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions docs/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ function generateConfigurator(id) {
<h2>Optional features</h2>
</div>
<div class="col-md-4">
<label for="rendererInput" class="form-label">SVG or Canvas (<a href="https://echarts.apache.org/handbook/en/best-practices/canvas-vs-svg/" target="apache_doc">See Apache ECharts documentation</a>)</label>
<select class="form-select" id="rendererInput" onchange="changeTheme('${id}')">
<option value="svg">SVG</option>
<option value="canvas">CANVAS</option>
</select>
</div>
<div class="col-md-4">
<label for="popoverInput" class="form-label">Popover or Tooltip</label>
<select class="form-select" id="popoverInput" onchange="changeTheme('${id}')">
Expand Down Expand Up @@ -265,6 +273,7 @@ async function displayChart(
colors,
visualMapColor,
lineStyle,
rendererInput,
popoverInput,
popoverSharedInput,
popoverAxisInput,
Expand Down Expand Up @@ -296,6 +305,9 @@ async function displayChart(
if (!cssThemeName) {
cssThemeName = iframe.contentWindow.ODSCharts.ODSChartsCSSThemesNames.BOOSTED5;
}
if (!rendererInput) {
rendererInput = 'svg';
}
if (!popoverInput) {
popoverInput = 'tooltip';
}
Expand Down Expand Up @@ -504,7 +516,7 @@ echarts.registerTheme(themeManager.name , themeManager.theme);
// get the chart holder and initiate it with the generated theme
var div = document.getElementById('${id}_chart');
var myChart = echarts.init(div, themeManager.name, {
renderer: 'svg',
renderer: '${rendererInput}',
});
// Set the data to be displayed.
Expand Down Expand Up @@ -582,6 +594,7 @@ myChart.setOption(themeManager.getChartOptions());
document.querySelector(`#accordion_${id} #darkModeInput option[value="${themeManager.options.mode}"]`).setAttribute('selected', 'selected');
document.querySelector(`#accordion_${id} #visualMapColorInput option[value="${themeManager.options.visualMapColor}"]`).setAttribute('selected', 'selected');
document.querySelector(`#accordion_${id} #lineStyleInput option[value="${themeManager.options.lineStyle}"]`).setAttribute('selected', 'selected');
document.querySelector(`#accordion_${id} #rendererInput option[value="${rendererInput}"]`).setAttribute('selected', 'selected');
document.querySelector(`#accordion_${id} #popoverInput option[value="${popoverInput}"]`).setAttribute('selected', 'selected');
document.querySelector(`#accordion_${id} #popoverSharedInput option[value="${popoverSharedInput}"]`).setAttribute('selected', 'selected');
document.querySelector(`#accordion_${id} #popoverAxisInput option[value="${popoverAxisInput}"]`).setAttribute('selected', 'selected');
Expand All @@ -599,7 +612,7 @@ myChart.setOption(themeManager.getChartOptions());
});

var myChart = iframe.contentWindow.echarts.init(div, themeManager.name, {
renderer: 'svg',
renderer: rendererInput,
});

themeManager.setDataOptions(options);
Expand Down Expand Up @@ -638,6 +651,7 @@ async function changeTheme(id) {
: document.querySelector(`#accordion_${id} #colorSetInput`).value,
document.querySelector(`#accordion_${id} #visualMapColorInput`).value,
document.querySelector(`#accordion_${id} #lineStyleInput`).value,
document.querySelector(`#accordion_${id} #rendererInput`).value,
document.querySelector(`#accordion_${id} #popoverInput`).value,
document.querySelector(`#accordion_${id} #popoverSharedInput`).value,
document.querySelector(`#accordion_${id} #popoverAxisInput`).value,
Expand Down

0 comments on commit 258b347

Please sign in to comment.