Widget:StatsGraph: Difference between revisions
Jump to navigation
Jump to search
Removed logging |
Dynamically creating orientation lines |
||
Line 39: | Line 39: | ||
var style = document.createElementNS(svgNS, 'style'); | var style = document.createElementNS(svgNS, 'style'); | ||
style.setAttribute('type', "text/css"); | style.setAttribute('type', "text/css"); | ||
var styleData = document.createTextNode('line.radial {stroke: #333;stroke-width: 4pt;}polygon {stroke-width: 4pt;}svg {fill: none;stroke: #777;stroke-opacity: 1;stroke-width: 1pt;}text {fill: #000;font-family: Arial, Helvetica, sans-serif;font-size: 2.5em;font-weight: normal;stroke: none;text-anchor: middle;}.unit { stroke: #f73; }'); | var styleData = document.createTextNode('line.emphased {stroke-width:3pt} line.radial {stroke: #333;stroke-width: 4pt;}polygon {stroke-width: 4pt;}svg {fill: none;stroke: #777;stroke-opacity: 1;stroke-width: 1pt;}text {fill: #000;font-family: Arial, Helvetica, sans-serif;font-size: 2.5em;font-weight: normal;stroke: none;text-anchor: middle;}.unit { stroke: #f73; }'); | ||
style.appendChild(styleData); | style.appendChild(styleData); | ||
svg.appendChild(style); | svg.appendChild(style); | ||
Line 48: | Line 48: | ||
var wedge = document.createElementNS(svgNS, 'g'); | var wedge = document.createElementNS(svgNS, 'g'); | ||
wedge.setAttribute('id', "wedge" + graphId); | wedge.setAttribute('id', "wedge" + graphId); | ||
var directionCount = dataComplete[0].data.length; | |||
var degreeSpacing = 360 / directionCount; | |||
var radialLine = document.createElementNS(svgNS, 'line'); | var radialLine = document.createElementNS(svgNS, 'line'); | ||
Line 53: | Line 56: | ||
radialLine.setAttribute('y2', 325); | radialLine.setAttribute('y2', 325); | ||
wedge.appendChild(radialLine); | wedge.appendChild(radialLine); | ||
for (int lineIdx=1;lineY<5;lineIdx++) { | |||
var orientationLine = document.createElementNS(svgNS, 'line'); | |||
var lineDistance = lineIdx * -75; | |||
var rotate = (-degreeSpacing * Math.PI) / 180; | |||
orientationLine.setAttribute('y1', lineDistance); | |||
orientationLine.setAttribute('x2', lineDistance*Math.sin(rotate)); | |||
orientationLine.setAttribute('y2', lineDistance*Math.cos(rotate)); | |||
if (lineIdx % 2 == 0) { | |||
orientationLine.setAttribute('class', 'emphased'); | |||
} | |||
wedge.appendChild(orientationLine); | |||
} | |||
defs.appendChild(wedge); | defs.appendChild(wedge); | ||
svg.appendChild(defs); | svg.appendChild(defs); | ||
Line 82: | Line 76: | ||
gDrawing.setAttribute('transform', 'translate(400 400)'); | gDrawing.setAttribute('transform', 'translate(400 400)'); | ||
for (var dataIdx=0; dataIdx<directionCount; dataIdx++) { | for (var dataIdx=0; dataIdx<directionCount; dataIdx++) { | ||
var propertyLine = document.createElementNS(svgNS, 'use'); | var propertyLine = document.createElementNS(svgNS, 'use'); |