ここで重要な何かが欠けている可能性があります。
この関数を使用して、一部の SVG テキスト要素の日付形式を変更しています。
jQuery.fn.fixDateformat = function(){
ar = $(this).text().split("/")
output = [ar[1], ar[0], ar[2]].join(".")
$(this).text(output)
};
コンソールで、変更したい要素の配列を取得します。
> array = $("text[x='0']")
[
<text y="5" dy=".71em" text-anchor="middle" x="0">04/21/13</text>,
<text y="5" dy=".71em" text-anchor="middle" x="0">04/26/13</text>,
<text y="5" dy=".71em" text-anchor="middle" x="0">05/02/13</text>,
<text y="5" dy=".71em" text-anchor="middle" x="0">05/08/13</text>,
<text y="5" dy=".71em" text-anchor="middle" x="0">05/14/13</text>
]
関数を要素の1つに渡すと、機能します。ええ!
> array.first().fixDateformatOnCharts()
しかし、配列をループすると、このエラーが発生します。
> array.each(function(i,v){ v.fixDateformatOnCharts()})
TypeError: Object #<SVGTextElement> has no method 'fixDateformatOnCharts'
何か案は?