In the following simple program, the canvas background is displayed, and the console log shows that I'm executing the graphics script with the proper data, but nothing is plotted.
Any ideas why not?
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>plotTracts</title> <link type="text/css" href="LIB\ui.theme.css" rel="stylesheet" /> <script src="LIB\jquery-1.3.2.js"></script> <script src="LIB\ui.core.js"></script> <script src="LIB\Geometry.js"></script> <script> canvasColor = "#ddddff"; mag = 1; // magnification function setUpCanvas(){ canvas = document.getElementById("myCanvasTag"); ctx = canvas.getContext('2d'); ctx.fillStyle = canvasColor; ctx.fillRect (0, 0, 5000, 5000); // PLOT THE CENSUS TRACTS for (var nn=1; nn<tractId.length ;nn++ ) { plotTract(nn, -1); } } function plotTract(nn, color) { var x = mag * tractX[nn]; //later can center it var y = mag * tractY[nn]; var r = mag * Math.sqrt(tractPop[nn]) / 5; ctx.strokeStyle = "#000000"; ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI*2, true); safelog(nn + ": called ctx.arc(" + x + ", " + y + ", " + r + ")"); ctx.closePath(); color = "#ff0000"; if (color > -1) { ctx.fillStyle = color; ctx.fill(); } } </script> <script> function safelog(msg) { if (window.console) { console.log(msg); } } </script> <script> lastX=0; lastY=0; // globals to save last click loc UpArrow=38; DownArrow=40; RightArrow=39; LeftArrow=37; //keyCodes PageUp=33; PageDown=34; HomeKey=36; EndKey=35; function saveCoords(e){lastX=e.pageX; lastY=e.pageY; } </script> </head> <body onload="setUpCanvas()" onkeypress="keyHandler(event)" onmousedown="saveCoords(event)"> <script src="tracts.js" ></script> <!-- Load data arrays tractId, tractPop, tractX, tractY, tractAdj --> <canvas id="myCanvasTag" width="1000" height="1000"></canvas> </body> </html>









Bookmarks