@millistream/millistream-widgets 0.0.14 → 0.0.15

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.
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  function Milli_Chart(settings) {
2
4
  var _this = this;
3
5
  _this.mdf_fields = [];
@@ -580,7 +582,7 @@ function Milli_Chart(settings) {
580
582
  m_ctx.strokeStyle = m_gridHorizontalCss.color;
581
583
  m_ctx.font = m_yLegendCss['font-weight'] + ' ' + m_yLegendCss['font-size'] + ' ' + m_yLegendCss['font-family'];
582
584
  m_ctx.fillStyle = m_yLegendCss.color;
583
- if (_this.settings.chartlen == '1d' || _this.settings.chartlen == '0d') firstvalue = _this.instruments[0].closeprice1d;
585
+ //if (_this.settings.chartlen == '1d' || _this.settings.chartlen == '0d') firstvalue = _this.instruments[0].closeprice1d;
584
586
 
585
587
  if (0 == calcHighLow()) {
586
588
  // console.log('no data to draw on');
@@ -1108,6 +1110,14 @@ function Milli_Chart(settings) {
1108
1110
  return datetime.toTimeString().substring(0, 8);
1109
1111
  }
1110
1112
 
1113
+ function calcTimeSpanInDays(startdate, enddate) {
1114
+ console.log(startdate, enddate)
1115
+ var s = Math.ceil(startdate / 86400000) * 86400000;
1116
+ var e = Math.ceil(enddate / 86400000) * 86400000;
1117
+ console.log(e - s / 86400000);
1118
+
1119
+ }
1120
+
1111
1121
  function drawXAxisTick(starttime, endtime) {
1112
1122
  m_ctx.save();
1113
1123
  m_ctx.font = m_xLegendCss['font-weight'] + ' ' + m_xLegendCss['font-size'] + ' ' + m_xLegendCss['font-family'];
@@ -1180,12 +1190,14 @@ function Milli_Chart(settings) {
1180
1190
  else
1181
1191
  maxHourLegends = Math.floor((legendItems[1].x - legendItems[0].x - getMaxTimeWidth()) / (getMaxTimeWidth() * 3));
1182
1192
  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'));
1193
+ calcTimeSpanInDays(starttime, endtime);
1194
+
1195
+ //if (m_zoom.isZooming) {
1196
+ console.log(starttime, endtime);
1197
+ tickSize = new Date(endtime - starttime);
1198
+ console.log(tickSize.getTime());
1199
+ //} else
1200
+ // 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
1201
  var interval;
1190
1202
  var modularvalue = 3600000;
1191
1203
  if (tickSize.getTime() < 3600000) {
@@ -1209,7 +1221,7 @@ function Milli_Chart(settings) {
1209
1221
  lastx = 0;
1210
1222
  var closeTime = new Date(currentDate.toISOString().substring(0, 10) + 'T' + _this.instruments[0].marketclose + 'Z');
1211
1223
  var workDate = new Date(currentDate);
1212
- var currentDate = new Date(startdate);
1224
+ currentDate = new Date(starttime);
1213
1225
  if (currentDate.getTime() % modularvalue != 0) // if not full hour, move up to next full hour
1214
1226
  currentDate = new Date(currentDate.getTime() - currentDate.getTime() % modularvalue + modularvalue); // START om full hour (if modulo == 0 then + 3600000 kanske)
1215
1227
 
@@ -1868,8 +1880,8 @@ function Milli_Chart(settings) {
1868
1880
 
1869
1881
  function setTimeSpanData() {
1870
1882
  if (typeof _this.settings.timespanelement === 'undefined' || _this.settings.timespanelement == null) return;
1871
- startdate = new Date(_this.scaleinfoX.startTimeStamp);
1872
- enddate = new Date(_this.scaleinfoX.endTimeStamp);
1883
+ var startdate = new Date(_this.scaleinfoX.startTimeStamp);
1884
+ var enddate = new Date(_this.scaleinfoX.endTimeStamp);
1873
1885
  if (startdate.getTime() - (startdate.getTime() % 86400000) == enddate.getTime() - (enddate.getTime() % 86400000)) {
1874
1886
  _this.settings.timespanelement.innerHTML = startdate.toTimeString().substring(0, 8) + ' - ' + enddate.toTimeString().substring(0, 8);
1875
1887
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@millistream/millistream-widgets",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "Millistream widgets node package",
5
5
  "main": "millistream-widgets.js",
6
6
  "scripts": {