0

I'm trying to make a simple X axis for a chart using Raphael SVG path, but the variables for M(moveto) and L(lineto) aren't getting accepted.

var x1 = x,
    y1 = y+height,
    x2 = x+width,
    y2 = y+height;
var xAxis = SVGpaper.path("Mx1,y1 Lx2,y2").attr({stroke: "config.axisColor", "stroke-width": 1});

It gives the error:

Error: Problem parsing d="M,0,0"

Am I making some error in declaring the variables or in the syntax for path? I can't find any code to refer to, so please advice some tips!

4

1 回答 1

1

您只是传递字符串“Mx1,y1 Lx2,y2”,即使用变量名而不是它们的值。

你要这个...

SVGpaper.path("M" + x1 + "," + y1 + " L" + x2 + "," + y2).attr({stroke: "config.axisColor", "stroke-width": 1});
于 2013-10-30T11:50:04.213 回答