pihome-shc / pihome

PiHome - Smart Heating, Ventilation and Air Conditioning (HVAC)
http://www.pihome.eu
Other
52 stars 25 forks source link

Graph colours #388

Closed frogstar51 closed 3 years ago

frogstar51 commented 3 years ago

Hi Is it possible to have the colours of the graphs the same? For example on my system at the moment PiHome Temperature Graphs Sensor's Battery Graphs Living Room Sensor 30 is Pink on the PiHome Temperature Graphs and Purple on the Sensor's Battery Graphs Bedroom Sensor 21 is Green on the PiHome Temperature Graphs and Light Blue on the Sensor's Battery Graphs Back Bedroom Sensor 20 is Purple on the PiHome Temperature Graphs and Green on the Sensor's Battery Graphs Comp Room Sensor: 28-0316a2791940 is Dark Blue on the PiHome Temperature Graphs Thanks Kevin

pihome-shc commented 3 years ago

@frogstar51, rainbow function is defined is defined in chart_batteryusage.php and chart_load.php the way this function generate colour for both charts isnt going to be in sync.

function rainbow(numOfSteps, step) {
    var r, g, b;
    var h = step / numOfSteps;
    var i = ~~(h * 6);
    var f = h * 6 - i;
    var q = 1 - f;
    switch(i % 6){
        case 0: r = 1; g = f; b = 0; break;
        case 1: r = q; g = 1; b = 0; break;
        case 2: r = 0; g = 1; b = f; break;
        case 3: r = 0; g = q; b = 1; break;
        case 4: r = f; g = 0; b = 1; break;
        case 5: r = 1; g = 0; b = q; break;
    }
    var c = "#" + ("00" + (~ ~(r * 255)).toString(16)).slice(-2) + ("00" + (~ ~(g * 255)).toString(16)).slice(-2) + ("00" + (~ ~(b * 255)).toString(16)).slice(-2);
    return (c);
}
twa127 commented 3 years ago

I might have a solution for this, testing at the moment

twa127 commented 3 years ago

Anybody want to give this a try, I don't have many battery nodes (functions.php goes in the st_inc directory).

Note the one limitation is where you have multiple sensors connected to a single node, in this case the battery graph colour will be the same as child_id 0

charts.zip

frogstar51 commented 3 years ago

Hi, just uploaded the files and all looks great thanks

twa127 commented 3 years ago

great, glad it worked

pihome-shc commented 3 years ago

@twa127 can you comity this change,

twa127 commented 3 years ago

Hi,

Noticed that the zone graphs are on showing the boiler active background colour. This is a bug I introduced back on 1st July, I'll fix in next commit.

pihome-shc commented 3 years ago

any further work required on this or can this be closed ?

twa127 commented 3 years ago

I think this is now fixex