You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2022/08/23 10:24:30 UTC

[GitHub] [echarts] iyashjayesh commented on issue #9232: Use OffScreenCanvas API for big data live charts

iyashjayesh commented on issue #9232:
URL: https://github.com/apache/echarts/issues/9232#issuecomment-1223869996

   can anyone help me to implement  web worker?
   
   Main Code:
   ```js
   dataset = "dataset" + document.getElementById("dataset").value
         const config = {
           xAxis: {
             type: 'category',
             data: Object.keys(window[dataset])
           },
           yAxis: {
             type: 'value'
           },
           series: [
             {
               data: Object.values(window[dataset]),
               type: 'line'
             }
           ]
         };
         const offscreenCanvas = document.getElementById("chart-container1");
         const worker1 = new Worker('echarts1.worker.js');
         worker1.postMessage({ canvas: offscreenCanvas, config }, [offscreenCanvas]);
   ```
   
   Web Worker (echarts1.worker.js)
   ```js
   importScripts('https://cdn.jsdelivr.net/npm/echarts@5.3.3/dist/echarts.js');
   
   onmessage = function (event) {
       console.log("Started Worker");
       const { canvas, config } = event.data;
       const chart = echarts.init(canvas);
       chart.setOption(config);
   
       console.log("Finished Worker");
   };
   ```
   
   While Executing I'm facing the below error in the console.
   
   ![127 0 0 1_5501_echarts html - Google Chrome 8_23_2022 3_52_45 PM (2)](https://user-images.githubusercontent.com/53042582/186134986-76b204c3-3eba-49d0-87b4-47e400e6ece9.png)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org