I am using the SVG Panel to try to re-create the “Status Dot” panel I had before the Version 8 upgrade that hosed it in the upgrade as it no longer exists in the Panel library.
But I cant seem to be able to change the colour attributes of the SVG circles as defined by the SVG builder.
I am trying to map the state of our CRAC units at my work - on/off/standby/unknown
There are 6 units arranged in 2 rows with the colours representing the states.
I have defined my SVG as below
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 400 500"><g id="crac1" transform="translate(0 0) rotate(0 0 0) scale(1)"><g id="circle_1" transform="translate(0,0)">
<svg height="123" viewBox="0 0 250 250" width="132" preserveAspectRatio="none">
<circle cx="124" cy="125" r="104" style="fill:#c0c0c0;stroke:#000;stroke-width:2">
</circle>
</svg>
</g></g><g id="crac2" transform="translate(150 0) rotate(0 0 0) scale(1)"><g id="circle_1" transform="translate(0,0)">
<svg height="123" viewBox="0 0 250 250" width="132" preserveAspectRatio="none">
<circle cx="124" cy="125" r="104" style="fill:#c0c0c0;stroke:#000;stroke-width:2">
</circle>
</svg>
</g></g><g id="crac3" transform="translate(300 0) rotate(0 0 0) scale(1)"><g id="circle_1" transform="translate(0,0)">
<svg height="123" viewBox="0 0 250 250" width="132" preserveAspectRatio="none">
<circle cx="124" cy="125" r="104" style="fill:#c0c0c0;stroke:#000;stroke-width:2">
</circle>
</svg>
</g></g><g id="crac4" transform="translate(0 150) rotate(0 0 0) scale(1)"><g id="circle_1" transform="translate(0,0)">
<svg height="123" viewBox="0 0 250 250" width="132" preserveAspectRatio="none">
<circle cx="124" cy="125" r="104" style="fill:#c0c0c0;stroke:#000;stroke-width:2">
</circle>
</svg>
</g></g><g id="crac5" transform="translate(150 150) rotate(0 0 0) scale(1)"><g id="circle_1" transform="translate(0,0)">
<svg height="123" viewBox="0 0 250 250" width="132" preserveAspectRatio="none">
<circle cx="124" cy="125" r="104" style="fill:#c0c0c0;stroke:#000;stroke-width:2">
</circle>
</svg>
</g></g><g id="crac6" transform="translate(300 150) rotate(0 0 0) scale(1)"><g id="circle_1" transform="translate(0,0)">
<svg height="123" viewBox="0 0 250 250" width="132" preserveAspectRatio="none">
<circle cx="124" cy="125" r="104" style="fill:#c0c0c0;stroke:#000;stroke-width:2">
</circle>
</svg>
</g></g></svg>
In the Javascript section I have the following:
var S = Snap(svgnode);
var cmap = { "on": "#008d00", "standby": "#ff8000", "off": "#ff0000", "unknown": "#c0c0c0" };
var c1 = S.select("#crac1");
var c2 = S.select("#crac2");
var c3 = S.select("#crac3");
var c4 = S.select("#crac4");
var c5 = S.select("#crac5");
var c6 = S.select("#crac6");
// Extract latest status of Crac 1 unit from series a text string "on" "standby" "off" or "unknown"
c1val = ctrl.data[0].datapoints[0][0];
c1col = cmap[c1val];
c2val = ctrl.data[0].datapoints[5][0];
c2col = cmap[c2val];
// Set Crac 1 and Crac 6 circles manually to RED colour
c1.attr( { fill: "#ff0000" } );
c6.attr( { fill: "#ff0000" } );
I try the above but it never works - all I get is the default Grey colour from the default SVG builder.
But when you inspect the rendered web page the SVG attributes for CRAC1 and CRAC6 have been coloured RED but they are not showing on the browser as red (as seen above in my sreeenshot).
Here is the inspected code and highlighted effected attributes after they were changed by the javascript code “c1.attr and c2.attr” assignments.
Once I can manually set the colour in the test code above I can then replace the fixed argument with a mapped colour using the assoc array.
Can anyone assist me?