長方形、パス、円、線などの非常に多くの要素を含むsvgチャートを作成しています.jsonオプションを渡すことで要素を作成しています.コードの下に参照を追加する要素も作成しています.
this.svgLink = "http://www.w3.org/2000/svg";
drawPath: function (options, element) {
var path = document.createElementNS(this.svgLink, "path");
$(path).attr(options).appendTo(element);
},
drawLine: function (options, element) {
var path = document.createElementNS(this.svgLink, "line");
$(path).attr(options);
$(path).appendTo(element);
},
drawCircle: function (options, element) {
var circle = document.createElementNS(this.svgLink, "circle");
$(circle).attr(options).appendTo(element);
},
drawEllipse: function (options, element) {
var ellipse = document.createElementNS(this.svgLink, "ellipse");
$(ellipse).attr(options).appendTo(element);
},
以下のコードのようなオプションを渡しています。
var rectOptions = {
'id': this.svgObject.id +'_ZoomArea', 'x': x, 'y': y, 'width': width, 'height': height,
'fill': 'rgba(69,114,167,0.25)', 'stroke-width': 1, 'stroke':'rgba(69,114,167,0.25)','clip-path': 'url(#' + this.svgObject.id +'_ChartAreaClipRect)'
};
ここで、jquery の $.extend のように属性値を新しい値に置き換えたいだけで、再度作成するのではなく、既に作成された特定の要素に他のオプションを渡したいと考えています。
属性値を新しい値に置き換えるにはどうすればよいですか?
ありがとう、
シヴァ