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

docs(examples): Add availibility to choose between canvas and svg #448

Merged
merged 2 commits into from
Dec 30, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var myChart = echarts.init(
div,
themeManager.name, // initialize the chart with the generated theme
{
renderer: 'svg', // SVG rendered is recommended
renderer: 'svg', // SVG renderer is recommended
}
);

Expand Down
18 changes: 16 additions & 2 deletions docs/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ function generateConfigurator(id) {
<h2>Optional features</h2>
</div>

<div class="col-md-4">
<label for="rendererInput" class="form-label">SVG (recommended) 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 @@ -263,6 +271,7 @@ async function displayChart(
colors,
visualMapColor,
lineStyle,
rendererInput,
popoverInput,
popoverSharedInput,
popoverAxisInput,
Expand Down Expand Up @@ -290,6 +299,9 @@ async function displayChart(
if (!cssThemeName) {
cssThemeName = iframe.contentWindow.ODSCharts.ODSChartsCSSThemesNames.BOOSTED5;
}
if (!rendererInput) {
rendererInput = 'svg';
}
if (!popoverInput) {
popoverInput = 'tooltip';
}
Expand Down Expand Up @@ -488,7 +500,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 @@ -566,6 +578,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 @@ -583,7 +596,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 @@ -622,6 +635,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
Loading