Moment.js doesn't show correct time - momentjs

When running my node.js project locally on my computer, moment.js is showing correct time (2019-10-28T07:00:00.000Z because moment have adjusted for DST +02:00 in april and +01:00 in october)):
Moment {
_isAMomentObject: true,
_i: '2019-04-15T06:00:00.000Z',
_f: 'YYYY-MM-DDTHH:mm:ss.SSSSZ',
_tzm: 0,
_isUTC: false,
_pf:
{ empty: false,
unusedTokens: [],
unusedInput: [],
overflow: -1,
charsLeftOver: 0,
nullInput: false,
invalidMonth: null,
invalidFormat: false,
userInvalidated: false,
iso: true,
parsedDateParts: [ 2019, 3, 15, 6, 0, 0, 0 ],
meridiem: undefined,
rfc2822: false,
weekdayMismatch: false },
_locale:
Locale {
_calendar:
{ sameDay: '[Today at] LT',
nextDay: '[Tomorrow at] LT',
nextWeek: 'dddd [at] LT',
lastDay: '[Yesterday at] LT',
lastWeek: '[Last] dddd [at] LT',
sameElse: 'L' },
_longDateFormat:
{ LTS: 'h:mm:ss A',
LT: 'h:mm A',
L: 'MM/DD/YYYY',
LL: 'MMMM D, YYYY',
LLL: 'MMMM D, YYYY h:mm A',
LLLL: 'dddd, MMMM D, YYYY h:mm A' },
_invalidDate: 'Invalid date',
ordinal: [Function: ordinal],
_dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
_relativeTime:
{ future: 'in %s',
past: '%s ago',
s: 'a few seconds',
ss: '%d seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years' },
_months:
[ 'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December' ],
_monthsShort:
[ 'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec' ],
_week: { dow: 0, doy: 6 },
_weekdays:
[ 'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday' ],
_weekdaysMin: [ 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ],
_weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
_meridiemParse: /[ap]\.?m?\.?/i,
_abbr: 'en',
_config:
{ calendar: [Object],
longDateFormat: [Object],
invalidDate: 'Invalid date',
ordinal: [Function: ordinal],
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
relativeTime: [Object],
months: [Array],
monthsShort: [Array],
week: [Object],
weekdays: [Array],
weekdaysMin: [Array],
weekdaysShort: [Array],
meridiemParse: /[ap]\.?m?\.?/i,
abbr: 'en' },
_dayOfMonthOrdinalParseLenient: /\d{1,2}(th|st|nd|rd)|\d{1,2}/ },
_a: [ 2019, 3, 15, 6, 0, 0, 0 ],
_d: 2019-10-28T07:00:00.000Z,
_isValid: true,
_z: null }
But on my server, I get this:
Moment {
_isAMomentObject: true,
_i: '2019-04-15T06:00:00.000Z',
_f: 'YYYY-MM-DDTHH:mm:ss.SSSSZ',
week: [Object],
weekdays: [Array],
weekdaysMin: [Array],
weekdaysShort: [Array],
meridiemParse: /[ap]\.?m?\.?/i,
abbr: 'en' },
_dayOfMonthOrdinalParseLenient: /\d{1,2}(th|st|nd|rd)|\d{1,2}/ },
_a: [ 2019, 3, 15, 6, 0, 0, 0 ],
_d: 2019-10-28T06:00:00.000Z,
_isValid: true,
_z: null }
The date is incorrectly set to 2019-10-28T06:00:00:000Z.
I have set the timezone on the server with sudo timedatectl set-timezone Europe/Oslo
If I am using moment.isDST() for dates on the server, it correctly gives my true in April and false in October.
I am unsure how to solve this, on the server or in my code?

I think I solved it. By answering the from Styx questions, I finally realized that the server app running in a docker container didn't have the correct timezone. By setting environment: TZ: "Europe/Oslo" in the docker-compose.yml file this fixed the problem, and I am getting correct time now.

Related

Business hours and labels in fullcalendar scheduler

I'm trying to use scheduler in order to show classes time from one entire day. The problem is that class time is 50 minutes, and between some classes has interval.
I did that using business hours, but it has a strange behavior in labels. Labels do not respect business time, the only thing I could do is show labels from 50 to 50 minutes too, but it is not enough because of intervals.
See below how it shows:
And now, how I would like it is:
And here is my code:
<script>
$(function(){
var todayDate = moment().startOf('day');
var YESTERDAY = todayDate.clone().subtract(1, 'day').format('YYYY-MM-DD');
var TODAY = todayDate.format('YYYY-MM-DD');
var TOMORROW = todayDate.clone().add(1, 'day').format('YYYY-MM-DD');
$('#calendar').fullCalendar({
resourceAreaWidth: 230,
editable: true,
aspectRatio: 1.5,
scrollTime: '07:25',
slotLabelInterval: '00:50:00',
slotDuration: '00:50:00',
slotLabelFormat: 'HH:mm',
defaultView: 'timelineDay',
resourceLabelText: 'Turma / Sub-turma',
businessHours: [
{ id: 'a1', start: '07:25:00', end: '08:15:00', dow: [0,1,2,3,4,5] },
{ id: 'a2', start: '08:15:00', end: '09:05:00', dow: [0,1,2,3,4,5] },
{ id: 'a3', start: '09:20:00', end: '10:10:00', dow: [0,1,2,3,4,5] },
{ id: 'a4', start: '10:10:00', end: '11:00:00', dow: [0,1,2,3,4,5] },
{ id: 'a5', start: '11:10:00', end: '12:00:00', dow: [0,1,2,3,4,5] },
{ id: 'a6', start: '12:00:00', end: '12:50:00', dow: [0,1,2,3,4,5] },
{ id: 'a7', start: '13:15:00', end: '14:05:00', dow: [0,1,2,3,4,5] },
{ id: 'a8', start: '14:05:00', end: '14:55:00', dow: [0,1,2,3,4,5] },
{ id: 'a9', start: '15:10:00', end: '16:00:00', dow: [0,1,2,3,4,5] },
{ id: 'a10', start: '16:00:00', end: '16:50:00', dow: [0,1,2,3,4,5] },
{ id: 'a11', start: '17:00:00', end: '17:50:00', dow: [0,1,2,3,4,5] },
{ id: 'a12', start: '17:50:00', end: '18:40:00', dow: [0,1,2,3,4,5] },
{ id: 'a13', start: '19:00:00', end: '19:50:00', dow: [0,1,2,3,4,5] },
{ id: 'a14', start: '19:50:00', end: '20:40:00', dow: [0,1,2,3,4,5] },
{ id: 'a15', start: '20:55:00', end: '21:45:00', dow: [0,1,2,3,4,5] },
{ id: 'a16', start: '21:45:00', end: '22:35:00', dow: [0,1,2,3,4,5] }
],
minTime: '07:25:00',
maxTime: '22:35:00',
resources: [
{ id: 'd', title: '1ยบ Semestre', children: [
{ id: 'd1', title: 'Turma A', children: [
{ id: 'd11', title: 'Sub-turma A' },
{ id: 'd12', title: 'Sub-turma B' },
] },
{ id: 'd2', title: 'Turma B' }
] },
],
events: [
{ id: 'e1', resourceId: 'd2', start: TODAY + 'T07:25:00', end: TODAY + 'T08:15:00', title: 'event ' },
{ id: 'e2', resourceId: 'd2', start: TODAY + 'T08:15:00', end: TODAY + 'T09:05:00', title: 'event ' },
{ id: 'e3', resourceId: 'd2', start: TODAY + 'T09:20:00', end: TODAY + 'T10:10:00', title: 'event ' },
{ id: 'e4', resourceId: 'd2', start: TODAY + 'T10:10:00', end: TODAY + 'T11:00:00', title: 'event ' },
{ id: 'e5', resourceId: 'd2', start: TODAY + 'T11:10:00', end: TODAY + 'T12:00:00', title: 'event ' },
{ id: 'e6', resourceId: 'd2', start: TODAY + 'T12:00:00', end: TODAY + 'T12:50:00', title: 'event ' },
{ id: 'e7', resourceId: 'd2', start: TODAY + 'T13:15:00', end: TODAY + 'T14:05:00', title: 'event ' },
{ id: 'e8', resourceId: 'd2', start: TODAY + 'T14:05:00', end: TODAY + 'T14:55:00', title: 'event ' },
{ id: 'e9', resourceId: 'd2', start: TODAY + 'T15:10:00', end: TODAY + 'T16:00:00', title: 'event ' },
{ id: 'e10', resourceId: 'd2', start: TODAY + 'T16:00:00', end: TODAY + 'T16:50:00', title: 'event ' },
{ id: 'e11', resourceId: 'd2', start: TODAY + 'T17:00:00', end: TODAY + 'T17:50:00', title: 'event ' },
{ id: 'e12', resourceId: 'd2', start: TODAY + 'T17:50:00', end: TODAY + 'T18:40:00', title: 'event ' },
{ id: 'e13', resourceId: 'd2', start: TODAY + 'T19:00:00', end: TODAY + 'T19:50:00', title: 'event ' },
{ id: 'e14', resourceId: 'd2', start: TODAY + 'T19:50:00', end: TODAY + 'T20:40:00', title: 'event ' },
{ id: 'e15', resourceId: 'd2', start: TODAY + 'T20:55:00', end: TODAY + 'T21:45:00', title: 'event ' },
{ id: 'e16', resourceId: 'd2', start: TODAY + 'T21:45:00', end: TODAY + 'T22:35:00', title: 'event ' },
]
});
});
</script>
Please help-me!!
Best regards

HighCharts: wrong data shown on datetime xaxis

I have a wrong point data shown.
It doesn't show the correct data, check out the picture.
Startpoint is Date.UTC(2016, 06, 30) and not the Date.UTC(2016, 07, 30) as in the tooltip. Here is the result I get:
$(function() {
Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Waterflow'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
day: '%e'
},
title: {
text: 'Date'
}
},
yAxis: {
title: {
text: 'Flow im Mio'
},
min: 0
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x:%e. %b}: {point.y:.2f} m'
},
plotOptions: {
spline: {
marker: {
enabled: true
}
}
},
series: [{
name: 'Main',
data: ([
[Date.UTC(2016, 06, 30), 3072.541365],
[Date.UTC(2016, 07, 31), 3315.618228],
[Date.UTC(2016, 08, 31), 3367.458135],
[Date.UTC(2016, 09, 30), 3370.195785],
[Date.UTC(2016, 10, 31), 3424.501986],
[Date.UTC(2016, 11, 30), 3479.865412],
[Date.UTC(2016, 12, 31), 3521.730275],
])
}, ]
});
});
In Date.UTC(Year,Month*,Day,Hour,Minute,Seconds) the Month is starting from 0. This is mentioned in the documentation.
So to specify the month June you have to use 5 and not 6.

How to achieve this graph with highcharts

How could I achieve the chart below as accurate as possible?
I'm trying to achieve the chart in the picture below with highcharts, the problem I have is that I can't achieve the gradients and the purple cut-line
this is what I have donde so far : jsFiddle
$(function () {
$('#container').highcharts({
chart: {
type: 'areaspline'
},
options: {
title: {
text: "Historical report"
},
heigth: 200
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 150,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
xAxis: {
categories: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
plotBands: [
{
from: 4.5,
to: 6.5,
color: 'rgba(68, 170, 213, .2)'
}
]
},
yAxis: {
title: {
text: 'Fruit units'
}
},
tooltip: {
shared: true,
valueSuffix: ' units'
},
credits: {
enabled: false
},
plotOptions: {
areaspline: {
fillOpacity: 0.5
}
},
series: [
{
name: 'John',
data: [3, 9, null, 5, 4, 10, 12],
lineColor: "#5A66AF"
}, {
name: 'Jane',
data: [1, 10, null, 3, 3, 5, 4],
lineColor: '#47a06b'
}, {
name: 'Roberto',
data: [10, 15, null, 15, 9, 9, 4],
lineColor: '#2ba9db'
}
]
});
});
The line is achieved by the DashStyle property:
http://api.highcharts.com/highcharts#plotOptions.line.dashStyle
The gradient fill is a matter of defining the gradient stops in the fillColor property:
http://api.highcharts.com/highcharts#plotOptions.area.fillColor
http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/area-fillcolor-gradient/
(though, FWIW, that extreme white end to the gradient is reeeeally distracting...)

Sendgrid Inbound Webhook Sending Empty Body

Trying to get Sendgrid's Inbound Parse Webhook following their instructions here
Using Meteor and Iron Router. I am capturing the request but the request body is empty. I'm following this tutorial https://sendgrid.com/blog/receive-inbound-email-meteorjs/ and https://sendgrid.com/blog/control-home-lighting-parse-webhook/, but when I do a console.log(this.request.body), it's returning an empty object {}.
I've also tried getting text (this.request.text), html, from, to, subject, but nothing. The only thing I've had success getting is this.request.headers.
The Sendgrid activity dashboard does show that the emails are being parsed, and I am clearly receiving them, but the body is empty. This is unexpected behaviour and I'm not sure how to troubleshoot. Can anybody point me in the right direction? Thanks. Here's a sample request.
{ _readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: false,
calledRead: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: { close: [Function] },
_maxListeners: 10,
socket:
{ _connecting: false,
_handle:
{ fd: 34,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: true,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
drain: [Object],
timeout: [Function],
error: [Function],
close: [Object] },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [],
errorEmitted: false },
writable: true,
allowHalfOpen: true,
onend: [Function],
destroyed: false,
bytesRead: 8249,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: 10,
_connections: 1,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: true,
httpAllowHalfOpen: false,
timeout: 5000,
_connectionKey: '4:0.0.0.0:23683' },
_idleTimeout: 5000,
_idleNext:
{ _connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
bytesRead: 79134,
_bytesDispatched: 14036,
_pendingData: null,
_pendingEncoding: '',
_idleTimeout: 30000,
_idleNext: [Object],
_idlePrev: [Circular],
_idleStart: 1459115857090,
_monotonicStartTime: 543430569,
pipe: [Function],
addListener: [Function: addListener],
on: [Function: addListener],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
_idlePrev: { _idleNext: [Circular], _idlePrev: [Object] },
_idleStart: 1459115857771,
_monotonicStartTime: 543431251,
parser:
{ _headers: [],
_url: '',
onHeaders: [Function: parserOnHeaders],
onHeadersComplete: [Function: parserOnHeadersComplete],
onBody: [Function: parserOnBody],
onMessageComplete: [Function: parserOnMessageComplete],
socket: [Circular],
incoming: [Circular],
maxHeaderPairs: 2000,
onIncoming: [Function] },
ondata: [Function],
_paused: false,
_httpMessage:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_headerSent: false,
_header: '',
_hasBody: true,
_trailer: '',
finished: false,
_hangupClose: false,
socket: [Circular],
connection: [Circular],
_headers: [Object],
_headerNames: [Object],
write: [Function],
end: [Function] } },
connection:
{ _connecting: false,
_handle:
{ fd: 34,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: true,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
drain: [Object],
timeout: [Function],
error: [Function],
close: [Object] },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [],
errorEmitted: false },
writable: true,
allowHalfOpen: true,
onend: [Function],
destroyed: false,
bytesRead: 8249,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: 10,
_connections: 1,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: true,
httpAllowHalfOpen: false,
timeout: 5000,
_connectionKey: '4:0.0.0.0:23683' },
_idleTimeout: 5000,
_idleNext:
{ _connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
bytesRead: 79134,
_bytesDispatched: 14036,
_pendingData: null,
_pendingEncoding: '',
_idleTimeout: 30000,
_idleNext: [Object],
_idlePrev: [Circular],
_idleStart: 1459115857090,
_monotonicStartTime: 543430569,
pipe: [Function],
addListener: [Function: addListener],
on: [Function: addListener],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
_idlePrev: { _idleNext: [Circular], _idlePrev: [Object] },
_idleStart: 1459115857771,
_monotonicStartTime: 543431251,
parser:
{ _headers: [],
_url: '',
onHeaders: [Function: parserOnHeaders],
onHeadersComplete: [Function: parserOnHeadersComplete],
onBody: [Function: parserOnBody],
onMessageComplete: [Function: parserOnMessageComplete],
socket: [Circular],
incoming: [Circular],
maxHeaderPairs: 2000,
onIncoming: [Function] },
ondata: [Function],
_paused: false,
_httpMessage:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_headerSent: false,
_header: '',
_hasBody: true,
_trailer: '',
finished: false,
_hangupClose: false,
socket: [Circular],
connection: [Circular],
_headers: [Object],
_headerNames: [Object],
write: [Function],
end: [Function] } },
httpVersion: '1.1',
complete: false,
headers:
{ 'x-forwarded-proto': 'http',
'x-forwarded-port': '80',
'x-forwarded-for': '167.89.125.249,127.0.0.1',
'content-type': 'multipart/form-data; boundary=xYzZY',
'content-length': '8782',
'user-agent': 'SendGrid 1.0',
host: '6f496891.ngrok.io',
connection: 'TE, close',
te: 'deflate,gzip;q=0.3' },
trailers: {},
_pendings: [],
_pendingIndex: 0,
url: '/webhook/sendgrid',
method: 'POST',
statusCode: null,
client:
{ _connecting: false,
_handle:
{ fd: 34,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: true,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
drain: [Object],
timeout: [Function],
error: [Function],
close: [Object] },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [],
errorEmitted: false },
writable: true,
allowHalfOpen: true,
onend: [Function],
destroyed: false,
bytesRead: 8249,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server:
{ domain: null,
_events: [Object],
_maxListeners: 10,
_connections: 1,
connections: [Getter/Setter],
_handle: [Object],
_usingSlaves: false,
_slaves: [],
allowHalfOpen: true,
httpAllowHalfOpen: false,
timeout: 5000,
_connectionKey: '4:0.0.0.0:23683' },
_idleTimeout: 5000,
_idleNext:
{ _connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
bytesRead: 79134,
_bytesDispatched: 14036,
_pendingData: null,
_pendingEncoding: '',
_idleTimeout: 30000,
_idleNext: [Object],
_idlePrev: [Circular],
_idleStart: 1459115857090,
_monotonicStartTime: 543430569,
pipe: [Function],
addListener: [Function: addListener],
on: [Function: addListener],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
_idlePrev: { _idleNext: [Circular], _idlePrev: [Object] },
_idleStart: 1459115857771,
_monotonicStartTime: 543431251,
parser:
{ _headers: [],
_url: '',
onHeaders: [Function: parserOnHeaders],
onHeadersComplete: [Function: parserOnHeadersComplete],
onBody: [Function: parserOnBody],
onMessageComplete: [Function: parserOnMessageComplete],
socket: [Circular],
incoming: [Circular],
maxHeaderPairs: 2000,
onIncoming: [Function] },
ondata: [Function],
_paused: false,
_httpMessage:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_headerSent: false,
_header: '',
_hasBody: true,
_trailer: '',
finished: false,
_hangupClose: false,
socket: [Circular],
connection: [Circular],
_headers: [Object],
_headerNames: [Object],
write: [Function],
end: [Function] } },
_consuming: false,
_dumped: false,
httpVersionMajor: 1,
httpVersionMinor: 1,
upgrade: false,
originalUrl: '/webhook/sendgrid',
_parsedUrl:
{ protocol: null,
slashes: null,
auth: null,
host: null,
port: null,
hostname: null,
hash: null,
search: null,
query: null,
pathname: '/webhook/sendgrid',
path: '/webhook/sendgrid',
href: '/webhook/sendgrid' },
body: {},
query: {} }
So, the Parse API makes a POST request to an endpoint of your choosing, but the data is encoded as a multipart/form-data. I recommend using Formidable which is an express middleware to parse the data, and then extract it via a regular key-value lookup. Here's some sample code to help you out:
var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files){//do something here})

Day vs Time on Scatter plot

I want to have a day vs timescatter plot. I have some unix time values. I just need to plot them on X and Y axis such that the days of the week (e.g. Monday, Tuseday etc.) on the X axis and the time e.g.(2:24,13:40 etc. ) on the Y axis. I have tried using the datetime type. But I think I am missing something.
Here is what I have tried to do:
data=[["Saturday", 1390723133.57414], ["Sunday", 1390803027.3852], ["Monday", 1390862581.18321], ["Monday", 1390830748.67335], ["Wedneday", 1391015403.93726], ["Wedneday", 1391006992.20059], ["Sunday", 1390804961.8415]]
$('#container').highcharts({
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'test'
},
xAxis: {
title: {
enabled: true,
text: 'Day of the week'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true,
},
yAxis: {
title: {
text: 'Time of the day'
},
type: 'datetime',
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: '#FFFFFF',
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
}
}
},
series: [{
name: '',
color: 'rgba(223, 83, 83, .5)',
data: data
}]
});
});
});
You need parse your data to correct format, because in data array you need to have timestamps or numbers, not days / strings as you have.

Resources