Estoy tratando de trazar un gráfico usando el gráfico JS que tiene alrededor de 300 000 puntos de datos. Funciona bastante lento, por lo que estoy tratando de mejorar su rendimiento utilizando el complemento de eliminación de datos. Sin embargo, los datos no están siendo diezmados en absoluto.
Muestra de mi código:
const dataset = { datasets: {[, data : [{ x : timetag, y : data, }], id : 'id', label: 'label', indexAxis: 'x' ,]} const config = { type: 'line', data: dataset, options: { // parsing: false, animation: false, scales : { x: { type: 'time', title: { display: true, text: 'Time Of Day'}, }, y:{ min : 0, }, }}}; const myChart = new Chart( document.getElementById("Chart"), config ); function decimateData(myChart) { myChart.options.plugins.decimation.algorithm = 'lttb'; myChart.options.plugins.decimation.enabled = true; myChart.options.plugins.decimation.samples = 50; myChart.update() } sample of the data structure [ { "x": "2022-02-24 00:00:26", "y": "11" }, { "x": "2022-02-24 00:00:27", "y": "7" }, { "x": "2022-02-24 00:00:28", "y": "8" } ]1,2,3 se cumplen creo. 4, al activar el análisis: falso en la configuración impide que mi trama funcione por completo.
¿Qué es incorrecto acerca de mi estructura de datos que no permitirá que chart js lo lea?
Cualquier orientación es muy apreciada gracias
Actualizar
Aquí está la función que usé para crear las opciones de datos en el bloque de configuración:
function genDatasets() { base = { datasets: [], parsing: false,, fill: false}; for (var i = 0; i < sources.length; i++){ set =[{ data : [{ x : timetags, y : data, }], id : sources[i].slice(0,-4), label: sources[i].slice(0,-4), borderColor: colours[i], indexAxis: 'x' ,}] base['datasets'].push(set[0]) ; } return base; };Mire la documentación sobre el parsing : https://www.chartjs.org/docs/latest/api/interfaces/ParsingOptions.html#parsing
How to parse the dataset. The parsing can be disabled by specifying parsing: false at chart options or dataset. If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.Solución: sus datos del eje x (etiquetas de tiempo) deben ser "milisegundos desde la época", que es la representación interna que usan los gráficos para el valor del tiempo. Actualmente, sus datos del eje x son una cadena de fecha, es por eso que no funciona