Menu

Color Change on value threshold

2005-08-11
2026-01-25
  • Nobody/Anonymous

    Greetings All,
    I am working on a simple chart to graph numbers between -2 and 6.

    I would like any value less that 0 or more than 5 to appear in red, all the other values in blue.

    Is this possible? If so could you point me an example?

    Thank you for your help!
    Dave

     
  • chuck lidderdale

    Gotit - I want to do the same thing. A graph of temperature in my greenhouse. At 55F a space heater turns on and I want to have temperature line to be green when above 55F and red below 55F.
    +--------+--------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +--------+--------------+------+-----+---------+----------------+
    | id | mediumint(9) | NO | PRI | NULL | auto_increment |
    | ts | timestamp | YES | | NULL | |
    | ghtemp | float(4,1) | YES | | NULL | |
    | ghhumd | float(4,1) | YES | | NULL | |
    | ghsump | float(4,1) | YES | | NULL | |
    | ostemp | float(4,1) | YES | | NULL | |
    | oshumd | float(4,1) | YES | | NULL | |
    | misc | int(11) | YES | | NULL | |
    +--------+--------------+------+-----+---------+----------------+

    "misc" will be 00000 heat off, 00001 heat on. Plot create needs $plot>SetDrawBrokenLines(TRUE);
    which allows for the line to "------- _-----------" where data[8] thru data[14] is NULL. (an aside)

    For testing because it's 4 deg outside right now I used $data[$n] to make it work.

    In the mysql while fetch_row

    if ($n > 100 && $n < 200)
    {
    $data[] = array($h, $row[2], $row[3], $s, $row[5], $row[6], 32, $row[2]);
    } else {
    $data[] = array($h, $row[2], $row[3], $s, $row[5], $row[6], 32, NULL);
    }

    and $plot->SetDataColors(array( 'DarkGreen', 'blue', 'brown', 'YellowGreen', '#aaaaaa', 'black', 'green', 'red'));
    and my graph is:
    gggggggggggggggggggggrrrrrrrrrrrrrrrrrrrrrrrrrgggggggggggggg ______gggggggggggggg
    the blank part is where I updated the temp to NULL.

    and Who's on First

     

    Last edit: chuck lidderdale 2026-01-25

Log in to post a comment.

MongoDB Logo MongoDB