Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

period positioning #4912

Closed
nicolaskruchten opened this issue Jun 10, 2020 · 3 comments · Fixed by #5074
Closed

period positioning #4912

nicolaskruchten opened this issue Jun 10, 2020 · 3 comments · Fixed by #5074
Assignees
Labels
feature something new

Comments

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Jun 10, 2020

This issue is intended to apply in principle to scatter (not scattergl), bar, funnel, waterfall, ohlc and candlestick traces, and only applies in the context of (x|y)axis.type=date.

We need to be able to position marks along date axes not at a particular instant in time, but at the start/midpoint/end of a well-defined period (see related #4911).

Proposed new trace-level attributes:

  • (x|y)period: Standard duration notation like ‘m’ or millis
  • (x|y)period0: A specific boundary point timestamp which is used to compute all boundaries. This will allow us to define e.g. "quarters that start on Feb 1" or "weeks that start on Wednesdays" etc
  • (x|y)periodalignment: start/middle/end

Proposed backwards-compatible changes to traces with width parameter:

  • Start accepting period lengths
  • Defaults to (x|y)period if orientation=(v|h)
  • If specified as a period, then the bar widths are variable and the gaps are computed as a percentage of the local bar width

Note: the hoverlabel here will need some thought.

@nicolaskruchten nicolaskruchten added this to the v1.56.0 milestone Jun 10, 2020
@nicolaskruchten nicolaskruchten removed this from the v1.56.0 milestone Jul 7, 2020
@archmoj archmoj self-assigned this Aug 14, 2020
@nicolaskruchten
Copy link
Contributor Author

Re the hover-label, let's not do anything special for now: the user can do whatever they like in the hovertemplate.

Re the xperiod0 concept, I'll note that setting the default value to 1950-01-01 00:00 conveniently anchors seconds, minutes, hours at 0, the day of week on a Sunday, the 1st of the month at 1, the first month of the year at January, the first quarter at Jan/Feb/Mar and the first year of a decade at a multiple of 10.

If someone wants quarters like Q1=Feb/Mar/Apr then could set xperiod0 to something like 2020-02-01 or any other February 1, and if they want weeks that start on Mondays then they could set xperiod0 to something like 2020-08-31 or any other Monday

@alexcjohnson
Copy link
Collaborator

FYI the default tick0 behavior already shifts to Sunday when using week ticks:

/*
* dateTick0: get the canonical tick for this calendar
*
* bool sunday is for week ticks, shift it to a Sunday.
*/
exports.dateTick0 = function(calendar, sunday) {
if(isWorldCalendar(calendar)) {
return sunday ?
Registry.getComponentMethod('calendars', 'CANONICAL_SUNDAY')[calendar] :
Registry.getComponentMethod('calendars', 'CANONICAL_TICK')[calendar];
} else {
return sunday ? '2000-01-02' : '2000-01-01';
}
};

@nicolaskruchten
Copy link
Contributor Author

Given Alex's comment above, let's just do the same thing with xperiod0 then, no need to force it to 1950 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants