Skip to content

Commit

Permalink
fix(deck.gl Multiple Layer Chart): Add Contour and Heatmap Layer as o…
Browse files Browse the repository at this point in the history
…ptions (apache#25923)
  • Loading branch information
Mattc1221 authored Jan 29, 2024
1 parent dfc614b commit 64ba579
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export { default as PathChartPlugin } from './layers/Path';
export { default as PolygonChartPlugin } from './layers/Polygon';
export { default as ScatterChartPlugin } from './layers/Scatter';
export { default as ScreengridChartPlugin } from './layers/Screengrid';
export { default as ContourChartPlugin } from './layers/Contour';
export { default as HeatmapChartPlugin } from './layers/Heatmap';
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ function setTooltipContent(formData: QueryFormData) {
<div className="deckgl-tooltip">
<TooltipRow
label={t('Start (Longitude, Latitude): ')}
value={`${o.object.sourcePosition[0]}, ${o.object.sourcePosition[1]}`}
value={`${o.object?.sourcePosition?.[0]}, ${o.object?.sourcePosition?.[1]}`}
/>
<TooltipRow
label={t('End (Longitude, Latitude): ')}
value={`${o.object.targetPosition[0]}, ${o.object.targetPosition[1]}`}
value={`${o.object?.targetPosition?.[0]}, ${o.object?.targetPosition?.[1]}`}
/>
{formData.dimension && (
<TooltipRow
label={`${formData.dimension}: `}
value={`${o.object.cat_color}`}
label={`${formData?.dimension}: `}
value={`${o.object?.cat_color}`}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ const recurseGeoJson = (

function setTooltipContent(o: JsonObject) {
return (
o.object.extraProps && (
o.object?.extraProps && (
<div className="deckgl-tooltip">
{Object.keys(o.object.extraProps).map((prop, index) => (
<TooltipRow
key={`prop-${index}`}
label={`${prop}: `}
value={`${o.object.extraProps[prop]}`}
value={`${o.object.extraProps?.[prop]}`}
/>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function setTooltipContent(o: JsonObject) {
<div className="deckgl-tooltip">
<TooltipRow
label={t('Centroid (Longitude and Latitude): ')}
value={`(${o.coordinate[0]}, ${o.coordinate[1]})`}
value={`(${o?.coordinate[0]}, ${o?.coordinate[1]})`}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Point } from '../../types';

function setTooltipContent(o: JsonObject) {
return (
o.object.extraProps && (
o.object?.extraProps && (
<div className="deckgl-tooltip">
{Object.keys(o.object.extraProps).map((prop, index) => (
<TooltipRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,27 @@ function getElevation(

function setTooltipContent(formData: PolygonFormData) {
return (o: JsonObject) => {
const metricLabel = formData.metric.label || formData.metric;
const metricLabel = formData?.metric?.label || formData?.metric;

return (
<div className="deckgl-tooltip">
{o.object.name && (
{o.object?.name && (
<TooltipRow
// eslint-disable-next-line prefer-template
label={t('name') + ': '}
value={`${o.object.name}`}
/>
)}
{o.object[formData.line_column] && (
{o.object?.[formData?.line_column] && (
<TooltipRow
label={`${formData.line_column}: `}
value={`${o.object[formData.line_column]}`}
/>
)}
{formData.metric && (
{formData?.metric && (
<TooltipRow
label={`${metricLabel}: `}
value={`${o.object[metricLabel]}`}
value={`${o.object?.[metricLabel]}`}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ function setTooltipContent(
<TooltipRow
// eslint-disable-next-line prefer-template
label={t('Longitude and Latitude') + ': '}
value={`${o.object.position[0]}, ${o.object.position[1]}`}
value={`${o.object?.position?.[0]}, ${o.object?.position?.[1]}`}
/>
{o.object.cat_color && (
{o.object?.cat_color && (
<TooltipRow
// eslint-disable-next-line prefer-template
label={t('Category') + ': '}
value={`${o.object.cat_color}`}
value={`${o.object?.cat_color}`}
/>
)}
{o.object.metric && (
<TooltipRow label={`${label}: `} value={`${o.object.metric}`} />
{o.object?.metric && (
<TooltipRow label={`${label}: `} value={`${o.object?.metric}`} />
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function setTooltipContent(o: JsonObject) {
<TooltipRow
// eslint-disable-next-line prefer-template
label={t('Longitude and Latitude') + ': '}
value={`${o.coordinate[0]}, ${o.coordinate[1]}`}
value={`${o?.coordinate?.[0]}, ${o?.coordinate?.[1]}`}
/>
<TooltipRow
// eslint-disable-next-line prefer-template
label={t('Weight') + ': '}
value={`${o.object.cellWeight}`}
value={`${o.object?.cellWeight}`}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { getLayer as deck_scatter } from './Scatter/Scatter';
import { getLayer as deck_geojson } from './Geojson/Geojson';
import { getLayer as deck_arc } from './Arc/Arc';
import { getLayer as deck_polygon } from './Polygon/Polygon';
import { getLayer as deck_heatmap } from './Heatmap/Heatmap';
import { getLayer as deck_contour } from './Contour/Contour';

const layerGenerators = {
deck_grid,
Expand All @@ -35,6 +37,8 @@ const layerGenerators = {
deck_geojson,
deck_arc,
deck_polygon,
deck_heatmap,
deck_contour,
};

export default layerGenerators;

0 comments on commit 64ba579

Please sign in to comment.