junyingg opened a new issue, #16976:
URL: https://github.com/apache/echarts/issues/16976

   ### Version
   
   5.30
   
   ### Link to Minimal Reproduction
   
   _No response_
   
   ### Steps to Reproduce
   
   Hi, I am currently replicating this[ server side rendering example provided 
for 
canvas](https://apache.github.io/echarts-handbook/en/how-to/cross-platform/server/)
 and facing this issue where I'm unable to pass in the Canvas object into the 
echarts.init function due to a type mismatch
   
   Am using nodeJS:
   
   Code portion:
   
   ```
   import * as echarts from "echarts";
   import { createCanvas } from "canvas";
   
   const canvas = createCanvas(800, 600);
     // ECharts can use the Canvas instance created by node-canvas as a 
container directly
     const chart = echarts.init(canvas);
     chart.setOption({
       xAxis: {
         type: "category",
         data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
       },
       yAxis: {
         type: "value",
       },
       series: [
         {
           data: [120, 200, 150, 80, 70, 110, 130],
           type: "bar",
         },
       ],
     });
   ```
   
   Current versions:
   
   ```
   "canvas": "^2.9.0",
   "echarts": "^5.3.0",
   ```
   
   It seems that the error is caused by type mismatch between the input and the 
accepted parameters for Typescript. Looking for anyone to advise on this issue, 
thanks!
   
   
   
   
   
   
   
   
   
   ### Current Behavior
   
   Error line:
   `const chart = echarts.init(canvas);`
   
   Error:
   ```
   Argument of type 'Canvas' is not assignable to parameter of type 
'HTMLElement'.
     Type 'Canvas' is missing the following properties from type 'HTMLElement': 
accessKey, accessKeyLabel, autocapitalize, dir, and 277 more.ts(2345)
   ```
   
   ### Expected Behavior
   
   No issue with inserting Canvas object into echarts.init function, as stated 
[here](https://apache.github.io/echarts-handbook/en/how-to/cross-platform/server/)
   
   Mentioned in the code sample
   // ECharts can use the Canvas instance created by node-canvas as a container 
directly
   
   ### Environment
   
   ```markdown
   - OS: Windows 10 Pro
   - Browser:
   - Framework: ts-node
   ```
   
   
   ### Any additional comments?
   
   _No response_


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to