javascript - 在其中绘制垂直虚线和圆圈的折线图

标签 javascript jquery raphael graphael

http://jsfiddle.net/ub69o0xw/7/

 jQuery(function ($) {

 var r = Raphael("graph", 303, 118);
 var lines = r.linechart(0, 0, 303, 126, [
     [0, 1, 2, 3, 4, 5, 6]
 ], [
     [1, 2, 3, 7, 4, 5, 4]
 ], {
     nostroke: false,
     axis: "0 0 1 1",
     axisxstep: 4,
     axisystep: 7,
     colors: ['#fff'],
     symbol: "circle",
     smooth: false,
     shade: true
 }).hoverColumn(function () {

 }, function () {
     this.tags && this.tags.remove();
 });

 var w = 300;
 var h = 122;
 x = 0;
 y = 0;
 // Draw horizontal lines
 for (var i = 0; i < lines.axis[1].text.items.length; i++) {
     r.path(['M', x, lines.axis[1].text.items[i].attrs.y, 'H', w + x]).attr({
         stroke: '#ccc'
     }).toBack();
 }
 lines.axis.hide();

 var i = 1;
 $("#graph svg circle").each(function () {
     rect_x = $(this).attr("cx");
     if (i >= 1) {
         r.path(['M', rect_x, 1, 'V', 114]).attr({
             "stroke-dasharray": ".",
             "stroke-width": "2.8",
             "stroke": "#818e8f",
             "stroke-linecap": "round",
             "stroke-linejoin": "round",
             "stroke-miterlimit": "2",
             "stroke-opacity": "0.5"
         }).toBack();
     }
     i++;
 });
});

我创建了这个折线图,其中有垂直的虚线穿过绘制的坐标。

这段代码在 mozilla 和 safari 中运行良好,但在 chrome 中则不行。有什么建议吗?

除此之外,我想绘制其中包含居中文本的圆圈,并与图表下方的这些垂直线对齐。知道如何实现这一点吗?

感谢您的帮助。

最佳答案

删除“描边线帽”和/或“描边线连接”。

关于javascript - 在其中绘制垂直虚线和圆圈的折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26582809/

相关文章:

javascript - 将 jquery 函数转换为每个

javascript - 如何将选项添加到 knockout js选项中的第一个?

javascript - 如何使用 Raphael JS 在悬停时将路径 curl 成螺旋形

RaphaelJS 问题 ...DRAW 或 REDRAW?

javascript - RaphaelJS 中图论图的标记节点

Javascript 将值传递给另一个 JS 类和 HTML 页面

javascript - 如何制作一个选择器 'live' 以便它适用于新插入的 DOM 元素?

javascript - 如何使用 React.js 编辑元素的文本?

javascript - 在滚动条上显示 float 导航栏

javascript - jquery固定位置 block ,切换到静态某个点