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/05/04 09:27:14 UTC
[GitHub] [echarts] junyingg opened a new issue, #16976: [Bug] Cannot pass Canvas object into echarts.init in Typescript nodeJS
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: commits-unsubscribe@echarts.apache.org.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
[GitHub] [echarts] dmeehan1968 commented on issue #16976: [Bug] Cannot pass Canvas object into echarts.init in Typescript nodeJS
Posted by GitBox <gi...@apache.org>.
dmeehan1968 commented on issue #16976:
URL: https://github.com/apache/echarts/issues/16976#issuecomment-1135108248
@types/echarts seems to be at v4.9.15, whilst echarts is at v5.3.2.
You can workaround by casting
```
const chart = echarts.init(canvas as unknown as HTMLCanvasElement);
```
This also goes for using SVG for the output type:
```
this.chart = echarts.init(null as unknown as HTMLCanvasElement, undefined, {
renderer: 'svg',
ssr: true,
width: 400,
height: 300
});
```
--
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
Re: [I] [Bug] Cannot pass Canvas object into echarts.init in Typescript nodeJS [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #16976: [Bug] Cannot pass Canvas object into echarts.init in Typescript nodeJS
URL: https://github.com/apache/echarts/issues/16976
--
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
Re: [I] [Bug] Cannot pass Canvas object into echarts.init in Typescript nodeJS [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #16976:
URL: https://github.com/apache/echarts/issues/16976#issuecomment-2125742094
This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.
--
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
Re: [I] [Bug] Cannot pass Canvas object into echarts.init in Typescript nodeJS [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #16976:
URL: https://github.com/apache/echarts/issues/16976#issuecomment-2140862048
This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!
--
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