-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from newrelic-experimental/fix-geo-countryname
Fix: Geo country name on tool tip
- Loading branch information
Showing
3 changed files
with
78 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 36 additions & 17 deletions
53
visualizations/store-map-viz/components/LocationPopup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
import React from "react"; | ||
import { Tooltip } from "react-leaflet"; | ||
|
||
const LocationPopup = ({ location, config, title, sticky }) => { | ||
const items = config.map((item) => { | ||
return ( | ||
<> | ||
type AttributesListProps = { | ||
location: any; | ||
config: any; | ||
}; | ||
|
||
type LocationPopupProps = { | ||
location: any; | ||
config: any; | ||
title?: string; | ||
sticky?: boolean; | ||
}; | ||
|
||
const AttributesList = ({ location, config }: AttributesListProps) => { | ||
const items = config.map((item, index) => { | ||
const value = location[item.queryField]; | ||
const formattedValue = | ||
typeof item.formatFn === "function" ? item.formatFn(value) : value; | ||
|
||
return value ? ( | ||
<React.Fragment key={index}> | ||
<div className="popup-label">{item.label}:</div> | ||
<div> | ||
{typeof item.formatFn === "function" | ||
? item.formatFn?.(location[item.queryField]) | ||
: location[item.queryField]} | ||
</div> | ||
</> | ||
); | ||
<div>{formattedValue}</div> | ||
</React.Fragment> | ||
) : null; | ||
}); | ||
|
||
return ( | ||
<Tooltip sticky={sticky}> | ||
{title && title !== "" && <h4>{title}</h4>} | ||
<div className="popup-grid">{items}</div> | ||
</Tooltip> | ||
); | ||
return <div className="popup-grid">{items}</div>; | ||
}; | ||
|
||
const LocationPopup = ({ | ||
location, | ||
config, | ||
title, | ||
sticky, | ||
}: LocationPopupProps) => ( | ||
<Tooltip sticky={sticky}> | ||
{title && <h4>{title}</h4>} | ||
<AttributesList location={location} config={config} /> | ||
</Tooltip> | ||
); | ||
|
||
export default LocationPopup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters