@millistream/millistream-widgets 1.0.45 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/millistream-widgets.js +108 -56
- package/package.json +1 -1
package/millistream-widgets.js
CHANGED
|
@@ -74,7 +74,8 @@ function Milli_Chart(settings) {
|
|
|
74
74
|
},
|
|
75
75
|
xAxisSpacing: 0,
|
|
76
76
|
yAxisSpacing: 4, // undocumented
|
|
77
|
-
xAxisModulo: 1 // undocumented,
|
|
77
|
+
xAxisModulo: 1, // undocumented,
|
|
78
|
+
cursor: 'crosshair' //'crosshair'
|
|
78
79
|
};
|
|
79
80
|
var m_startdate = null;
|
|
80
81
|
var m_chartspaces = {
|
|
@@ -1261,7 +1262,6 @@ function Milli_Chart(settings) {
|
|
|
1261
1262
|
x = Math.round(m_chartspaces.chart.left + ((currentDate.getTime() - _this.scaleinfoX.startDate.getTime()) / _this.scaleinfoX.timePerPixel) - offset);
|
|
1262
1263
|
//if (lastx == 0 && m_chartspaces.chart.left > (x - (getMaxDateWidth() / 2))) { // do not print left of y legend
|
|
1263
1264
|
if (lastx == 0 && 0 > x - (getMaxDateWidth() / 2)) {
|
|
1264
|
-
console.log(currentDate,x - (getMaxDateWidth() / 2));
|
|
1265
1265
|
currentDate = new Date(currentDate.getTime() + 86400000);
|
|
1266
1266
|
continue;
|
|
1267
1267
|
}
|
|
@@ -1769,6 +1769,48 @@ function Milli_Chart(settings) {
|
|
|
1769
1769
|
if (m_zoom.mousedown && m_zoom.mousedown.pos != m_zoom.mouseup.pos) return;
|
|
1770
1770
|
}
|
|
1771
1771
|
|
|
1772
|
+
function findClosestValue(dataset, target) {
|
|
1773
|
+
//returns closest value and position in array
|
|
1774
|
+
let left = 0;
|
|
1775
|
+
let right = dataset.length - 1;
|
|
1776
|
+
let closest = null;
|
|
1777
|
+
let iterations = 0;
|
|
1778
|
+
let mid;
|
|
1779
|
+
while (left <= right) {
|
|
1780
|
+
iterations++;
|
|
1781
|
+
mid = Math.floor((left + right) / 2);
|
|
1782
|
+
const midValue = dataset[mid];
|
|
1783
|
+
|
|
1784
|
+
if (midValue === target) {
|
|
1785
|
+
return [midValue,mid];
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
if (closest === null || Math.abs(midValue - target) < Math.abs(closest - target)) {
|
|
1789
|
+
closest = midValue;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
if (midValue < target) {
|
|
1793
|
+
left = mid + 1;
|
|
1794
|
+
} else {
|
|
1795
|
+
right = mid - 1;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return [closest,mid];
|
|
1799
|
+
}
|
|
1800
|
+
function getDivHeight(elem) {
|
|
1801
|
+
let style = getComputedStyle(elem);
|
|
1802
|
+
let h = elem.offsetHeight + parseInt(style.marginBottom) + parseInt(style.marginTop);
|
|
1803
|
+
let divs = elem.children;
|
|
1804
|
+
if(divs) {
|
|
1805
|
+
for(let d = 0; d < divs.length; d++) {
|
|
1806
|
+
if(divs[d].nodeName == 'DIV' && divs[d].offsetWidth != 0) {
|
|
1807
|
+
style = getComputedStyle(divs[d]);
|
|
1808
|
+
h = Math.max(h,divs[d].offsetHeight + parseInt(style.marginBottom) + parseInt(style.marginTop));
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
return h;
|
|
1813
|
+
}
|
|
1772
1814
|
function onMouseMove(pos) {
|
|
1773
1815
|
if (m_dataPoints.arr.length == 0) return;
|
|
1774
1816
|
var rect = m_canvas.getBoundingClientRect();
|
|
@@ -1794,28 +1836,39 @@ function Milli_Chart(settings) {
|
|
|
1794
1836
|
onMouseOut();
|
|
1795
1837
|
return;
|
|
1796
1838
|
}
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1839
|
+
let obj = [];
|
|
1840
|
+
let i;
|
|
1841
|
+
let a = findClosestValue(m_dataPoints.arr,x); // closest and pos
|
|
1842
|
+
|
|
1843
|
+
for(let s = 0; s < _this.instruments.length; s++) {
|
|
1844
|
+
if(_this.instruments[s].insref != 0) {
|
|
1845
|
+
//for (i = 0; i < m_dataPoints.arr.length; i++) {
|
|
1846
|
+
//for (i = m_dataPoints.arr.length - 1; i >= 0; i--) {
|
|
1847
|
+
for (i = a[1]; i >= 0; i--) {
|
|
1848
|
+
if (x >= m_dataPoints.arr[i]) {
|
|
1849
|
+
let o = m_dataPoints.map.get(m_dataPoints.arr[i]);
|
|
1850
|
+
let breakout = false;
|
|
1851
|
+
for(let ss = 0; ss < o.instruments.length; ss++) {
|
|
1852
|
+
if(o.instruments[ss] && o.instruments[ss].insref == _this.instruments[s].insref) {
|
|
1853
|
+
obj[s] = {timestamp: o.timestamp,instruments: o.instruments[ss]};
|
|
1854
|
+
breakout = true;
|
|
1855
|
+
break;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
if(breakout) break;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1801
1861
|
}
|
|
1802
1862
|
}
|
|
1803
|
-
if (
|
|
1804
|
-
if (i != 0) {
|
|
1805
|
-
if (Math.abs(x - m_dataPoints.arr[i]) > Math.abs(x - m_dataPoints.arr[i - 1]))
|
|
1806
|
-
i--;
|
|
1807
|
-
}
|
|
1808
|
-
var obj = m_dataPoints.map.get(m_dataPoints.arr[i]);
|
|
1809
|
-
if (obj == null) {
|
|
1863
|
+
if (obj.length == 0) {
|
|
1810
1864
|
return;
|
|
1811
1865
|
}
|
|
1812
|
-
var highy = -1;
|
|
1813
|
-
var lowy = m_chartspaces.chart.height;
|
|
1814
1866
|
var toolArray = [];
|
|
1815
1867
|
let pointerWidth = 0;
|
|
1816
1868
|
for (x = 0; x < _this.instruments.length; x++) {
|
|
1817
|
-
if (_this.instruments[x].insref != 0 && typeof obj.instruments[x] !== 'undefined') {
|
|
1818
|
-
|
|
1869
|
+
//if (_this.instruments[x].insref != 0 && typeof obj.instruments[x] !== 'undefined') {
|
|
1870
|
+
if (_this.instruments[x].insref != 0 && typeof obj[x] !== 'undefined') {
|
|
1871
|
+
var instr = {};
|
|
1819
1872
|
instr.chartType = chartType;
|
|
1820
1873
|
instr.name = _this.instruments[x].name;
|
|
1821
1874
|
instr.instrumenttype = _this.instruments[x].instrumenttype;
|
|
@@ -1824,7 +1877,7 @@ function Milli_Chart(settings) {
|
|
|
1824
1877
|
instr.symbol = _this.instruments[x].symbol;
|
|
1825
1878
|
|
|
1826
1879
|
instr.data = {};
|
|
1827
|
-
MillistreamWidgetApi_AssignObject(obj
|
|
1880
|
+
MillistreamWidgetApi_AssignObject(obj[x].instruments, instr.data);
|
|
1828
1881
|
instr.data.price = formatNiceNumber(instr.data.price, _this.settings.thousandseparator, _this.settings.decimalseparator, _this.settings.num_decimals, false);
|
|
1829
1882
|
if(x == 0) {
|
|
1830
1883
|
for (let s = 0; s < _this.settings.indicators.length; s++) {
|
|
@@ -1834,7 +1887,7 @@ function Milli_Chart(settings) {
|
|
|
1834
1887
|
instr.data.indicator = {
|
|
1835
1888
|
method: _this.settings.indicators[s].method,
|
|
1836
1889
|
datapoints: _this.settings.indicators[s].timeseries[ss].datapoints
|
|
1837
|
-
}
|
|
1890
|
+
};
|
|
1838
1891
|
} else break;
|
|
1839
1892
|
}
|
|
1840
1893
|
}
|
|
@@ -1853,24 +1906,22 @@ function Milli_Chart(settings) {
|
|
|
1853
1906
|
m_canvas.parentNode.appendChild(_this.instruments[x].toolTipPointer);
|
|
1854
1907
|
_this.instruments[x].toolTipPointer.setAttribute('class', 'millistream-chart-pointer');
|
|
1855
1908
|
_this.instruments[x].toolTipPointer.style.left = (m_dataPoints.arr[i] - (_this.instruments[x].toolTipPointer.clientWidth / 2)) + 'px';
|
|
1856
|
-
_this.instruments[x].toolTipPointer.style.top = (obj
|
|
1909
|
+
_this.instruments[x].toolTipPointer.style.top = (obj[x].instruments.y - (_this.instruments[x].toolTipPointer.clientHeight / 2)) + 'px';
|
|
1857
1910
|
_this.instruments[x].toolTipPointer.style.position = 'absolute';
|
|
1858
1911
|
_this.instruments[x].toolTipPointer.style.backgroundColor = typeof m_instrumentCss[x].pointerColor === 'string' ? m_instrumentCss[x].pointerColor : m_instrumentCss[x].color;
|
|
1859
1912
|
_this.instruments[x].toolTipPointer.style.pointerEvents = 'none';
|
|
1860
1913
|
|
|
1861
1914
|
}
|
|
1862
|
-
_this.instruments[x].toolTip.innerHTML = _this.settings.tooltip.formatter.call(instr, m_chartspaces, obj
|
|
1915
|
+
_this.instruments[x].toolTip.innerHTML = _this.settings.tooltip.formatter.call(instr, m_chartspaces, obj[x].instruments.x);
|
|
1863
1916
|
var pointerStyle = getComputedStyle(_this.instruments[x].toolTipPointer);
|
|
1864
1917
|
pointerWidth = _this.instruments[x].toolTipPointer.offsetWidth + parseInt(pointerStyle.marginLeft) + (parseInt(pointerStyle.marginRight));
|
|
1865
1918
|
var pointerHeight = _this.instruments[x].toolTipPointer.offsetHeight + parseInt(pointerStyle.marginTop) + parseInt(pointerStyle.marginBottom);
|
|
1866
|
-
var posy = obj
|
|
1919
|
+
var posy = obj[x].instruments.y - (getDivHeight(_this.instruments[x].toolTip ) / 2);
|
|
1920
|
+
//var posy = obj[x].instruments.y - (_this.instruments[x].toolTip.offsetHeight / 2);
|
|
1867
1921
|
_this.instruments[x].toolTip.style.top = posy + 'px';
|
|
1868
|
-
toolArray.push({ top: (obj
|
|
1869
|
-
_this.instruments[x].toolTipPointer.style.left = (obj
|
|
1870
|
-
_this.instruments[x].toolTipPointer.style.top = (obj
|
|
1871
|
-
if (posy > highy) highy = posy;
|
|
1872
|
-
if (posy < lowy) lowy = posy;
|
|
1873
|
-
// _this.instruments[x].toolTip.innerHTML = _this.settings.tooltip.formatter.call(instr, m_chartspaces, obj.instruments[x].x);
|
|
1922
|
+
toolArray.push({ top: (obj[x].instruments.y - (pointerHeight / 2)), instrument: x });
|
|
1923
|
+
_this.instruments[x].toolTipPointer.style.left = (obj[x].instruments.x - (pointerWidth / 2)) + 1 + 'px'; // hmm plus 1??
|
|
1924
|
+
_this.instruments[x].toolTipPointer.style.top = (obj[x].instruments.y - (pointerHeight / 2)) + 'px';
|
|
1874
1925
|
let divs = _this.instruments[x].toolTip.children;
|
|
1875
1926
|
let width = _this.instruments[x].toolTip.offsetWidth;
|
|
1876
1927
|
for(let d = 0; d < divs.length; d++) {
|
|
@@ -1878,10 +1929,10 @@ function Milli_Chart(settings) {
|
|
|
1878
1929
|
}
|
|
1879
1930
|
if (m_dataPoints.arr[i] + width > m_canvas.getWidth()) { // || m_dataPoints.arr[i] + (_this.instruments[x].toolTip.offsetWidth * 1.5) > m_canvas.getWidth()) { // TODO +10 should be calculated better
|
|
1880
1931
|
// draw the hover to the left
|
|
1881
|
-
_this.instruments[x].toolTip.style.left = (obj
|
|
1932
|
+
_this.instruments[x].toolTip.style.left = (obj[x].instruments.x - width - (pointerWidth / 2)) + 1 + 'px';
|
|
1882
1933
|
} else {
|
|
1883
1934
|
// draw hover to the right
|
|
1884
|
-
_this.instruments[x].toolTip.style.left = (obj
|
|
1935
|
+
_this.instruments[x].toolTip.style.left = (obj[x].instruments.x + (pointerWidth / 2)) + 'px';
|
|
1885
1936
|
}
|
|
1886
1937
|
} else {
|
|
1887
1938
|
if (_this.instruments[x].toolTip) {
|
|
@@ -1920,12 +1971,14 @@ function Milli_Chart(settings) {
|
|
|
1920
1971
|
m_canvas.parentNode.appendChild(_this.settings.indicators[x].toolTip.div);
|
|
1921
1972
|
}
|
|
1922
1973
|
_this.settings.indicators[x].toolTip.div.style.left = _this.settings.indicators[x].timeseries[xx].pos.x / 1 + (pointerWidth / 2) + 'px'; // this i modified in the data for the instruments, but not for indicators
|
|
1923
|
-
_this.settings.indicators[x].toolTip.div.style.top = _this.settings.indicators[x].timeseries[xx].pos.y / 1 + 'px'; // this i modified in the data for the instruments, but not for indicators
|
|
1974
|
+
//_this.settings.indicators[x].toolTip.div.style.top = _this.settings.indicators[x].timeseries[xx].pos.y / 1 + 'px'; // this i modified in the data for the instruments, but not for indicators
|
|
1975
|
+
_this.settings.indicators[x].toolTip.div.style.top = toolArray[0].top + 2 + 'px'; // this i modified in the data for the instruments, but not for indicators
|
|
1976
|
+
|
|
1924
1977
|
_this.settings.indicators[x].toolTip.div.innerHTML = _this.settings.indicators[x].toolTip.formatter.call(_this.settings.indicators[x].timeseries[xx]);
|
|
1925
1978
|
if (y > _this.settings.indicators[x].timeseries[xx].pos.y -(height/2) && y < _this.settings.indicators[x].timeseries[xx].pos.y + (height/2))
|
|
1926
1979
|
m_canvas.style.cursor = "pointer";
|
|
1927
1980
|
else {
|
|
1928
|
-
m_canvas.style.cursor =
|
|
1981
|
+
m_canvas.style.cursor = _this.settings.cursor;
|
|
1929
1982
|
}
|
|
1930
1983
|
remove = false;
|
|
1931
1984
|
toolArray.push({ top: parseInt(_this.settings.indicators[x].toolTip.div.style.top), indicator: x });
|
|
@@ -1936,7 +1989,7 @@ function Milli_Chart(settings) {
|
|
|
1936
1989
|
if (_this.settings.indicators[x].toolTip.div && _this.settings.indicators[x].staticTooltip != true) {
|
|
1937
1990
|
_this.settings.indicators[x].toolTip.div.parentNode.removeChild(_this.settings.indicators[x].toolTip.div);
|
|
1938
1991
|
_this.settings.indicators[x].toolTip.div = undefined;
|
|
1939
|
-
m_canvas.style.cursor =
|
|
1992
|
+
m_canvas.style.cursor = _this.settings.cursor;
|
|
1940
1993
|
}
|
|
1941
1994
|
|
|
1942
1995
|
}
|
|
@@ -1946,26 +1999,20 @@ function Milli_Chart(settings) {
|
|
|
1946
1999
|
let lastHeight = 0;
|
|
1947
2000
|
for (x = 0; x < toolArray.length; x++) {
|
|
1948
2001
|
if (typeof toolArray[x].instrument !== 'undefined') {
|
|
1949
|
-
//if (x != 0 && typeof _this.instruments[x - 1].toolTip !== 'undefined') {
|
|
1950
|
-
//if (lastTop + _this.instruments[x - 1].toolTip.offsetHeight > toolArray[x].top) {
|
|
1951
2002
|
if (lastTop + lastHeight > toolArray[x].top) {
|
|
1952
|
-
|
|
1953
|
-
toolArray[x].top = (lastTop + lastHeight);
|
|
2003
|
+
toolArray[x].top = (lastTop + lastHeight)+1;
|
|
1954
2004
|
}
|
|
1955
|
-
//}
|
|
1956
2005
|
} else {
|
|
1957
|
-
//if (lastTop + _this.settings.indicators[toolArray[x].indicator].toolTip.div.offsetHeight > toolArray[x].top) {
|
|
1958
2006
|
if (lastTop + lastHeight > toolArray[x].top) {
|
|
1959
|
-
//toolArray[x].top = (lastTop + _this.settings.indicators[toolArray[x].indicator].toolTip.div.offsetHeight);
|
|
1960
2007
|
toolArray[x].top = (lastTop + lastHeight);
|
|
1961
2008
|
}
|
|
1962
2009
|
}
|
|
1963
2010
|
if (typeof toolArray[x].instrument !== 'undefined') {
|
|
1964
2011
|
_this.instruments[toolArray[x].instrument].toolTip.style.top = toolArray[x].top + 'px';
|
|
1965
|
-
lastHeight = _this.instruments[toolArray[x].instrument].toolTip
|
|
2012
|
+
lastHeight = getDivHeight(_this.instruments[toolArray[x].instrument].toolTip);
|
|
1966
2013
|
} else {
|
|
1967
2014
|
_this.settings.indicators[toolArray[x].indicator].toolTip.div.style.top = toolArray[x].top + 'px';
|
|
1968
|
-
lastHeight = _this.settings.indicators[toolArray[x].indicator].toolTip.div
|
|
2015
|
+
lastHeight = getDivHeight(_this.settings.indicators[toolArray[x].indicator].toolTip.div);
|
|
1969
2016
|
}
|
|
1970
2017
|
lastTop = toolArray[x].top;
|
|
1971
2018
|
}
|
|
@@ -2067,7 +2114,7 @@ function Milli_Chart(settings) {
|
|
|
2067
2114
|
m_chartspaces.chart.right = m_canvas.getWidth()- getScaledSetting(m_chartCss.marginRight);// - 50;
|
|
2068
2115
|
m_chartspaces.chart.marginBottom = getScaledSetting(m_chartCss.marginBottom);
|
|
2069
2116
|
m_chartspaces.chart.bottom = (m_chartspaces.chart.height - m_chartspaces.chart.marginBottom);
|
|
2070
|
-
m_chartspaces.chart.width = m_canvas.getWidth()
|
|
2117
|
+
m_chartspaces.chart.width = m_canvas.getWidth();
|
|
2071
2118
|
|
|
2072
2119
|
m_chartspaces.lowerChart.marginBottom = getScaledSetting(20) / window.devicePixelRatio;
|
|
2073
2120
|
m_chartspaces.lowerChart.marginTop = getScaledSetting(0);
|
|
@@ -2076,7 +2123,7 @@ function Milli_Chart(settings) {
|
|
|
2076
2123
|
m_chartspaces.lowerChart.left = m_chartspaces.chart.left;
|
|
2077
2124
|
m_chartspaces.lowerChart.right = m_chartspaces.chart.right;
|
|
2078
2125
|
m_chartspaces.lowerChart.bottom = m_canvas.getHeight() - m_chartspaces.lowerChart.marginBottom;
|
|
2079
|
-
m_chartspaces.lowerChart.width = m_canvas.getWidth()
|
|
2126
|
+
m_chartspaces.lowerChart.width = m_canvas.getWidth();
|
|
2080
2127
|
}
|
|
2081
2128
|
|
|
2082
2129
|
function calculateIndicators() {
|
|
@@ -2149,12 +2196,12 @@ function Milli_Chart(settings) {
|
|
|
2149
2196
|
return;
|
|
2150
2197
|
}
|
|
2151
2198
|
calcChartSpaces();
|
|
2152
|
-
|
|
2153
2199
|
m_ctx.clearRect(0, 0, m_canvas.getWidth(), m_canvas.getHeight());
|
|
2154
2200
|
m_ctx.lineWidth = 1 / 1;
|
|
2155
2201
|
m_ctx.textBaseline = 'top'; // important!
|
|
2156
2202
|
var s;
|
|
2157
2203
|
if (period == 'd' && _this.settings.chartlen != 'ytd') {
|
|
2204
|
+
if(_this.instruments[0].trades.length == 0) return;
|
|
2158
2205
|
if (m_zoom.mousedown.timestamp) {
|
|
2159
2206
|
_this.scaleinfoX.endTimeStamp = m_zoom.mouseup.timestamp > m_zoom.mousedown.timestamp ? m_zoom.mouseup.timestamp : m_zoom.mousedown.timestamp;
|
|
2160
2207
|
_this.scaleinfoX.startTimeStamp = m_zoom.mouseup.timestamp < m_zoom.mousedown.timestamp ? m_zoom.mouseup.timestamp : m_zoom.mousedown.timestamp;
|
|
@@ -2181,17 +2228,14 @@ function Milli_Chart(settings) {
|
|
|
2181
2228
|
|
|
2182
2229
|
var tradetimestamp = new Date(_this.instruments[0].trades[_this.instruments[0].trades.length - 1].timestamp).getTime();
|
|
2183
2230
|
var closetimestamp = new Date(new Date(_this.instruments[0].trades[_this.instruments[0].trades.length - 1].timestamp).toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketclose + 'Z').getTime();
|
|
2184
|
-
//console.log(tradetimestamp,closetimestamp);
|
|
2185
2231
|
if (closetimestamp < tradetimestamp)
|
|
2186
2232
|
_this.scaleinfoX.endTimeStamp = new Date(closetimestamp); // borde inte rita med closeprice1d då heller eller spelar det ingen roll?
|
|
2187
2233
|
else
|
|
2188
2234
|
_this.scaleinfoX.endTimeStamp = new Date(tradetimestamp);
|
|
2189
|
-
//console.log(new Date(_this.scaleinfoX.endTimeStamp));
|
|
2190
2235
|
}
|
|
2191
2236
|
if (_this.scaleinfoX.endTimeStamp - (_this.scaleinfoX.endTimeStamp % 86400000) > _this.instruments[0].quotedate) {
|
|
2192
2237
|
_this.scaleinfoX.endTimeStamp -= _this.scaleinfoX.endTimeStamp - _this.scaleinfoX.endTimeStamp % 86400000;
|
|
2193
2238
|
_this.scaleinfoX.endTimeStamp += _this.instruments[0].quotedate; // set enddate = last Quotedate
|
|
2194
|
-
//console.log('asdasd',new Date(_this.scaleinfoX.endTimeStamp));
|
|
2195
2239
|
}
|
|
2196
2240
|
|
|
2197
2241
|
for (var i = 0; i < _this.settings.indicators.length; i++) {
|
|
@@ -2201,7 +2245,6 @@ function Milli_Chart(settings) {
|
|
|
2201
2245
|
}
|
|
2202
2246
|
}
|
|
2203
2247
|
}
|
|
2204
|
-
//console.log(new Date(_this.scaleinfoX.startTimeStamp),new Date(_this.scaleinfoX.endTimeStamp),new Date(_this.instruments[0].quotedate));
|
|
2205
2248
|
setTimeSpanData();
|
|
2206
2249
|
if (_this.settings.absoluteScaling == true) {
|
|
2207
2250
|
for (s = 1; s < _this.instruments.length; s++) _this.instruments[s].factor = 1;
|
|
@@ -2209,7 +2252,7 @@ function Milli_Chart(settings) {
|
|
|
2209
2252
|
if (_this.instruments.length > 1) {
|
|
2210
2253
|
// calc factors
|
|
2211
2254
|
var instrumentprice;
|
|
2212
|
-
for (i = 0; i < _this.instruments[0].trades.length; i++) {
|
|
2255
|
+
for (let i = 0; i < _this.instruments[0].trades.length; i++) {
|
|
2213
2256
|
if (_this.instruments[0].trades[i].timestamp >= _this.scaleinfoX.startTimeStamp) {
|
|
2214
2257
|
instrumentprice = _this.instruments[0].trades[i].price;
|
|
2215
2258
|
break;
|
|
@@ -2217,7 +2260,7 @@ function Milli_Chart(settings) {
|
|
|
2217
2260
|
}
|
|
2218
2261
|
for (s = 1; s < _this.instruments.length; s++) {
|
|
2219
2262
|
if (_this.instruments[s].insref != 0) {
|
|
2220
|
-
for (i = 0; i < _this.instruments[s].trades.length; i++) {
|
|
2263
|
+
for (let i = 0; i < _this.instruments[s].trades.length; i++) {
|
|
2221
2264
|
if (_this.instruments[s].trades[i].timestamp >= _this.scaleinfoX.startTimeStamp) {
|
|
2222
2265
|
_this.instruments[s].factor = instrumentprice / _this.instruments[s].trades[i].price;
|
|
2223
2266
|
break;
|
|
@@ -2266,6 +2309,7 @@ function Milli_Chart(settings) {
|
|
|
2266
2309
|
|
|
2267
2310
|
} else
|
|
2268
2311
|
if (period == 'm') {
|
|
2312
|
+
if(_this.instruments[0].history.length == 0) return;
|
|
2269
2313
|
if (m_zoom.mousedown.timestamp) {
|
|
2270
2314
|
_this.scaleinfoX.startTimeStamp = m_zoom.mousedown.timestamp > m_zoom.mouseup.timestamp ? m_zoom.mouseup.timestamp : m_zoom.mousedown.timestamp;
|
|
2271
2315
|
_this.scaleinfoX.endTimeStamp = m_zoom.mousedown.timestamp > m_zoom.mouseup.timestamp ? m_zoom.mousedown.timestamp : m_zoom.mouseup.timestamp;
|
|
@@ -2334,6 +2378,7 @@ function Milli_Chart(settings) {
|
|
|
2334
2378
|
}
|
|
2335
2379
|
} else
|
|
2336
2380
|
if ((period == 'y' || _this.settings.chartlen == 'ytd' || _this.settings.chartlen == 'max')) {
|
|
2381
|
+
if(_this.instruments[0].history.length == 0) return;
|
|
2337
2382
|
if (m_zoom.mousedown.timestamp) {
|
|
2338
2383
|
_this.scaleinfoX.startTimeStamp = m_zoom.mousedown.timestamp > m_zoom.mouseup.timestamp ? m_zoom.mouseup.timestamp : m_zoom.mousedown.timestamp;
|
|
2339
2384
|
_this.scaleinfoX.startTimeStamp -= (_this.scaleinfoX.startTimeStamp % 3600000);
|
|
@@ -3636,8 +3681,9 @@ function Milli_Chart(settings) {
|
|
|
3636
3681
|
parseData(resp[0], 1);
|
|
3637
3682
|
var period = _this.settings.chartlen.substring(_this.settings.chartlen.length - 1);
|
|
3638
3683
|
var len = parseInt(_this.settings.chartlen.substring(0, _this.settings.chartlen.length - 1));
|
|
3639
|
-
if ((period == 'd' && _this.settings.chartlen != 'ytd') && typeof resp[0].trades === 'undefined') {
|
|
3640
|
-
|
|
3684
|
+
//if ((period == 'd' && _this.settings.chartlen != 'ytd') && typeof resp[0].trades === 'undefined') {
|
|
3685
|
+
if ((period == 'd' && _this.settings.chartlen != 'ytd') && typeof _this.instruments[0].trades === 'undefined' ) {
|
|
3686
|
+
return;
|
|
3641
3687
|
}
|
|
3642
3688
|
if ((period == 'm' || period == 'y' || _this.settings.chartlen == 'ytd' || _this.settings.chartlen == 'max') && typeof resp[0].history === 'undefined') {
|
|
3643
3689
|
return;
|
|
@@ -3651,7 +3697,7 @@ function Milli_Chart(settings) {
|
|
|
3651
3697
|
setChartSize();
|
|
3652
3698
|
m_canvas.addEventListener('mousemove', onMouseMove, false); // disable while loading and enable on drawReady
|
|
3653
3699
|
m_canvas.addEventListener('mouseout', onMouseOut, false);
|
|
3654
|
-
m_canvas.style.cursor = "crosshair";
|
|
3700
|
+
m_canvas.style.cursor = _this.settings.cursor; //"crosshair";
|
|
3655
3701
|
m_canvas.onmousedown = (function(evt) {
|
|
3656
3702
|
if (evt.which != 1) return; // ignore right and middle
|
|
3657
3703
|
var rect = m_canvas.getBoundingClientRect();
|
|
@@ -6954,9 +7000,15 @@ function formatDate(date, format, widget) {
|
|
|
6954
7000
|
}
|
|
6955
7001
|
if (format == 'b dd') { // Jan 01
|
|
6956
7002
|
timeStamp = new Date(date);
|
|
6957
|
-
|
|
7003
|
+
if(typeof widget.settings.locale !== 'undefined') {
|
|
7004
|
+
mon = timeStamp.toLocaleString(widget.settings.locale, { month: 'short' }).substring(0, 3);
|
|
7005
|
+
}
|
|
7006
|
+
else {
|
|
7007
|
+
mon = timeStamp.toDateString().split(' ');
|
|
7008
|
+
mon = mon[1];
|
|
7009
|
+
}
|
|
6958
7010
|
day = timeStamp.getDate();
|
|
6959
|
-
return mon
|
|
7011
|
+
return mon + ' ' + (day <= 9 ? '0' + day : day);
|
|
6960
7012
|
}
|
|
6961
7013
|
if (format == 'b dd yyyy') { // Jan 01 2017
|
|
6962
7014
|
timeStamp = new Date(date);
|