wip improvements
This commit is contained in:
@@ -8,10 +8,10 @@ export default (
|
||||
): void => {
|
||||
if (ctx && series) {
|
||||
const tempGradientFill = ctx.createLinearGradient(0, 0, 0, config.maxY);
|
||||
tempGradientFill.addColorStop(0, getColor(config.maxTemp.toFixed(0), unit) + '5c');
|
||||
tempGradientFill.addColorStop(0.25, getColor(config.maxTemp.toFixed(0), unit) + '5c');
|
||||
tempGradientFill.addColorStop(0.85, getColor(config.minTemp.toFixed(0), unit) + '06');
|
||||
tempGradientFill.addColorStop(1, getColor(config.minTemp.toFixed(0), unit) + '00');
|
||||
tempGradientFill.addColorStop(0, getColor(config.maxTemp, unit) + '5c');
|
||||
tempGradientFill.addColorStop(0.25, getColor(config.maxTemp, unit) + '5c');
|
||||
tempGradientFill.addColorStop(0.85, getColor(config.minTemp, unit) + '06');
|
||||
tempGradientFill.addColorStop(1, getColor(config.minTemp, unit) + '00');
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(
|
||||
|
||||
@@ -25,19 +25,18 @@ export function rgbToHex(rgb: string) {
|
||||
return hex;
|
||||
}
|
||||
|
||||
export const getColor = (tempString: string, unit = 'celsius'): string => {
|
||||
export const getColor = (temperature: number, unit = 'celsius'): string => {
|
||||
let index = 0;
|
||||
const temp = Number(tempString);
|
||||
if (unit === 'celsius') {
|
||||
if (temp <= -40) {
|
||||
if (temperature <= -40) {
|
||||
index = 0;
|
||||
} else if (temp >= 60) {
|
||||
} else if (temperature >= 60) {
|
||||
index = colorScaleHex.length - 1;
|
||||
} else {
|
||||
index = temp + 40;
|
||||
index = temperature + 40;
|
||||
}
|
||||
} else {
|
||||
const tempInCelsius = Math.round(((temp - 32) * 5) / 9);
|
||||
const tempInCelsius = Math.round(((temperature - 32) * 5) / 9);
|
||||
if (tempInCelsius <= -40) {
|
||||
index = 0;
|
||||
} else if (tempInCelsius >= 60) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user