gpt4 book ai didi

jQuery flot ...如何填充样条曲线?

转载 作者:行者123 更新时间:2023-12-01 04:05:27 25 4
gpt4 key购买 nike

我正在使用 jQuery flot 插件并尝试填充样条线。但是,只有当我在 lines 中设置 show: false 时,我才能填充它,这会导致显示第二行。我做错了什么?

我有这样的代码:

$(function () {        
$.plot($("#flotcontainer"),
[{
data: data9_1,
label: "Page Views",
color: "#e74c3c"
}
],{
series: {
lines: {
show: true,
fill: 0.3,
lineWidth: 1,
fillColor: "#d5d5d5"
},
splines: {
show: true,
tension: 0.4,
lineWidth: 1,
fill: 1
},
points: {
radius: 5,
show: true,
fill: true,
fillColor: "#ffffff"
},
shadowSize: 2
},
grid: {
hoverable: true,
clickable: true,
tickColor: "#d5d5d5",
borderWidth: 1,
color: '#d5d5d5'
},
colors: ["#1ab394", "#464f88"],
xaxis:{
ticks: [
[1, "Jan 2015"],
[2, "Feb 2015"],
[3, "Mar 2015"],
[4, "Apr 2015"]
],
color: "#838383"
} ,
yaxis: {
ticks: 4
},
legend: {
show: false,
}
}
);

$("#flotcontainer").UseTooltip();

});

它显示如下:

enter image description here

如果我从行中删除 show: true ,它会删除第二行,但也会删除填充。

如何获得带有填充的平滑样条曲线?

最佳答案

您似乎正在使用 this spline plugin 。请参阅this comment在同一页面上查看具有填充功能的 fork 版本:

@aaronaverill: I also needed the fill to work so I forked the plugin and fixed it.

You can set the fill via the splines: { fill: (float between 0 and 1 || false) } option. The seriesColor will automatically be used.

My fork also draws the entire line at once instead of doing it one segment at a time so it should be faster.

The fork is here: https://github.com/AMKohn/flot/blob/master/jquery.flot.spline.js

And I put together a demo here: http://jsfiddle.net/MHTEy/1/

Since the project I'm working on doesn't use any area charts I'm not sure if it works with them properly. I also used a slightly modified version of flot while working on it but that shouldn't affect anything.

关于jQuery flot ...如何填充样条曲线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29539069/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com