-
Gas Pump Price/Gallon Expression
I’ve had the idea to make a comp that would show the rise in price / gallon at the pump. Can this be done by slider controls? One that sets the price per gallon and/or the amount of gasoline.
Using Dan Ebbert’s universal currency / count expression I’ve slightly modified the expression code for a time slider and total amount of gas, however I need the total amount to equal the number of gallons times price at the time. Any assistance would be greatly appreciated.
numDecimals = 2;
commas = true;
dollarSign = true;
beginCount = 0;
endCount = effect("PRICE SLIDER")("Slider")
dur = effect("TIME")("Slider");t = time - inPoint;
s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);prefix = "";
if (s[0] == "-"){
prefix = "-";
s = s.substr(1);
}
if(dollarSign) prefix += "$";if (commas){
decimals = "";
if (numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length - (numDecimals + 1));
}
outStr = s.substr(-s.length, (s.length-1)%3 +1);
for (i = Math.floor((s.length-1)/3); i > 0; i--){
outStr += "," + s.substr(-i*3,3);
}
prefix + outStr + decimals;
}else{
prefix + s;
}