@millistream/millistream-widgets 0.0.13 → 0.0.14
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 +39 -16
- package/package.json +1 -1
package/millistream-widgets.js
CHANGED
|
@@ -1053,7 +1053,7 @@ function Milli_Chart(settings) {
|
|
|
1053
1053
|
pixelsperday[i] = arr[i] * timePerPixel;
|
|
1054
1054
|
}
|
|
1055
1055
|
var x = totalmilli / maxLegendItems / 60000;
|
|
1056
|
-
numticks = maxLegendItems;
|
|
1056
|
+
var numticks = maxLegendItems;
|
|
1057
1057
|
|
|
1058
1058
|
_this.scaleinfoX.milliPerDay = new Date('2019-01-01T' + _this.instruments[0].marketclose + 'Z') - new Date('2019-01-01T' + _this.instruments[0].marketopen + 'Z');
|
|
1059
1059
|
_this.scaleinfoX.timePerPixel = timePerPixel;
|
|
@@ -1179,43 +1179,69 @@ function Milli_Chart(settings) {
|
|
|
1179
1179
|
maxHourLegends = Math.floor((_this.scaleinfoX.lineLength - legendItems[0].x - getMaxTimeWidth()) / (getMaxTimeWidth() * 3));
|
|
1180
1180
|
else
|
|
1181
1181
|
maxHourLegends = Math.floor((legendItems[1].x - legendItems[0].x - getMaxTimeWidth()) / (getMaxTimeWidth() * 3));
|
|
1182
|
-
var tickSize
|
|
1183
|
-
|
|
1184
|
-
|
|
1182
|
+
var tickSize;
|
|
1183
|
+
if (m_zoom.isZooming) {
|
|
1184
|
+
console.log(starttime, endtime);
|
|
1185
|
+
tickSize = new Date(endtime - starttime);
|
|
1186
|
+
console.log(tickSize.getTime());
|
|
1187
|
+
} else
|
|
1188
|
+
tickSize = new Date(new Date(currentDate.toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketclose + 'Z') - new Date(currentDate.toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketopen + 'Z'));
|
|
1189
|
+
var interval;
|
|
1190
|
+
var modularvalue = 3600000;
|
|
1191
|
+
if (tickSize.getTime() < 3600000) {
|
|
1192
|
+
tickSize = tickSize.getTime() / 300000;
|
|
1193
|
+
interval = Math.floor(tickSize / (maxHourLegends + 1)) * 300000;
|
|
1194
|
+
modularvalue = 300000;
|
|
1195
|
+
} else
|
|
1196
|
+
if (tickSize.getTime() < 7200000 * 3) {
|
|
1197
|
+
tickSize = tickSize.getTime() / 600000;
|
|
1198
|
+
interval = Math.floor(tickSize / (maxHourLegends + 1)) * 600000;
|
|
1199
|
+
modularvalue = 600000;
|
|
1200
|
+
} else {
|
|
1201
|
+
tickSize = tickSize.getTime() / 3600000;
|
|
1202
|
+
interval = Math.floor(tickSize / (maxHourLegends + 1)) * 3600000;
|
|
1203
|
+
}
|
|
1204
|
+
if (interval == 0) interval = 300000;
|
|
1205
|
+
|
|
1185
1206
|
console.log('MAX', maxHourLegends, tickSize, interval);
|
|
1186
1207
|
// print other times
|
|
1187
1208
|
offset = 0;
|
|
1188
1209
|
lastx = 0;
|
|
1189
1210
|
var closeTime = new Date(currentDate.toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketclose + 'Z');
|
|
1190
1211
|
var workDate = new Date(currentDate);
|
|
1212
|
+
var currentDate = new Date(startdate);
|
|
1213
|
+
if (currentDate.getTime() % modularvalue != 0) // if not full hour, move up to next full hour
|
|
1214
|
+
currentDate = new Date(currentDate.getTime() - currentDate.getTime() % modularvalue + modularvalue); // START om full hour (if modulo == 0 then + 3600000 kanske)
|
|
1215
|
+
|
|
1191
1216
|
console.log('workdate', workDate);
|
|
1217
|
+
var count = 0;
|
|
1192
1218
|
while (currentDate.getTime() < _this.scaleinfoX.endTimeStamp) {
|
|
1193
1219
|
console.log('workdate', workDate);
|
|
1220
|
+
if (count++ > 30) break;
|
|
1194
1221
|
draw = true;
|
|
1195
1222
|
while (currentDate.getDay() == 0 || currentDate.getDay() == 6) { // move past weekends , maybe skip this if date is available in data
|
|
1196
1223
|
console.log('Helg', currentDate);
|
|
1197
1224
|
closeTime = new Date(closeTime.getTime() + 86400000);
|
|
1198
1225
|
currentDate = new Date(currentDate.getTime() + 86400000);
|
|
1199
1226
|
//currentDate = new Date(currentDate.getTime() + currentDate.getTime() % 3600000); // START om full hour (if modulo == 0 then + 3600000 kanske)
|
|
1200
|
-
if (currentDate.getTime() %
|
|
1201
|
-
currentDate = new Date(currentDate.getTime() - currentDate.getTime() %
|
|
1227
|
+
if (currentDate.getTime() % modularvalue != 0) // if not full hour, move up to next full hour
|
|
1228
|
+
currentDate = new Date(currentDate.getTime() - currentDate.getTime() % modularvalue + modularvalue); // START om full hour (if modulo == 0 then + 3600000 kanske)
|
|
1202
1229
|
var workDate = new Date(workDate.getTime() + 86400000);
|
|
1203
1230
|
offset += 86400000 / _this.scaleinfoX.timePerPixel;
|
|
1204
1231
|
}
|
|
1205
1232
|
console.log(currentDate, closeTime);
|
|
1206
1233
|
if (currentDate.getTime() > closeTime.getTime()) {
|
|
1207
1234
|
// draw DayEnd(start) dash line
|
|
1208
|
-
var dayStart = new Date(
|
|
1209
|
-
x = Math.round(parseInt(m_chartCss['margin-left']) + ((
|
|
1210
|
-
drawXAxisGridlines({ 'x': x, y: m_canvas.height - parseInt(m_chartCss['margin-bottom']) }); // dash
|
|
1235
|
+
/*var dayStart = new Date(workDate.toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketclose + 'Z')
|
|
1236
|
+
x = Math.round(parseInt(m_chartCss['margin-left']) + ((dayStart.getTime() - _this.scaleinfoX.startDate.getTime()) / _this.scaleinfoX.timePerPixel) - offset);
|
|
1237
|
+
drawXAxisGridlines({ 'x': x, y: m_canvas.height - parseInt(m_chartCss['margin-bottom']) }, true); // dash?*/
|
|
1211
1238
|
|
|
1212
1239
|
|
|
1213
1240
|
closeTime = new Date(closeTime.getTime() + 86400000);
|
|
1214
1241
|
workDate = new Date(workDate.getTime() + 86400000);
|
|
1215
1242
|
currentDate = new Date(workDate.toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketopen + 'Z');
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
currentDate = new Date(currentDate.getTime() - currentDate.getTime() % 3600000 + 3600000); // START om full hour (if modulo == 0 then + 3600000 kanske)
|
|
1243
|
+
if (currentDate.getTime() % modularvalue != 0) // if not full hour, move up to next full hour
|
|
1244
|
+
currentDate = new Date(currentDate.getTime() - currentDate.getTime() % modularvalue + modularvalue); // START om full hour (if modulo == 0 then + 3600000 kanske)
|
|
1219
1245
|
offset += (86400000 - _this.scaleinfoX.milliPerDay) / _this.scaleinfoX.timePerPixel;
|
|
1220
1246
|
console.log('CLOSED', currentDate, closeTime);
|
|
1221
1247
|
continue;
|
|
@@ -1223,22 +1249,19 @@ function Milli_Chart(settings) {
|
|
|
1223
1249
|
console.log(currentDate, closeTime);
|
|
1224
1250
|
x = Math.round(parseInt(m_chartCss['margin-left']) + ((currentDate.getTime() - _this.scaleinfoX.startDate.getTime()) / _this.scaleinfoX.timePerPixel) - offset);
|
|
1225
1251
|
for (var i = 0; i < legendItems.length; i++) {
|
|
1226
|
-
console.log('loop', x, legendItems[i].x);
|
|
1227
1252
|
if (x < legendItems[i].x && x + (getMaxTimeWidth() / 2) > (legendItems[i].x - getMaxTimeWidth())) {
|
|
1228
1253
|
draw = false;
|
|
1229
|
-
console.log('False1');
|
|
1230
1254
|
break;
|
|
1231
1255
|
}
|
|
1232
1256
|
if (x > legendItems[i].x && legendItems[i].x + (getMaxTimeWidth() / 2) > (x - getMaxTimeWidth())) {
|
|
1233
1257
|
draw = false;
|
|
1234
|
-
console.log('False2');
|
|
1235
1258
|
break;
|
|
1236
1259
|
}
|
|
1237
1260
|
}
|
|
1238
1261
|
console.log(x, lastx, offset);
|
|
1239
1262
|
if (lastx + (getMaxTimeWidth() / 2) > (x - getMaxTimeWidth())) {
|
|
1240
1263
|
//draw = false;
|
|
1241
|
-
console.log('false');
|
|
1264
|
+
//console.log('false');
|
|
1242
1265
|
}
|
|
1243
1266
|
if (draw) {
|
|
1244
1267
|
lastx = x;
|