简体   繁体   English

“Flipping / Mirroring”一个Flot图表

[英]“Flipping/Mirroring” a Flot chart

I'm using a framework called Lorikeet which is built off of the Flot Javascript framework. 我正在使用一个名为Lorikeet的框架,它是基于Flot Javascript框架构建的。 Currently I'm able to use their basic usage of the charts and it shows a nice graph as such: 目前我可以使用他们对图表的基本用法,它显示了一个很好的图形:

在此输入图像描述

However, my ultimate goal is to have two different graphs lined up as such: 但是,我的最终目标是将两个不同的图表排成一行:

在此输入图像描述

My basic question is how can I "flip/mirror" a Flot chart? 我的基本问题是如何“翻转/镜像”Flot图表?

Essentially, how do I have it such that I'm able to display the percentages descending from 100% to 0% and back to ascending 100%, as well as show a "mirrored" data set that grows downward depending on intensity? 从本质上讲,我如何能够显示百分比从100%降至0%并返回到升序100%,并显示“镜像”数据集,根据强度向下增长?

EDIT: 编辑:

Here's what I have done so far: http://hologos.org/stackoverflow/html/example_use%20-%20Copy.html I was only able to create two separate graphs that had the same zoom functionality as the original one. 这是我到目前为止所做的: http//hologos.org/stackoverflow/html/example_use%20-%20Copy.html我只能创建两个独立的图形,它们具有与原始图像相同的缩放功能。

Here's an example that draws two flot charts, one a mirror of the other. 这是一个绘制两个flot图表的示例,一个是另一个的镜像。 The key is to use a yaxis transform function that will allow the axis to run in "reverse": 关键是使用yaxis转换函数,允许轴以“反向”运行:

var somePlot1 = $.plot("#placeholder", 
                  [ {data: d1} ],
                  { 
                      xaxis: { position: 'top'} // place on top
                  }
);
var somePlot2 = $.plot("#placeholder2", 
                  [ {data: d1} ],
                   { 
                       xaxis: { position: 'bottom'}, // place on bottom
                       yaxis: { 
                           ticks: [0.5, 1.0, 1.5, 2.0, 2.5], // custom ticks to avoid overlap on 0
                           transform: function (v) { return -v; }, // run the yaxis in reverse
                           inverseTransform: function (v) { return -v; }
                        } 
                   }
);

Example here . 这里的例子。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM