Highcharts - How to show x-axis with incomplete data? - highcharts

Not entirely sure how to best describe this issue in a title, so here goes.
I'm working on a chart that plots data over time, starting with a single date and adding one piece of data each day.
In the following screen shot, here's what I'm using for a x-axis:
categories: ['Mon Apr 3', 'Tue Apr 4', 'Wed Apr 5', 'Thu Apr 6', 'Fri Apr 7', 'Sat Apr 8', 'Sun Apr 9']
For my y-axis:
data: [4,0,0,0,0,0,0]
Which results in this graph:
The issue with it is technically only the Mon Apr 3 date has happened. The outcome I want is a single dot for Mon Apr 3 with the rest of the line uncharted.
When I adjust my axis as follows, highcharts hides the rest of the dates in my x-axis and centers the single point:
categories: ['Mon Apr 3', 'Tue Apr 4', 'Wed Apr 5', 'Thu Apr 6', 'Fri Apr 7', 'Sat Apr 8', 'Sun Apr 9']
data: [4]
Resulting in this:
Does anyone know of how to go about achieving the desired result? Again, just want this first data point of 4 to left align while keeping all of the other dates in the future.

Technically 0 is a value. You could map the array to look like this instead:
categories: ['Mon Apr 3', 'Tue Apr 4', 'Wed Apr 5', 'Thu Apr 6', 'Fri Apr 7', 'Sat Apr 8', 'Sun Apr 9']
data: [4, null, null, null, null, null, null]

Related

Set Google Sheets background color by alternating weeks

I maintain a Google Sheets based release calendar for my website, where we publish new content 5 days a week (sometimes 4, sometimes 6 or 7).
In order to make viewing the release calendar easier for my team I go through and manually stripe every other week a different color. Starting with Monday, ending on Sunday. I'd like to create a formula which will do this for me, so that I can save a bit of time. Given the dates below I've indicated what color I'd like a row to be. Could someone tell me if this is possible, and if so provide some pointers as to how to accomplish it?
Mon, January 4, 2021 <-- light grey
Tue, January 5, 2021 <-- light grey
Wed, January 6, 2021 <-- light grey
Thu, January 7, 2021 <-- light grey
Fri, January 8, 2021 <-- light grey
Mon, January 11, 2021 <-- default color
Tue, January 12, 2021 <-- default color
Wed, January 13, 2021 <-- default color
Thu, January 14, 2021 <-- default color
Thu, January 14, 2021 <-- default color
Fri, January 15, 2021 <-- default color
Mon, January 18, 2021 <-- light grey
Tue, January 19, 2021 <-- light grey
Tue, January 19, 2021 <-- light grey
Wed, January 20, 2021 <-- light grey
Thu, January 21, 2021 <-- light grey
Fri, January 22, 2021 <-- light grey
Sat, January 23, 2021 <-- light grey
use in CF:
=ISEVEN(WEEKNUM(A1, 2))

How to get the date of "this Wednesday", "this Thursday" etc. in Rails

I know that Rails has an elegant way of getting dates for a certain day of the week for next week, or for last week (docs).
today = Time.zone.today
=> Fri, 24 Jan 2020
today.next_week
=> Mon, 27 Jan 2020 # Gets Monday by default
today.next_week(:thursday)
=> Thu, 30 Jan 2020 # You can get a certain day of the week by passing it in as an argument
Is there a way to do the same for this week? For example, getting the date of this Thursday, Friday, etc.? Right now, my workaround is to get the date of beginning_of_week (Monday) and calculate from there. Ideally, I wanted to do something similar to above, like Time.zone.today.this_week(:thursday).
this_monday = Time.zone.today.beginning_of_week
=> Mon, 20 Jan 2020
this_friday = this_monday.since(4.days).to_date
=> Fri, 24 Jan 2020
You could use #next_occurring
pry(main)> Time.zone.today.beginning_of_week
Mon, 20 Jan 2020
pry(main)> Time.zone.today.beginning_of_week.next_occurring(:thursday)
Thu, 23 Jan 2020

Is there a way to delete a date in a range of dates?

I have a range of dates and a date:
dates==> Wed, 20 Nov 2019...Sat, 30 Nov 2019:Range
date ==> Wed, 20 Nov 2019
Is there a way to eliminate the date from the dates range?
For reference, I imagine something similar to:
[1, 2, 7, 4, 5] - [7] which results in => [1, 2, 4, 5]
ActiveSupport provides the Enumerable#without method. In your case, you can achieve this by:
dates.without(date)

Datetime format in Ruby doesn't work for identifier

I have a question about the format of t.datetime.
When I command in the rails console,
Lesson.find(1781).start_time,
then
the Tue, 03 May 2016 14:00:00 UTC +00:00
is returned.
If I command
Classtime.find_by(start_time: 'Tue, 03 May 2016 14:00:00 UTC +00:00')
, it returns nil.
But if I command
Classtime.find_by(start_time: Lesson.find(1781).start_time)
, it returns
<Classtime id: 4429, start_time: "2016-05-03 14:00:00", created_at: "2016-04-21 15:53:22", updated_at: "2016-04-21 15:53:22">
So I guess, Lesson.find(1781).start_time is not equal to the return of Lesson.find(1781).start_time in some sense. How would I be able to know what caused this?
Please share with me!!!
This:
Classtime.find_by(start_time: Lesson.find(1781).start_time)
is the same as:
Classtime.find_by(start_time: '2016-05-03 14:00:00')
which is NOT the same as:
Classtime.find_by(start_time: 'Tue, 03 May 2016 14:00:00 UTC +00:00')
The database knows how to translate the string 2016-05-03 14:00:00 to a date, but not the string Tue, 03 May 2016 14:00:00 UTC +00:00.

xAxis ticks in Chartkick

I created a chart of User registered/Month chart with Chartkick, however, some data at xAxis is not visible, such as this:
Aralık means "December" and Şubat means "February". Even though there aret users registered at "November", there is no representing label in xAxis. There should be a label for every month, however I could not achieve it. My current rails code is this:
<%= line_chart User.group_by_month(:created_at).count %>
and the output from grouping query is this:
{Sun, 01 Nov 2015 00:00:00 UTC +00:00=>1, Tue, 01 Dec 2015 00:00:00 UTC +00:00=>1, Fri, 01 Jan 2016 00:00:00 UTC +00:00=>1, Mon, 01 Feb 2016 00:00:00 UTC +00:00=>1, Tue, 01 Mar 2016 00:00:00 UTC +00:00=>1}
I've also tried using the Google Charts library like this,
{library: {discrete: true, hAxis: {format: "MMMM yyyy", ticks: #patient_month_distribution.keys}}}
Google Charts outputs this error:
How can I modify my code so that every month/year is visible?
Use format in group_by_month function
<%= line_chart User.group_by_month(:created_at, format: "%b %y").count %>

Resources