Unable to display Google Charts timeline on all devices - google-visualization

I'm using react-google-charts to create a Timeline. It works for me on my Macbook but not on iPad or iPhone with Chrome. It doesn't work in Safari or Firefox on the Macbook.
This is the error message I get:
undefined is not an object (evaluating 'Dygraph.TICK_PLACEMENT[a].datefield')×
I've looked through the Google Developers forum but couldn't find any similar posts. Any idea what this means?
GitHub repo
In the console in Safari, it says invalid date. So I need to fix the format of the dates I think.

I figured it out. It was the date format. The csv file I was pulling from used a date format '16JUL2016'. I was using that to create a new Date, i.e. new Date('16JUL2016'). That was not working in all browsers. So I used slice to get the month, date and year and create a new date.
let startDay = startDate.slice(0, 2);
let startMonth = months.findIndex((e) => e === startDate.slice(2, 5));
let startYear = startDate.slice(5);
let start = new Date(startYear, startMonth, startDay, 0, 0, 0);

Related

How to get current year in the Postman script

I have a requirement to get current year in the Postman pre-req script.
I'm planning to get the current date, then convert the date to string and apply sub-string to get year value
I would like to know, is this the right way of doing it, or is there any pre-defined function available to do it?
I guess there is no pre-defined function to get year alone may be you can try like below,
const moment = require('moment');
pm.globals.set("timestamp", moment().format("MM/DD/YYYY"));
Then reference {{timestamp}} where ever you need it.
check the link for more details
To get year -
var moment = require('moment');
console.log("timestamp", moment().format("YYYY"));
or even without using moment library -
console.log(new Date());
Another way to get current year :
new Date().getFullYear();
var currentYear=new Date().getFullYear();
postman.setEnvironmentVariable("currentYear" , currentYear);
This worked for me.

Previous day in Postman request

I have below code in postman's pre-request script --which gives me current date. I rather want yesterday's date (current_timestamp - 1 day).
var current_timestamp = new Date();
postman.setEnvironmentVariable("current_timestamp", current_timestamp.toISOString());
I searched doc & net but could not get the answer. Can someone please help me with reference to date functions --to get my desired result.
Thanks
You can use the momentjs module in Postman to get a date in any format you need.
In the Pre-Request Script, add this to get what you need without using native JS:
var moment = require('moment')
pm.environment.set("current_timestamp", moment().toISOString())
pm.environment.set("current_timestamp - 1 day", moment().subtract(1, 'day').toISOString())
This snippet will bring in the module and set the dates you require in the environment file.
For a non moment solution in plain JavaScript to just quickly go back 24hrs, you could do something like this:
var yesterday = (Date.now() - 86400000) // 24hrs in ms
pm.environment.set('yesterday', new Date(yesterday).toISOString())
Both solutions would give you the same outcome but I prefer to use moment as it's a built-in module that handles dates and times very well.

Google Visualization Datatable: DateFormatter is not working

I'm trying to show 12 hours format on Google Chart timeline.
This is the example from Google with arrayToDataTable method. It is working fine and this is the result I really want in 12hrs format with am & pm.
Code Pen link 1: http://codepen.io/Thein/pen/mAOrow
This is how I populated dataTable using google.visualization.DataTable().
Additionally, I formatted -
var formatter_12h = new google.visualization.DateFormat({ pattern: "d/MM/yy h:m:s aa" });
formatter_12h.format(dataTable, 1);
formatter_12h.format(dataTable, 2);
It always comes up with 24 hours format in tooltip.
Code Pen link 2: http://codepen.io/Thein/pen/KgNvJA
I tried to play with Culture value in in web.config as follow but it is still showing 24h format.
<globalization enableClientBasedCulture="false" uiCulture="en-AU" culture="en-AU" />
EDIT: It seems that Snippet 2 code is working with 12 hours format on
Apahache server and It is showing 24 hours format on IIS server.
Thanks to WhiteHat and his solution. I have fixed the Timeline chart as follow:
Code Pen link 3: http://codepen.io/Thein/pen/LRbdKv
HhAxis is quite messy though. It is so much cleaner in Code Pen link 1(http://codepen.io/Thein/pen/mAOrow). Please post your answer if you can get the result exactly like Code Pen link 1 with dataTable, I will accept your answer.

Excel operating slow with office 13 and not supporting xlrd (not able to read hyperlink's content)

I am facing primarily two problems:
I had an excel in xls format and I moved it to xlsm format. After this, xlrd is not able to read the hyperlinks. I have no other option but to use xlrd. Any solution?
And the xls is working too slow with Office 13. I converted it to xlsm format too. But still its too slow. Is there anything that can be done with xlrd? Actually my python script is used by lot of people to work with excel. So, I cant force each end user to configure xlsm (this will be the last option in case no other option is available).
For this, the issue is happening because the formatting text flag is not enabled in the case of xlsm. The only solution is to create a new column where we put the sheet name and read it, instead of getting it from the hyperlink.
Sub Button1_Click()
Dim a As Integer
Dim b As String
Dim c As Integer
On Error Resume Next
For Each hl In Sheets("TPD Sheet").Hyperlinks
'Get the sheet name
If Not IsNull(hl) Then
c = Application.Evaluate(hl.Range.row)
MsgBox "Aakash" & Application.Evaluate(hl.Range.row)
Set r = Application.Evaluate(hl.SubAddress)
'MsgBox "Row number being operated upon -> " & Application.Evaluate(hl.Range.row)
'Get the cell where the sheet name to be put
a = Application.Evaluate(hl.Range.row)
b = Application.Evaluate(hl.Range.Column)
Set TxtRng = Sheets("MySheet").Cells(a, "D")
TxtRng.value = r.Parent.name
End If
Next hl
End Sub
Select disable hardware graphics acceleration and it will be little faster. Still trying to make it faster.

Modify date time to a specific format

I'm having trouble coding a conversion to a specific time format along with converting to string format. I have the following code.
txtMonday->Text = Convert::ToString(dtpMondayIn->Value);
I want txtMonday(text box) not only to display dtpMondayIn's value(datetimepicker), but in h.mm format. Currently, it will display the date and time, for example, January 1, 2014 8:40:30 AM. I want the text box to show only 8.40 as in hours and minutes. How could I code this? I'm using Visual Studio 2012 and c++ language.
I am not really sure but
try this,
txtMonday->Text = Convert::ToString(dtpMondayIn->Value.ToString("hh:mm tt",CultureInfo.InvariantCulture));
OR
Convert::ToString(dtpMondayIn->Value.ToString("hh:mm",CultureInfo.InvariantCulture));
Also check DATETIME PICKER VALUE PROP
and DATETIME FORMATS
Let me know in case it works.