我有以下代码来绘制一条线,但它不会绘制。我只看到画布边框。我在控制台中看不到任何错误。
索引.html:
<div id="chart_area">
<canvas id="chart1" width="800" height="600"></canvas>
</div>
...
<script>
processChart()
</script>
样式.css:
#chart_area
{
text-align:center;
color:red;
}
#chart1
{
text-align:center;
border:solid;
color:blue;
}
#control_panel
{
text-align:center;
color:red;
float:right;
clear:both;
}
图表.js:
function processChart() {
var b_canvas = document.getElementById("chart1");
var b_context = b_canvas.getContext("2d");
b_context.moveTo([0,0]);
b_context.lineTo([300,300]);
b_context.stroke()
}