Techno-magis

Mon passage sous eCharts

Thursday 25th November 2021

Je suis passé récemment sous Apache eCharts, et j’ai eu quelques petits problèmes.

Redimensionnement

Le redimensionnement n'est pas géré automatiquement. Heureusement c'est assez simple à mettre en place.

CODE:

window.addEventListener('resize', () => {
	charts.forEach(chart => chart.resize());
});

Je mets tous mes chartes dans la liste “charts”.

Changement de langue

Importer le fichier de langue :

CODE:

<script type="text/javascript" src="path/echarts/echarts.min.js"></script>
<script type="text/javascript" src="path/echarts/i18n/langFR.min.js"></script>

Et dans le code Js, j'ai fait comme ceci :

CODE:

const chartDom = document.getElementById(graph_jour.dataset.id);
chartDom.style.height = graph_jour.dataset.height ?? '250px';
const chart = echarts.init(chartDom, null, {locale: 'FR'});
charts.push(chart);
chart.setOption( {... options } );

La “locale” doit impérativement mis en place.

Categories:
By Zéfling, the 25/11/2021 at 14:22:53
The ticket was read 82 times, with 0 comment posted.
👍 0 👎 0

No comment

Write your below.

Write a commentary