- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想根据 y 轴值在背景图上显示 3 个颜色区域,据我了解,我无法通过不同颜色控制背景颜色。
我的想法是用 canvasOverlay 绘制 3 条水平线 - 这是有效的。
问题是我想把这条线放在我的图形曲线后面,现在它在前面看到,它覆盖了我的点线。
我可以更改 z-index 或不透明度的属性吗?
也许还有其他想法?
$.jqplot( 'ChartDIV', [data],
{
series: [{ showMarker: true}],
highlighter: {
sizeAdjust: 10,
show: true,
tooltipLocation: 'n',
useAxesFormatters: true
},
tickOptions: {
formatString: '%d'
},
canvasOverlay: {
show: true,
objects: [
{
horizontalLine:
{
name: 'low',
y: 1.0,
lineWidth: 100,
color: 'rgb(255, 0, 0)',
shadow: false
}
},
{
horizontalLine:
{
name: 'medium',
y: 2.0,
lineWidth: 100,
color: 'rgb(250, 250, 0)',
shadow: true
}
},
{
horizontalLine:
{
name: 'high',
y: 3.0,
lineWidth: 100,
color: 'rgb(145, 213, 67)',
shadow: false
}
},
]
},
axes: {
xaxis:
{
label: 'Dates',
renderer: $.jqplot.DateAxisRenderer,
rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer },
tickOptions: {
formatString: '%d/%m/%Y',
angle: -30,
fontFamily: 'Arial',
fontSize: '13px',
fontWeight: 'bold'
},
min: d[0] + "/" + d[1] + "/01",
tickInterval: '2 month',
labelOptions: {
fontFamily: 'Arial',
fontSize: '14pt',
fontWeight: 'bold',
textColor: '#0070A3'
}
},
yaxis:
{
label: 'Level',
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
tickOptions: {
formatter: $.jqplot.tickNumberFormatter
},
rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer },
labelOptions: {
fontFamily: 'Arial',
fontSize: '14pt',
fontWeight: 'bold',
textColor: '#0070A3',
angle: -90
}
}
}
} );
最佳答案
我认为您的问题可能是您绘画的顺序。我认为您首先创建图表,然后在其中绘制这条线,对吗?
因此,要解决这个问题,您可以尝试其中一个 Hook jqPlot
图表提供。
要了解如何使用钩子(Hook),please see my other answer (顺便问一下我自己的问题:)我在哪里使用了 postDrawHooks
绘制图形后, Hook 以更改标签的格式。在您的情况下,您可以使用 preDrawHooks
或者更合适的是使用 preDrawSeriesHooks
,因为我不确定当函数传入 preDrawHooks
时是否可以使用 Canvas 叫做。
请记住,according to the documentation , preDrawSeriesHooks
每次在绘制系列之前都会调用它,因此在您的情况下,您只需要它工作一次。
编辑
在这种情况下,答案很简单,你可以两者都做,这在我的 jsfiddle 中显示,available here .
您需要这段代码将覆盖 Canvas 发送到后面,您应该在绘制图形的代码之前放置它:
$.jqplot.postDrawHooks.push(function(){
$(".jqplot-overlayCanvas-canvas").css('z-index', '0');//send overlay canvas to back
$(".jqplot-series-canvas").css('z-index', '1');//send series canvas to front
});
rgba()
方法,对于系列,它是这样完成的:
seriesColors:['rgba(100, 150, 100, 0.75)']
color: 'rgba(145, 213, 67, 0.25)'
z-index
进行了更正。为了它。完整的方法如下所示:
$.jqplot.postDrawHooks.push(function() {
$(".jqplot-overlayCanvas-canvas").css('z-index', '0'); //send overlay canvas to back
$(".jqplot-series-canvas").css('z-index', '1'); //send series canvas to front
$(".jqplot-highlighter-tooltip").css('z-index', '2'); //make sure the tooltip is over the series
$(".jqplot-event-canvas").css('z-index', '5'); //must be on the very top since it is responsible for event catching and propagation
});
z-index
.
$.jqplot.postDrawHooks.push(function() {
var overlayCanvas = $($('.jqplot-overlayCanvas-canvas')[0])
var seriesCanvas = $($('.jqplot-series-canvas')[0])
seriesCanvas.detach();
overlayCanvas.after(seriesCanvas);
});
关于jqPlot - 如何更改 canvasOverlay 的不透明度或 z-index?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10426192/
我试图了解当未指定宽度时 jqplot 如何计算条的宽度。假设我有以下图表: $.jqplot(chartDiv.attr("id"), [ [ ['2013-02-15',
我是 jqplot 的新手,当我想绘制条形图时,x 轴是日期,间隔是 1 天。这是我的代码的一部分: axesDefaults:{
我正在使用 jqPlot创建一个 Y 轴从 0% 到 100% 的线性图表。我遇到的问题是其中一个值落在 X 轴上(为 0%)或 100%,它被轴或图表的边界截断。 如何确保不会发生这种情况,同时将
这是否已包含在 jqPlot 中,或者是否存在可以执行此操作的库? 我敢肯定,如果我投入 12 个小时,我就能解决这个问题,但我只是觉得我会问。 :) 最佳答案 我还没有在 jqPlot 中看到过这样
我刚刚开始使用 jqPlot 绘制具有多个系列的折线图。看起来不错。 我添加了 Cursor 插件,目的是在 x 轴上的最近 数据点上显示一条垂直线。换句话说,它捕捉到最近的点。然而,Cursor 插
有没有办法根据条形图中的阈值设置/更改条形颜色。 变量 s1 = [460, -260, 690, 820]; 对于上面指定的值,低于 -200 的条(-260 的条)应该是红色的。有没有办法在 jq
我正在 jqPlot 中使用条形图,我需要在图表上用单独的线显示平均值。我的问题是如何做到这一点?我需要为此使用折线图吗?我看过一些折线图示例,但它们在条形图中显示为趋势,从图表上的第一个条形开始,而
我有一个条形图,在某个点 x 轴显示 35 多个项目,代表图表上的单个条形图。 问题:保持图表背景大小与当前一样,每个条形图变得非常窄并且显示阴影,造成视觉干扰。所以我试图从图表中删除阴影。 尝试过:
我正在用 jqPlot 绘制图表,在我的模板中,我设计了图表,使其向下生长,有点翻转条形,使它们从顶部开始向下移动,这取决于来自数据库的一些输入。我想乘以-1,但似乎行不通。 有什么建议?这是我的代码
我正在尝试以编程方式打开和关闭 pointLabels。我认为它会像这样工作: var data_ = [[1,1],[2,5],[4,9]]; var graph = $.jqplo
我有一个多系列图表,不仅要突出显示点的 x 和 y 坐标,还要突出显示 series 名称。 可能吗? 最佳答案 我发现最简单的方法是这样的: $.jqplot('chart-id', values,
我对其中一个 jqPlot 插件文件 (jqplot.highlighter.js) 做了一些更改,我想在部署前将其缩小。 有谁知道 jqPlot 开发人员使用什么工具来缩小他们的 jqPlot 相关
当光标悬停到 JQPlot 的 Bar 时,我想将光标更改为“指针”。 我试图改变 CSS。但它没有用。请帮我。 最佳答案 您需要 - 正如您所尝试的那样 - 使用 CSS 修改它。 您可能没有在正确
一直在搜索,找不到我正在寻找的东西。需要将多个系列加载到一个 jqplot 中,每个系列都来自自己的数据文件。 这里的例子http://www.jqplot.com/tests/data-render
当使用 jqPlot 绘制图形时,我有包含正值和负值的曲线,因此穿过 x 轴。我想强调 0 处的 x 轴,以便更清楚地区分正值和负值。有办法做到这一点吗? 在我使用示例曲线的代码下方: $.jqplo
有人遇到过吗?我对此很陌生,所以我不确定这里到底发生了什么。但我正在尝试根据文档使用 jqplot 的仪表,但它似乎没有用。我可以很好地创建条形图、折线图等图表。 包括必要的脚本链接(以及其他需要的链
与this question完全相同,但由于我没有赞成它的声誉(也无法回答),我将不得不再次询问...... 给定如下图,我如何强制刻度始终为整数,即使该图为空?目前,如果图表没有数据,它将变为 0,
我可以使用 EnhancedLegendRenderer 插件获得 jqplot 图的水平图例。但是我需要图底部的水平图例。有什么建议吗? 最佳答案 在发布到堆栈溢出时,您应该始终显示一些工作。它有助
嗨,我正在使用 jqplot,有没有办法缩短数字轴上的刻度标签。假设有一个像这样的 y 系列 [100,250,125000000,14000000,300,..]。这里根据最大值轴被缩放并用大刻度值
我想使用 jqPlot 在页面上创建 3 个单独的图表,是否可以配置 jqPlot 以便当光标在一个图表上移动时,垂直线也会在其他图表上移动? 最佳答案 我还需要同时跟踪 2 个图表上的一条垂直线,并
我是一名优秀的程序员,十分优秀!