如何在Flot堆叠条形图中反转图例标签?

时间:2022-12-03 18:01:02

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

基本上都在标题里。我将json对象传递给模板。这就是如何使用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?

所有的值都是负数,所以我希望图例以相反的方式显示。我该怎么做呢?

1 个解决方案

#1


4  

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.

使用排序:“反向”,如自定义文档的传奇部分所述。请注意,这需要Flot 0.8,这在技术上仍然是一个dev版本,但是它将在未来一两周内替换0.7作为稳定版本。

#1


4  

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.

使用排序:“反向”,如自定义文档的传奇部分所述。请注意,这需要Flot 0.8,这在技术上仍然是一个dev版本,但是它将在未来一两周内替换0.7作为稳定版本。