Widget:StatsGraph: Difference between revisions
Jump to navigation
Jump to search
Added label output |
Removed inline style and turned graph upside down |
||
Line 3: | Line 3: | ||
var oldX = 0; | var oldX = 0; | ||
var oldY = (max-min) == 0 ? 0 : (300 / (max-min)) * (val - min); | var oldY = (max-min) == 0 ? 0 : -(300 / (max-min)) * (val - min); | ||
if (degree == 0) { | if (degree == 0) { | ||
Line 35: | Line 35: | ||
svg.setAttribute('preserveAspectRatio', "none"); | svg.setAttribute('preserveAspectRatio', "none"); | ||
svg.setAttribute('version', "1.1"); | svg.setAttribute('version', "1.1"); | ||
/* This pretty much defines the base net lines */ | /* This pretty much defines the base net lines */ | ||
Line 54: | Line 47: | ||
var radialLine = document.createElementNS(svgNS, 'line'); | var radialLine = document.createElementNS(svgNS, 'line'); | ||
radialLine.setAttribute('class', 'radial'); | radialLine.setAttribute('class', 'radial'); | ||
radialLine.setAttribute('y2', 325); | radialLine.setAttribute('y2', -325); | ||
wedge.appendChild(radialLine); | wedge.appendChild(radialLine); | ||
for (var lineIdx=1;lineIdx<5;lineIdx++) { | for (var lineIdx=1;lineIdx<5;lineIdx++) { | ||
var orientationLine = document.createElementNS(svgNS, 'line'); | var orientationLine = document.createElementNS(svgNS, 'line'); | ||
var lineDistance = lineIdx * 75; | var lineDistance = lineIdx * -75; | ||
var rotate = (degreeSpacing * Math.PI) / 180; | var rotate = (degreeSpacing * Math.PI) / 180; | ||
orientationLine.setAttribute('y1', lineDistance); | orientationLine.setAttribute('y1', lineDistance); | ||
Line 95: | Line 88: | ||
var label = document.createElementNS(svgNS, 'text'); | var label = document.createElementNS(svgNS, 'text'); | ||
var rotate = (-degreeSpacing * labelIdx * Math.PI) / 180; | var rotate = (-degreeSpacing * labelIdx * Math.PI) / 180; | ||
label.setAttribute('x', 340*Math.sin(rotate)); | label.setAttribute('x', -340*Math.sin(rotate)); | ||
label.setAttribute('y', 340*Math.cos(rotate)); | label.setAttribute('y', -340*Math.cos(rotate)); | ||
label.appendChild(document.createTextNode(polygonParams.data[labelIdx].label)); | label.appendChild(document.createTextNode(polygonParams.data[labelIdx].label)); | ||
gDrawing.appendChild(label); | gDrawing.appendChild(label); |