看別人翻譯的開發文檔:git
開發文檔地址:https://zlq4863947.gitbooks.io/tradingview/後端
方法介紹:圖表庫調用這個函數來得到可見的K線範圍的標記。 圖表預期每調用一次getMarks就會調用一次onDataCallback。ide
mark爲具備如下屬性的對象:函數
每一個K線容許幾個標記(如今最多爲10個)。目前我測試的能夠多於 10 個。不容許標記脫離K線。測試
Remark: 只有當您聲明您的後端是支持標記時纔會調用這個函數。supporting marks.this
個人代碼栗子:spa
1 Datafeeds.Container.prototype.getMarks = function (symbolInfo, startDate, endDate, onDataCallback, resolution) { 2 console.log('endDate: ',endDate); 3 var marks = that.getMarks(); 4 setTimeout(function () { 5 onDataCallback(marks); 6 }, 0); 7 } 8 9 getMarks(){ 10 var that = this; 11 var id = 1; 12 var time = Date.parse(new Date())/1000; 13 var color = { border: '#103bff', background: '#ff00e9' }; 14 var text = '這是標記: '; 15 var label = 'S'; 16 var labelFontColor = '#ff8e53'; 17 var minSize = 5; 18 var marks = []; 19 for(var i=0;i<15;i++){ 20 var mark = {}; 21 mark.id = id++; 22 mark.time = time; 23 time -= 28800; 24 mark.color = color; 25 mark.text = text + (id-1); 26 mark.label = label; 27 mark.labelFontColor = labelFontColor; 28 mark.minSize = minSize; 29 marks.push(mark); 30 } 31 return marks; 32 }