carbon-design-system / carbon-addons-data-viz-react

DEPRECATED. Please use Carbon Charts instead
https://github.com/carbon-design-system/carbon-charts
26 stars 26 forks source link

fix: isUTC does NOT Display UTC Times in X Axis #110

Closed DmitriWolf closed 6 years ago

DmitriWolf commented 6 years ago

Current Behavior

The LineGraph.js component currently will not display times in the x-axis according to UTC even with isUTC: true.

Desired Behavior

When you enter isUTC: true as a prop, the Line Graph will display all date values (ie. 1528487686098) for UTC time (as seen from time zone +00 or Greenwich Mean Time).

The fix

The bug happens because d3.timeFormat defaults to locale time. If we use d3.utcFormat it will use UTC time.

Docs for d3.timeFomat.

Docs for d3.utcFormat.

Equivalent to locale.format, except all directives are interpreted as Coordinated Universal Time (UTC) rather than local time.