0
我只在jqplot.pointlabels.js文件中添加了幾行內容,所以我在jqplot pointlabels選項中獲得了一個額外的選項。我如何爲此創建一個新的插件?如何爲jqplot -option創建新的插件?
當然,如果我需要更新,我喜歡保留這些更改。我不知道如何做到這一點。我試圖製作一個時間表/甘特圖像。每個項目或線條是隻有兩個點的系列。所以我沒有在每一端都有點標籤,而是計算中心並放置一個標籤。
所以jqplot.pointlabels.js,線322將是:
if (p.centerLabel) {
var ell = xax.u2p(pd[i][0]) + ((xax.u2p(pd[1][0]) - xax.u2p(pd[0][0]))/2) +p.xOffset(elem, location);
} else {
var ell = xax.u2p(pd[i][0]) + p.xOffset(elem, location);
}
和我會寫類似jqplot的選擇:
pointLabels:{
show:true,
location:'s',
fontSize: '1em',
centerLabel: true, // extra option, see code
labelsFromSeries: true,
formatter: $.jqplot.DefaultTickFormatter,
}
我可以將所有的代碼複製到一個名爲jqplot.singleSeriesLabels.js的新插件,但是如何讓jqplot使用該插件作爲'pointLabels'?