2

In my Ruby on Rails application , i have the below json and i am displaying the linechart from chartkick. In linechart , it shows previous day's date though date is correct in the json. When i use format it displays the date fully. How we can display only the date in x axis. My json from controller

[["2018-05-27T00:00:00.000Z", #<BigDecimal:558070d10920,'0.3206E2',18(18)>], 
["2018-05-29T00:00:00.000Z", #<BigDecimal:558070d10060,'0.23848E3',18(18)>], 
["2018-05-30T00:00:00.000Z", #<BigDecimal:558070d0b420,'0.33899E3',18(18)>], 
["2018-05-31T00:00:00.000Z", #<BigDecimal:558070d0a548,'0.83962E3',18(18)>]]

Please find the code used

<%= line_chart [name: 'Sales Amount ', data: @daily_sales_debit_data],
                          xtitle: 'Period',
                          ytitle: 'Sales Amount',
                          library: {
                              vAxis: { format: "currency" },
                              legend: { position: 'in'},"format":"dd/MM/yy"},
                          "discrete":true%>

In the graph , it is being displayed as below . how can i format the date being displayed in x axis without time .

2018-05-08T00:00:00.000Z
2018-05-09T00:00:00.000Z
2018-05-14T00:00:00.000Z
2018-05-15T00:00:00.000Z
2018-05-16T00:00:00.000Z
2018-05-18T00:00:00.000Z
2018-05-19T00:00:00.000Z
2018-05-21T00:00:00.000Z
2018-05-22T00:00:00.000Z
2018-05-25T00:00:00.000Z
2018-05-27T00:00:00.000Z
2018-05-29T00:00:00.000Z
2018-05-30T00:00:00.000Z
2018-05-31T00:00:00.000Z
EnthuDev
  • 170
  • 2
  • 3
  • 15
  • Do you have any control over the json sent from the controller? How do you generate it? – nathanvda Jun 02 '18 at 15:57
  • I am using SQL query trunc function for timestamp column and generating the json from the resultset – EnthuDev Jun 02 '18 at 16:57
  • Please show the code how you query and generate the resultset. It should be pretty easy to format the date correctly. And please a gentle note: today is a saturday, I replied to your question and asked for more info, please stop urging me on all my social contact-channels to respond here. – nathanvda Jun 02 '18 at 20:00

1 Answers1

2

Formatting the date in the proper format - "MM-DD-YYYY" worked

EnthuDev
  • 170
  • 2
  • 3
  • 15