Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reverse legend labels in Flot stacked bar chart?

Basically it is all in the title. I pass a json object to my template. This is how it's build using python:

series = []
tab = []
for i,l in reversed(list(enumerate(ts_g))):
    try:
        z = l[0].split(";")

        start_z = ts_g[0][0].split(';')[0]
        tmp_d = {
            'data': [
            [float(start_z), float(z[1])],
            ],
            'label': str(s.description),
            'color':str(s.color)
            }
        series.append(tmp_d)
        tab.append([z[0],z[1],s.description])

    except Exception:
        raise Exception("couldn't get data from vsoil data field\n")


return series, tab.reverse()

All values are negatives so I want the legend to be displayed in reverse. How can I do this?

like image 510
LarsVegas Avatar asked Jan 21 '26 05:01

LarsVegas


1 Answers

Use sorted: "reverse", as described in the Customizing the Legend section of the documentation. Note that this requires Flot 0.8, which is still technically a dev version, though it's due to replace 0.7 as the stable release in the next week or two.

like image 66
DNS Avatar answered Jan 22 '26 18:01

DNS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!