Skip to content

Commit e3d7e94

Browse files
authored
feat: demo tile extension viz config (#123)
1 parent b8ad3a5 commit e3d7e94

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

react/javascript/tile-visualization/src/TileExtension.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ import { MountPoint } from '@looker/extension-sdk'
3131
import { VisualizationTile } from './components/VisualizationTile/VisualizationTile'
3232
import { DashboardTile } from './components/DashboardTile/DashboardTile'
3333

34-
const getDefaultRouteComponent = (mountPoint, isRendering) => {
34+
const getDefaultRouteComponent = (mountPoint, isRendering, visConfig) => {
3535
const config = isRendering
3636
? {
37+
...visConfig,
3738
valueCountUp: false,
3839
waveAnimateTime: 0,
3940
waveRiseTime: 0,
4041
waveAnimate: false,
4142
waveRise: false,
4243
}
43-
: {}
44+
: visConfig
4445

4546
if (mountPoint === MountPoint.dashboardVisualization) {
4647
return <VisualizationTile config={config} />
@@ -56,13 +57,23 @@ const getDefaultRouteComponent = (mountPoint, isRendering) => {
5657
return <DashboardTile standalone={true} config={config} />
5758
}
5859

60+
const emptyConfig = {}
61+
5962
export const TileExtension = () => {
60-
const { lookerHostData } = useContext(ExtensionContext40)
63+
const { lookerHostData, visualizationData } = useContext(ExtensionContext40)
64+
// The default visualization configuration can be overridden by the explore.
65+
// Make the overrides available to the visualization.
66+
const visConfig = visualizationData?.visConfig
6167
const mountPoint = lookerHostData?.mountPoint
6268
const isRendering = lookerHostData?.isRendering
6369
const component = useMemo(
64-
() => getDefaultRouteComponent(mountPoint, isRendering),
65-
[mountPoint, isRendering]
70+
() =>
71+
getDefaultRouteComponent(
72+
mountPoint,
73+
isRendering,
74+
visConfig || emptyConfig
75+
),
76+
[mountPoint, isRendering, visConfig]
6677
)
6778

6879
return (

0 commit comments

Comments
 (0)