Page MenuHomePhabricator

Graph with dates displays fine in preview, but duplicates labels in rendered PNG when setting xType=date
Closed, InvalidPublic

Description

Example: https://en.wikipedia.org/w/index.php?title=User:AntiCompositeNumber/sandbox2&oldid=945530563

{{Graph:Chart
 | width=500
 | height=250
 | xAxisTitle=Time
 | yAxisTitle=Cases
 | xType=date 
 | xAxisFormat=%b %-e 
 | legend=Legend
 | type=line
 | x=2020-03-06,2020-03-07,2020-03-08,2020-03-09,2020-03-10,2020-03-11,2020-03-12,2020-03-13 
 | y1Title=Total cases
 | y1=8,13,28,41,92,95,108,123
 | y2Title=Biogen
 | y2=,,,,70,77,82,94
 | y3Title=Travel-related
 | y3=,,,,4,4,5,5
 | y4Title=Berkshire Medical Center
 | y4=,,,,,,8,8
 | y5Title=Under investigation
 | y5=,,,,18,14,13,16
 }}

produces a rendered output of

010777c4f3949059379b42faaecac81f5c122ec1.png (306×723 px, 27 KB)

which has duplicate x-axis labels. Switching the dates to plain numbers (and removing the associated formatting and typing) renders as expected. Both graphs render as expected in the SVG preview.

Event Timeline

canvas.png (306×711 px, 22 KB)

Looking closer, in the preview SVG, the label is offset from the data point in an inconsistent manner. The rendered PNG fixes this inconsistency by placing the label at the data point (where it should be in this case) and at the point the preview SVG had it.

The problem does not happen if you remove xType=date.

This might be a bug in Template:Graph:Chart but not in the Graph extension?

Aklapper renamed this task from Graph with dates displays fine in preview, but duplicates labels in rendered PNG to Graph with dates displays fine in preview, but duplicates labels in rendered PNG when setting xType=date.Mar 16 2020, 9:17 PM

Its because its doing it at 12 hour intervals (you don't notice because format is set to not show the hour)

In theory, i think the tickCount property controls this, but i was not able to get it to work in my testing. https://vega.github.io/vega/docs/axes/

TheDJ subscribed.

Question answered, not a graphs extension problem.