我在点击按钮后尝试渲染图形,但点击后图形会在一秒钟内快速消失。
这是我用来渲染图表的函数(我正在使用CanvasJS):
function makeChart() {
var p = Number(dieForm.elements["headsProb"].value);
var numTrials = Number(dieForm.elements["numTrials"].value);
var dieResults = coinToss(p, numTrials);
var heads = dieResults[0];
var tails = dieResults[1];
var chart = new CanvasJS.Chart("colChartContainer", {
theme: "theme2",
title:{
text: "Coin Toss Results"
},
data: [
{
type: "column",
dataPoints: [
{ label: "Heads", y: heads},
{ label: "Tails", y: tails}
]
}
]
});
chart.render();
}