Skip to content

Add a "timezone" prop to heatmaps, time series and anomaly charts

Miguel Rincon requested to merge 214370-single-chart-time-formatter into master

What does this MR do?

Chart related implementation of #214370 (closed)

Allow heatmaps, time series and anomaly charts to accept a timezone prop. Both x axis and tooltip formats have been updated to consider this prop.

No changes are expected in the UX as local timezone is used by default.

  • In follow-up issue #219210 (closed), other charts should be updated but they need to format their dates as well!
  • In a follow-up MR, I will connect the use configuration to the dashboard_panel to wire the solution.

Most loc changes are in time_series_spec.js that were due for a refactor anyway.

How to test

Add :timezone="'UTC'" to the settings of the charts:
diff --git a/app/assets/javascripts/monitoring/components/dashboard_panel.vue b/app/assets/javascripts/monitoring/components/dashboard_panel.vue
index a23d6692e33..221ff21d7be 100644
--- a/app/assets/javascripts/monitoring/components/dashboard_panel.vue
+++ b/app/assets/javascripts/monitoring/components/dashboard_panel.vue
@@ -373,6 +373,7 @@ export default {
       :is="basicChartComponent"
       v-else-if="basicChartComponent"
       :graph-data="graphData"
+      :timezone="'UTC'"
       v-bind="$attrs"
       v-on="$listeners"
     />
@@ -386,6 +387,7 @@ export default {
       :project-path="projectPath"
       :thresholds="getGraphAlertValues(graphData.metrics)"
       :group-id="groupId"
+      :timezone="'UTC'"
       v-bind="$attrs"
       v-on="$listeners"
       @datazoom="onDatazoom"

Screenshots

On my local machine, at 7PM (China time), the time format changes depending on the settings:

:timezone="'UTC'" (local clock in Shanghai) :timezone="'LOCAL'" (local clock in Shanghai) :timezone="'LOCAL'" (local clock in Los Angeles)
Screen_Shot_2020-05-27_at_7.08.31_PM Screen_Shot_2020-05-27_at_7.09.41_PM Screen_Shot_2020-05-27_at_4.14.18_AM
Anomaly chart verification

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports