You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Next »
Description: This svg is uses Ractive, and works by dragging and dropping a virtual point on top of the component. The gauge will change colors depending if it is above, below, or within the "Ok Value". The "Ok Value", colors, and name can all be changed from the default, using tags.
Download: verticalGaugeSVG.zip
Adding a Virtual Point
- Go to the Virtual Points menu on the left hand side
- Drag and drop a virtual point onto the gauge
- To change the point, drag and drop a new virtual point onto the component
okValLow = the smaller number for the "Ok Value" range (default 40)
okValHigh = the larger number for the "Ok Value" range (default 60)
maxValColor = hex color for gauge when value is above the "Ok Value" range (default #c34c46)
minValColor = hex color for gauge when value is below the "Ok Value" range (default #5d8eca)
okValColor = hex color for gauge when value is in the "Ok Value" range (default #6cc487)
minVal = lowest value displayed on the gauge (default is the minVal on the virtual point if one exists, otherwise the default is 0)
maxVal = highest value displayed on the gauge (default is the maxVal on the virtual point if one exists, otherwise the default is 100)
shortName = name appearing under the vaule under the gauge (default is the navName of the virtual point)
How to Create Your Own
- Start by dragging out a Ractive component from the components menu on the left side
- Add a tag to the component called verticalGauge
- Open the Ractive Editor from the properties menu on the left side
- Copy and paste the code below into the Template section of the Ractive Editor
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 357 441" style="enable-background:new 0 0 357 441;" xml:space="preserve">
<path style="fill:#E6E6E6;" d="M195,341.8h-56c-2.2,0-4-1.8-4-4v-302c0-2.2,1.8-4,4-4h56c2.2,0,4,1.8,4,4v302C199,340,197.2,341.8,195,341.8z"/>
<rect x="139" y="328" style="fill:{{#if myValue<okValueLow }}{{minValueColor}}{{elseif okValueHigh<myValue}}{{maxValueColor}}{{else}}{{okValueColor}}{{/if}};" width="56" height="{{gaugeValue}}" transform="rotate(180 167,332.5)"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="336.8" x2="178" y2="336.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="306.8" x2="178" y2="306.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="276.8" x2="178" y2="276.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="246.8" x2="178" y2="246.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="216.8" x2="178" y2="216.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="186.8" x2="178" y2="186.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="156.8" x2="178" y2="156.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="126.8" x2="178" y2="126.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="96.8" x2="178" y2="96.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="66.8" x2="178" y2="66.8"/>
<line style="fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;" x1="197" y1="36.8" x2="178" y2="36.8"/>
<text transform="matrix(1 0 0 1 206.5161 343.3412)" style="font-family:'SourceSansPro-Light'; font-size:24px;">{{minInputValue.toFixed(0)}}</text>
<text transform="matrix(1 0 0 1 206.5161 283.3412)" style="font-family:'SourceSansPro-Light'; font-size:24px;">{{((((maxInputValue-minInputValue)/10)*2)+minInputValue).toFixed(0)}}</text>
<text transform="matrix(1 0 0 1 206.5161 223.3412)" style="font-family:'SourceSansPro-Light'; font-size:24px;">{{((((maxInputValue-minInputValue)/10)*4)+minInputValue).toFixed(0)}}</text>
<text transform="matrix(1 0 0 1 206.5161 163.341)" style="font-family:'SourceSansPro-Light'; font-size:24px;">{{((((maxInputValue-minInputValue)/10)*6)+minInputValue).toFixed(0)}}</text>
<text transform="matrix(1 0 0 1 206.5161 103.3411)" style="font-family:'SourceSansPro-Light'; font-size:24px;">{{((((maxInputValue-minInputValue)/10)*8)+minInputValue).toFixed(0)}}</text>
<text transform="matrix(1 0 0 1 206.5161 43.3412)" style="font-family:'SourceSansPro-Light'; font-size:24px;">{{maxInputValue.toFixed(0)}}</text>
<text transform="matrix(1 0 0 1 167 387.4922)" style="fill:{{#if myValue<okValueLow }}{{minValueColor}}{{elseif okValueHigh<myValue}}{{maxValueColor}}{{else}}{{okValueColor}}{{/if}}; font-family:'SourceSansPro-Bold'; font-size:36px;" text-anchor="middle">{{prettyValue}}</text>
<text transform="matrix(1 0 0 1 167 414.8256)" style="fill:{{#if myValue<okValueLow }}{{minValueColor}}{{elseif okValueHigh<myValue}}{{maxValueColor}}{{else}}{{okValueColor}}{{/if}}; font-family:'SourceSansPro-Bold'; font-size:25px;" text-anchor="middle">{{myNavName}}</text>
</svg>
- Next we are going to add a program
- Go to Programs in the left menu and click the + icon to create a new program
- Name your program, and set the Program Target Filter to verticalGauge
- Click the three dots in the top right corner, and select variables
- Click the + icon next to Program Vars
- Click the gear that appears as you hover over "newVariable"
- Name the newVariable point and in the box below type id==$virtualPointRef
- Turn on Invokes the Function
- Change the dropdown to Tag Change
- In the textbox below the dropdown type curVal
- Click the gray Save button
- Copy and paste the code below into the main section and click the blue save
this.prettyValue = GetPrettyValue(point);
this.myValue = point.curVal;
this.myNavName = this.shortName || point.navName;
this.minInputValue = this.minVal || point.minVal || 0;
this.maxInputValue = this.maxVal || point.maxVal || 100;
this.minOutputValue = this.minOutputVal || 0;
this.maxOutputValue = this.maxOutputVal || 300;
this.maxValueColor = this.maxValColor || "#c34c46";
this.minValueColor = this.minValColor || "#5d8eca";
this.okValueColor = this.okValColor || "#6cc487";
this.okValueLow = this.okValLow || 40;
this.okValueHigh = this.okValHigh || 60;
var myGaugeValue = fin.Utils.ResetBAS(point.curVal, this.minInputValue , this.maxInputValue , this.minOutputValue, this.maxOutputValue);
this.ractive.animate('gaugeValue',myGaugeValue);