I am in the process of creating a dashboard skin that receives data from a game via a plugin. I have encountered a problem with the RPM gauge. The issue is that the angle from 0 to 5 on the gauge is smaller than the angle from 5 to 10. I am attempting to set the angle for 5 to a specific value. The minimum angle is -125 and the maximum angle is 125, so 0 = -125, 5 = -90, but 10 = -40. This means the angle from 0 to 5 is 35 degrees, while from 5 to 10 it is 50 degrees. I only have HTML code and CSS for the gauge needle placement.
HTML:
<div class="truck-engineRpm gauges" data-type="meter" data-min="0" data-max="25" data-min-angle="-125" data-max-angle="90"></div>
CSS:
.truck-engineRpm {
z-index: 1;
visibility: visible;
position: absolute;
left: 1816px;
top: 391px;
width: 40px;
height: 391px;
background-image: url("images/needle.png");
transform: rotate(-125deg);
transform-origin: 50% 322px;
transition: 300ms linear;
}
There is a discrepancy in the degrees between the points on the gauge I created, as it is linear, while the gauge in question is not. When assigning a value to the gauge using JavaScript, it does not align with the data on the gauge.
I aim to develop a non-linear gauge with fixed angle settings. Currently, I only have a linear gauge with minimum/maximum data and angles.
---- Issue Resolved ----
I determined the value at which the needle was pointing (e.g., when it was on 5, the data was 350 rpm), and calculated how to display the game RPMs correctly.
JavaScript code:
var Rpm = data.truck.engineRpm;
var RpmCalc = data.truck.engineRpm;
var RpmRange1 = data.truck.engineRpm;
var RpmRange2 = data.truck.engineRpm - 500;
var RpmRange3 = data.truck.engineRpm - 1000;
var RpmRange4 = data.truck.engineRpm - 1442;
var RpmRange5 = data.truck.engineRpm - 1500;
var RpmRange6 = data.truck.engineRpm - 2000;
if (Rpm >= 0 && Rpm <= 500) {
data.engineRpm = RpmCalc - (0.3 * RpmRange1);
} else if (Rpm > 500 && Rpm <= 1000) {
data.engineRpm = RpmCalc - (0.01 * RpmRange2 + 150);
} else if (Rpm > 1000 && Rpm <= 1442) {
data.engineRpm = RpmCalc + (0.35 * RpmRange3 - 155);
} else if (Rpm > 1442 && Rpm <= 1500) {
data.engineRpm = RpmCalc + (0.38 * RpmRange4);
} else if (Rpm > 1500 && Rpm <= 2000) {
data.engineRpm = RpmCalc + (0.08 * RpmRange5 + 22);
} else if (Rpm > 2000 && Rpm <= 2500) {
data.engineRpm = RpmCalc - (0.124 * RpmRange6 - 62);
}
This solution may not look elegant, but if it works, it works :)