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

Embedded grapher doesn't respect time query param #4437

Closed
rakyi opened this issue Jan 10, 2025 · 3 comments
Closed

Embedded grapher doesn't respect time query param #4437

rakyi opened this issue Jan 10, 2025 · 3 comments

Comments

@rakyi
Copy link
Contributor

rakyi commented Jan 10, 2025

Description

The article about the Gini coefficient includes an edited version of this chart about the change in three metrics of inequality. In the article, the chart subtitle says: "The percentage change relative to initial levels (in 1990, or 2001 for Uruguay). For example, a change in Gini from 0.4 to 0.5 would be shown as +25%." This chart was set to start from 1990 in the URL on the Gdoc, but it's not being picked up.

From my quick investigation, it looks like the parsing of the query param fails in Grapher.

Expected behaviour

The chart embedded in the article should start from the year specified in the URL.

Additional context

See related Slack thread.

Relates to https://github.com/owid/owid-issues/issues/1804.

@rakyi
Copy link
Contributor Author

rakyi commented Jan 13, 2025

This might be fixed in the new narrative views. Check whether it's still a problem there.

@marcelgerber
Copy link
Member

this problem happens here:

@computed get timelineHandleTimeBounds(): TimeBounds {
if (this.isOnMapTab) {
const time = maxTimeBoundFromJSONOrPositiveInfinity(this.map.time)
return [time, time]
}
// If the timeline is hidden on the chart tab but displayed on the table tab
// (which is the case for charts that plot time on the x-axis),
// we always want to use the authored `minTime` and `maxTime` for the chart,
// irrespective of the time range the user might have selected on the table tab
if (this.isOnChartTab && this.hasTimeDimensionButTimelineIsHidden) {
const { minTime, maxTime } = this.authorsVersion
return [
minTimeBoundFromJSONOrNegativeInfinity(minTime),
maxTimeBoundFromJSONOrPositiveInfinity(maxTime),
]
}
return [
// Handle `undefined` values in minTime/maxTime
minTimeBoundFromJSONOrNegativeInfinity(this.minTime),
maxTimeBoundFromJSONOrPositiveInfinity(this.maxTime),
]
}

in particular, if hasTimeDimensionButTimelineIsHidden is true (which is the case here, because the timeline is - by default - hidden in this narrative embed), then the timeline is explicitly set to the config as authored, disregarding any query params.
This choice makes sense for users visiting a grapher page with a hidden timeline, but maybe doesn't make sense for our own embeds.

@danyx23
Copy link
Contributor

danyx23 commented Jan 15, 2025

Thanks for reporting! This can now be done with narrative charts (Pablo A just did this for one chart - I think the one you are talking about here). Because of this, I'd say we wont fix the issue described by Marcel for now, unless we find another good reason to do so.

@danyx23 danyx23 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants