How to make the time like 'YYYY-MM-dd HH:mm:ss' when the xAxis's type is time? - date

When I use echarts to show a table, I make the xAxis type time. What ever I do, the label on the xAxis is like MM-dd hh:mm. So how could I make it YYYY-MM-dd hh:mm:ss?
The echarts version is the newest. I set the maxInterval 1000, but it doesn't work.

You will need to configure the xAxis.axisLabel.formatter: documentation
The example in the documentation itself shows a case that uses Date objects ; since the formatter supports callback functions, you can freely set the format with all the operations you need to make it work.

Related

How do you use ECharts' formatter to specify international number formats?

I'm building an API to create ECharts configs and would like the data labels to appear in the correct format based on where the end user is reading the chart from.
For example, if a number in a chart is 10,000 I would like it to appear as 10,000 in North America and 10.000 in Europe.
It looks like it's not possible to set a global format in ECharts, so I will need to use the formatter option. I thought this would be as simple as passing in a function that uses JavaScript's toLocaleString() or Intl.NumberFormat, but the ECharts docs make this look much more complicated.
I haven't found any examples of formatter that show both the inputs and outputs for common formatting scenarios, so I'm hoping to get some help in understanding the right way to do this.
Below is a very simple example of the function I'm hoping to include in formatter, but this particular example doesn't work.
formatter: function(d){
return d.toLocaleString()
}
Answering my own question so someone who needs this info can find it in the future. It turned out to be very simple, but I couldn't find a simple example like this anywhere!
Because ECharts was already displaying a value as a default label on my chart, I assumed that any function I included in formatter would use that value (that's the assumption in the simple function in my question).
I learned that when you add a function to formatter, it doesn't use the default value automatically. You need to pass in a specific reference to a piece of data using their params dataset.
In my example, I needed to use params.value to access the data I needed. My series dataset also includes both x and y columns in an array, so I needed to reference only one of the columns to get the labels to work.
params is detailed in the ECharts docs, but in the series type sections, it wasn't clear (at least to me) how to use it.
Here's what a simplified version of my working function looks like:
formatter: function(params){
let label = params.value[1] // this is my y column
return label.toLocaleString()
}

Date Format - Change format of Month from String to Numeric Value

I would think this is relatively straight forward but cant find documentation on how to do it(or the correct syntax to use) and my messing around hasn't worked so far.
For Dates we have a custom format called Month /Day /Year. This pulls back a the date(as a date type) in date format as such:
"14 April 2003"
The code behind this is:
(DATEPART('year', [Close Date])*10000 + DATEPART('month', [Close Date])*100 + DATEPART('day', [Close Date]))
What I want to get back is the month is numeric format like:
"14.04.2003"
Is it simply changing the "month" part in the code to a different type? Has any one come across this?
Cheers
lampbob, I'd just use date formatting which will mean you will still be able to use all the date-fields flexibility that Tableau provides.
Select Custom format with the following input:
dd.mm.yyyy
See the screen below for more details:
This can be easily achieved using the 'Format' option in Tableau. Here are the steps to follow to format the date field as you have specified.
Add Date field to your Rows/Columns field on a Tableau worksheet.
Set the format of the Date to be DAY(Date).
Click on options for 'DAY(Date)' and go to 'Format...'
On the Format DAY(Date) panel, go to Scale -> Dates.
Select 'Custom' option and type in 'mm.dd.yyyy'. Now the date will be in the string format you need.
Screenshots:
String format for date,
Changing to 'DAY' and 'Format...'
If you are only concerned about how the date is presented, then leave the datatype as a date, and use a custom format string via the format pane to display it as desired.
Followed your advice and just had to change the date pill, in the column field, to a continuous value. Then right clicked -> format -> Scale -> custom. Then used the above suggested format setting. Thanks Petr, woodhead92.

eonasdan datetimepicker century threshold

Any tips would be welcome: I need the datetimepicker to transform a date earlier than 1969 to that year in the 20th century. So if I enter 12-12-69 the datetimepicker transforms that into 12-12-1969. Entering 12-12-68 though is transformed into 12-12-2068. I assume this is done in moment.js, but I may be mistaken. If it is done in moment.js anyone have an idea where to look to change the threshhold for this automagic transformation? I'd rather change it in the library than use parseInputDate, but if anyone has an example on usage of parseInputDate, please share. I have found that the date already has been changed automagically as ddescribed above when I try and access the date-object via:
$('#datefrom').on('dp.change',function(e) { console.log(e.date); });
I need to access the date object B4 this happens. It works to set a onchange="dostuff()" inline on the input field itself, but that sort of feels wrong, as I want to handle this in one place in the datetimepicker and not in 50 places inline.

Google Sheets converting dates to numbers

I've run into a problem and haven't been able to find a solution for this via Google.
Using Google Sheets, I have a series of dates in the DD/MM/YYYY format in a column, and I'm filtering them based on info in another column with this formula in column G:
=ARRAYFORMULA(FILTER(D:D, B:B=B2))
where the dates are in column D. For example, 5/20/2013.
This works fine, but next, I want to add a string to the front of the dates like so:
=ARRAYFORMULA("End: "&FILTER(D:D, B:B=B2))
The dates are converting into numbers. So 5/20/2013 becomes End: 41414 instead of End: 5/20/2013, which is what I need.
Further, this happens whenever I try to reference a cell with a date in it in any formula. I have another column that puts together some values from other columns like this:
=IF(B:B=B2,ARRAYFORMULA(F2&" "&E2),"")
I want to add the date to that, like so:
=IF(B:B=B2,ARRAYFORMULA(F2&" "&E2&" "&G2),"")
The result I'm getting is the same, where I should see 5/20/2013 I'm instead getting 41414.
Can anyone tell me what's going on and how I can prevent it from converting my dates to numbers like that? Thanks!
In addition to Chris' answer: just converting to text should also work:
=ARRAYFORMULA("End: "&FILTER(to_text(D:D), B:B=B2))
You can format the formula output using TEXT, for example:
=ARRAYFORMULA("End: "&FILTER(TEXT(D:D,"mm/dd/yyyy"), B:B=B2))
=IF(B:B=B2,ARRAYFORMULA(F2&" "&E2&" "&TEXT(G2,"mm/dd/yyyy")),"")

zebra datepicker direction - past up to certain date

I want to set up Zebra datepicker plugin in a way that it has enabled all past dates up to certain specified date. I found out this stackoverflow post that explains how to do that if that border date is today. But, if the border date is lets say 1 month in the past or so, how should I define the "direction" option?
So basically I want to restrict date selection from the "beginning of time" up to some specified date.
Thank you
As you can see they described it in the documentation. Try out this code:
$('#datepicker-example5').Zebra_DatePicker({
// remember that the way you write down dates
// depends on the value of the "format" property!
direction: ['2012-08-01', '2012-08-12']
});
The example is listed in topic "Demos" (Sub-Topic 5) here: http://stefangabos.ro/jquery/zebra-datepicker/