javascript - Jquery - Flot,如何只显示点而不显示线?

标签 javascript jquery jquery-plugins flot

好的开始我正在使用 Jquery-Flot 绘制径向图我找到了一个插件来创建蜘蛛图请参阅此处的 API:

http://www.jumware.com/Includes/jquery/Flot/Doc/JQuery.Flot.spider.html

现在一切正常,除非我不想显示连接点的线。 通常与:

points: { show: true}, lines: { show: false}

但是当使用 spider 插件时,它似乎忽略了这个设置。我在这里做错了什么,还是在使用这个插件时我必须显示线条?


工作示例:

http://jsfiddle.net/WAscC/2/


代码:

function EveryOneSec() {

    var d1 = [[0, 10], [1, 20], [2, 80], [3, 70], [4, 60]];
    var d2 = [[0, 30], [1, 25], [2, 50], [3, 60], [4, 95]];
    var d3 = [[0, 50], [1, 40], [2, 60], [3, 95], [4, 30]];

    var options = {
        series: {
            spider: {
                active: true,
                legs: {
                    data: ["", "", "", "", ""],
                    legScaleMax: 1,
                    legScaleMin: 0.8
                }, spiderSize: 0.9
            }
        }, grid: {
            hoverable: false,
            clickable: false,
            tickColor: "rgba(0,0,0,0.2)",
            mode: "radar"
        }
    };


    data = [{
        label: "",
        data: d1,
        spider: {
            show: true,
            lineWidth: 0
        }
    }, {
        label: "",
        data: d2,
        spider: {
            show: true,
            lineWidth: 0
        }
    }, {
        label: "",
        data: d3,
        spider: {
            show: true,
            lineWidth: 0
        },
        points: { show: true},lines: { show: false }
    }];

    $.plot($("#RadialPlot"), data, options);
}
EveryOneSec();

更新一

编辑 lineWidth: 0, connectionWidth: 0 到任何数字似乎都对图表没有任何影响。


如何只显示点而不显示线?

最佳答案

添加 connection: { width: 0 } 到 spider options:

spider: {
   active: true,
   connection: { width: 0 }, // add this line
   legs: {
       data: ["", "", "", "", ""],
       legScaleMax: 1,
       legScaleMin: 0.8
   },
   spiderSize: 0.9
}

Documentation声明该选项应为:connectionWidth: 0,但从 source for the actual plugin 中可以看出,这似乎已发生变化:

function drawspiderConnections(ctx,cnt,serie,c,fill) {
    var pos,d;
    ctx.beginPath();
    ctx.lineWidth = serie.spider.connection.width; // this is the line

    // etc.

}

关于javascript - Jquery - Flot,如何只显示点而不显示线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3262371/

相关文章:

javascript - 使用jQuery按下删除键时如何从字符串中跳过一个字符

javascript - 将动态加载的 html 元素分配给变量

javascript - onMouseOver 文本替换整个页面

使用默认字段值进行 Javascript 验证

javascript - 将 javascript fetch API 与 SOAP Web 服务一起使用

javascript - 未捕获的 TypeError Accordion 不是 jQuery 中的函数?

javascript - jQuery:查找具有特定自定义属性的元素

javascript - blockUI 无法在 Internet Explorer 上运行

jquery - 使用下一个/上一个按钮自动完成

javascript - React/Redux 加载数据有副作用