You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/11 17:52:51 UTC

[GitHub] [superset] ktmud commented on a diff in pull request #20651: fix: annotation broken

ktmud commented on code in PR #20651:
URL: https://github.com/apache/superset/pull/20651#discussion_r918201346


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts:
##########
@@ -130,3 +134,13 @@ export function extractAnnotationLabels(
 
   return formulaAnnotationLabels.concat(timeseriesAnnotationLabels);
 }
+
+export function getAnnotationData(
+  chartProps: EchartsTimeseriesChartProps | EchartsMixedTimeseriesProps,
+): AnnotationData {
+  const data = chartProps?.queriesData[0]?.annotation_data as AnnotationData;
+  if (!isEmpty(data)) {
+    return data;
+  }
+  return {};

Review Comment:
   Nit: ternary seems more readable here
   
   ```suggestion
       return isEmpty(data) ? {} : data;
   ```
   
   I'm also not sure `isEmpty` is needed. If for whatever reason `annotation_data` becomes anything other than a plain object, it probably means there's bugs in the code or corrupted data and we'd need to fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org