我是编程新手。我想在浏览器上渲染画布
我的代码在这里
// implement canvas js
let dataPoints = [
{label: 'One', y: 0},
{label: 'Two', y: 0},
{label: 'Three', y: 0},
{label: 'Four', y: 0}
];
const myContainer = document.querySelector(
'#mytContainer'
);
if(cmytContainer){
const chart = CanvasJS.Chart('mytContainer', {
animationEnabled: true,
theme: 'theme1',
title: {
text: 'My Results'
},
data: [
{
type: 'column',
dataPoints: dataPoints
}
]
});
chart.return()
}
请帮助一下。 预先感谢
答案 0 :(得分:0)
我认为错误是由于条件变量拼写更改为myContainer
let dataPoints = [
{label: 'One', y: 0},
{label: 'Two', y: 0},
{label: 'Three', y: 0},
{label: 'Four', y: 0}
];
const myContainer = document.querySelector(
'#mytContainer'
);
if(myContainer){
const chart = CanvasJS.Chart('mytContainer', {
animationEnabled: true,
theme: 'theme1',
title: {
text: 'My Results'
},
data: [
{
type: 'column',
dataPoints: dataPoints
}
]
});
chart.return()
}