航迹图:标记z-index? [英] Flot charts: markings z-index?

查看:78
本文介绍了航迹图:标记z-index?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以访问和手动设置浮点图中标记线的z索引(由于缺少更好的单词)?现在,我正在折线图上创建一些标记以用作阈值(将基本水平线设置为特定值),它的工作原理非常好,除非标记恰好与图表的网格线对齐.发生这种情况时,网格线会与标记线重叠,因此很难看到标记线.我想做的是手动将标记线设置在网格线的顶部,但是我不知道在哪里设置该选项(或者甚至可以).

Is there any way to access and manually set the z-index (for lack of better word) of the markings lines in a flot chart? Right now I am creating some markings on a line chart to use as thresholds (basic horizontal lines set to a specific value) and it's working great except when the markings happen to be lined up perfectly with the chart's grid lines. When that happens the grid line overlaps the marking line so it's hard to see the marking line. What I would like to do is manually set the marking line to be on top of the grid lines, but I can't figure out where to set that option (or if it's even possible).

这是我正在动态创建的标记数组:

Here is the markings array that I am creating (dynamically):

markings: [ { y2axis: {from: -20, to: -20}, color: "#848484", lineWidth: 2.5 },{ y2axis: {from: -12, to: -12}, color: "#848484", lineWidth: 2.5 } ]

这是结果的图像(您可以看到-12处的阈值被埋在图表的网格线下,并且看起来几乎像2条较细的线):

Here is an image of the result (you can see the threshold at -12 is buried under the chart's gridline and appears almost like 2 thinner lines):

感谢您提供的任何帮助或建议!

Thanks for any help or advice you can offer!

推荐答案

在画布上绘制时,没有z顺序.稍后绘制的内容覆盖了较旧的内容.当您查看浮动代码(在drawGrid()函数中)时,您会看到标记是首先绘制的.

When drawing on the canvas there is no z-order. What is drawn later is drawn over older stuff. And when you look at the flot code (in the drawGrid() function) you see that the markings are drawn first.

这里有一些不同的解决方案/解决方法:

There are a few different solutions / work-arounds here:

  1. 您可以制作jquery.flot.js文件的本地副本并更改代码,以便在drawGrid()函数中最后绘制标记.
  2. 您删除标记,而是使用两个端点生成一个简单的数据系列,然后将其添加到您的数据集中(最好在您的真实数据系列之前).然后在网格之后和实际数据系列之前绘制标记数据系列.
  3. 在flot绘制网格之后,在flot绘制数据图之前,您可以手动绘制标记. (请参见文档.)
  1. You make a local copy of the jquery.flot.js file and change the code so that the markings are drawn last in the drawGrid() function.
  2. You remove the markings and instead generate a simple data series with the two endpoints and add it to your dataset (preferably before your real data series). Then your markings data series is drawn after the grid and before your real data series.
  3. You draw the markings manually after flot draws the grid and before flot draws the plot for the data. (See the documentation.)

这篇关于航迹图:标记z-index?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆