Page MenuHomePhabricator

Graph view axes always begin at 0 when both coordinates are numeric
Open, LowPublic

Description

Example query:

#defaultView:LineChart
SELECT ?year (COUNT(?person) AS ?count) WHERE {
  ?person wdt:P31 wd:Q5;
          p:P570/psv:P570 [
            wikibase:timeValue ?date;
            wikibase:timePrecision ?precision
          ].
  FILTER("1900-12-31"^^xsd:dateTime < ?date && ?date < "1910-00-00"^^xsd:dateTime).
  FILTER(?precision >= 9).
  BIND(YEAR(?date) AS ?year).
}
GROUP BY ?year
ORDER BY ?year

Link

Both axes (year and count) are numeric, which seems to be a corner case (used to summarize everything into one result, too) – in this case, both axes begin with 0, rather than a more appropriate value such as the lowest actually occurring value.

Workaround, found in the example queries: turn the X axis into a string with (STR(?year) AS ?year_).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I don’t think this is specific to both axes being numeric – dimple just always includes 0 in the range for numerical values. I’ve suggested an upstream fix: PMSI-AlignAnalytics/dimple#256. I went over all the chart example queries and didn’t see any obvious errors with this patch; several of the line chart queries can in fact be improved: if you remove the STR workaround, gaps in the years become visible (in STR form, there’s no indication that 2016 does not directly follow 2013 if there are no results for 2014 and 2015).

Since there hasn’t been any activity on the dimple repository for over half a year (last commits on master and merged pull requests on March 23rd), we might want to go ahead and just apply this fix without waiting for them to merge and release it, provided someone here can review it (it’s a fairly small patch).