atmospi
atmospi copied to clipboard
Assigning fixed colors
Currently highcharts seems to assign a random color to each [temperature] line. This makes the result analysis needlessy difficult. It would be nice if both the order as well as the line color could be derived from a configuration file.
I solved this in the following way:
Create a new function getDevParams. This function sets various rendering parameters: device name, legend sort order and line color:
// set key parameters for each device and map device ID to a human-sensible name
function getDevParams(device) {
switch (device) {
case "28-000005fab05d":
devName = "CV ruimte";
legendIndex = 4;
lineColor = '#66CCFF'
break;
case "28-000005fab2e0":
devName = "vloer aanvoer";
legendIndex = 2;
lineColor = '#FF9900'
break;
case "28-000005fab89c":
devName = "vloer retour";
legendIndex = 3;
lineColor = '#FFDD77'
break;
case "28-000005fb03d6":
devName = "CV aanvoer";
legendIndex = 1;
lineColor = '#FF0000'
break;
}
var devParams = new Object();
devParams.devName = devName;
devParams.legendIndex = legendIndex;
devParams.lineColor = lineColor;
return devParams;
}
I still can't get the summary div to sort though.
To summarize:
- each sensor gets a human sensible name
- each sensor gets a user defined line color
- the legend sort order can be defined by the user
Unfortunately most of this is hard coded; hopefully someone can improve on this.
Point 1 in your comment above is done! See #10
Point 2: Let's look at the possibility of adding a "Color" column to the new Devices table, and pulling that into the Highcharts UI...
Point 3: This is the trickiest part... the data for each device is loaded separately and asynchronously, so the order in which the HTTP requests finish is the order in which the data is displayed. And, the "Latest Measurements" load separately from the rest of the data, so those can be in a different order too...
On Point 3: I realize this is going to be tricky; at the same time as you can see from #23, meeting this requirement will significantly enhance usability in cases where there are many [>3] sensors.
I'm in the process of porting my extensions to the latest release. It seems to me that the settings construct that is now in place, will serve as a suitable mechanism to store this information as well as being much more convenient than storing the equivalent in the database. However, I need some help in finding the right structure as I need to capture a set of parameters for each device as well as global options such as chart background and height [which I know how to do]. Can you write a small example on how to cleanly define a set of options per device?