elambert

HLED chart not rendering with value greater than upperlimit

Recommended Posts

Good morning.  I'm using json to render a live-update HLED chart.  I have it all working well until the data value returned from the database happens to fall above (or below, as in -1 error state) the upperlimit set for the HLED widget.  I would hope/expect that it would fill the HLED since, in this case, 18 > 12.  However it draws the HLED with a zero value.  In the case in question, the $led_end=12 and the data returned by the datastreamURL query is 18.

 

Is there a way to have this behave as I would expect, where "since 18 > 12, assume 12 and fill chart"?  Know what I mean? =)

 

Here's a piece of the perl script I use to generate the JSON in question:

                ($name, $itemid, $label, $x, $y, $qtype, $units, $led_start, $led_warnlow, $led_warnhigh, $led_end, $environ) = split(/,/, $line);

                $chart = {
                        manageresize => "1",
                        origH => "120",
                        origW => "310",
                        basefont => "Cabin",
                        basefontsize => 10,
                        lowerlimit => "$led_start",
                        upperlimit => "$led_end",
                        showLimits => "1",
                        bgcolor => "000000",
                        bgalpha => "88",
                        numbersuffix => "$units",
                        majortmcolor => "646F8F",
                        majortmheight => "9",
                        majortmthickness => "1",
                        majortmnumber => "6",
                        minortmcolor => "646F8F",
                        minortmheight => "3",
                        minortmnumber => "3",
                        tickvaluestep => "1",
                        ticksbelowgauge => "0",
                        decimalprecision => "1",
                        forcedecimals => "0",
                        palettethemecolor => "FFFFFF",
                        charttopmargin => "30",
                        chartbottommargin => "10",
                        ledborderthickness => "1",
                        ledgap => "2",
                        ledsize => "3",
                        decimals => "1",
                        refreshInstantly => "1",
                        clickURL => "j-renderChart-$name",
                        dataStreamURL => "/perl/ops/garch-$release_env/getdata.pl?name=$name",
                        refreshInterval => "20"
                };

                $initial_value = { value => "$default_value"};
                $annotation_items[0] = { color => "FFFFFF", type => "text", bold => "1", font => "Cabin", fontSize => "11", x => '$chartCenterX', y => '$chartStartY+15', label => "$label ($environ)" };
                $groups[0] = { id => "Group1", items => \@annotation_items };
                $annotation = { groups => \@groups };

                $color[0] = { minvalue => "$led_start", maxvalue => "$led_warnlow", code => "00FF00" };
                $color[1] = { minvalue => "$led_warnlow", maxvalue => "$led_warnhigh", code => "FFFF00" };
                $color[2] = { minvalue => "$led_warnhigh", maxvalue => "$led_end", code => "FF0000" };
                $colorrange = { color => \@color };

                $list = { chart => $chart, value => $initial_value, annotations => $annotation, colorrange => $colorrange };

                $json_text = encode_json $list;
                print header('application/json');
                print $json_text;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now