jgoz commented on code in PR #14990:
URL: https://github.com/apache/druid/pull/14990#discussion_r1328872205
##########
web-console/src/views/explore-view/modules/pie-chart-echarts-module.ts:
##########
@@ -20,8 +20,29 @@ import { C, SqlExpression } from '@druid-toolkit/query';
import { typedVisualModule } from '@druid-toolkit/visuals-core';
import * as echarts from 'echarts';
+import { highlightStore } from '../highlight-store/highlight-store';
import { getInitQuery } from '../utils';
+/**
+ * Returns the cartesian coordinates of a pie slice external centroid
+ */
+function getCentroid(chart: echarts.ECharts, dataIndex: number) {
+ // see these underscores everywhere? that's because those are private
properties
+ // I have no real choice but to use them, because there is no public API for
this (on pie charts)
+ // #no_ragrets
+ const layout = (chart as any)._chartsViews[0]._data._itemLayouts[dataIndex];
Review Comment:
Maybe for some extra safety in case the private API changes... tradeoff
between crashing and not calculating a centroid 🤷
```suggestion
const layout = (chart as
any)._chartsViews?.[0]?._data?._itemLayouts?.[dataIndex];
```
##########
web-console/src/views/explore-view/utils/use-resize-observer.ts:
##########
@@ -0,0 +1,80 @@
+/*
Review Comment:
This could move to `src/hooks`
##########
web-console/src/views/explore-view/modules/pie-chart-echarts-module.ts:
##########
@@ -20,8 +20,29 @@ import { C, SqlExpression } from '@druid-toolkit/query';
import { typedVisualModule } from '@druid-toolkit/visuals-core';
import * as echarts from 'echarts';
+import { highlightStore } from '../highlight-store/highlight-store';
import { getInitQuery } from '../utils';
+/**
+ * Returns the cartesian coordinates of a pie slice external centroid
+ */
+function getCentroid(chart: echarts.ECharts, dataIndex: number) {
+ // see these underscores everywhere? that's because those are private
properties
+ // I have no real choice but to use them, because there is no public API for
this (on pie charts)
+ // #no_ragrets
+ const layout = (chart as any)._chartsViews[0]._data._itemLayouts[dataIndex];
Review Comment:
Maybe for some extra safety in case the private API changes... tradeoff
between crashing and not calculating a centroid 🤷
```suggestion
const layout = (chart as
any)._chartsViews?.[0]?._data?._itemLayouts?.[dataIndex];
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]