Skip to content

Commit

Permalink
🐝 (dod) disable automatic lookup for indicator names
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Mar 6, 2024
1 parent 4c73b35 commit 49d0330
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
7 changes: 0 additions & 7 deletions adminSiteClient/DimensionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from "@fortawesome/free-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import { OwidTable } from "@ourworldindata/core-table"
import { makeDetailIdFromText } from "@ourworldindata/utils"

@observer
export class DimensionCard extends React.Component<{
Expand Down Expand Up @@ -151,12 +150,6 @@ export class DimensionCard extends React.Component<{
store={dimension.display}
auto={column.displayName}
onBlur={this.onChange}
helpText={`Detail: ${makeDetailIdFromText({
text:
dimension.display.name ??
column.displayName,
type: "indicator",
})}`}
errorMessage={this.props.errorMessages?.displayName}
/>
<BindAutoString
Expand Down
61 changes: 36 additions & 25 deletions packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import {
compact,
getOriginAttributionFragments,
sortBy,
makeDetailIdFromText,
extractDetailsFromSyntax,
} from "@ourworldindata/utils"
import {
Expand Down Expand Up @@ -1261,24 +1260,38 @@ export class Grapher
@computed get detailsOrderedByReference(): string[] {
if (typeof window === "undefined") return []

// if a custom axis label is given, extract details from it;
// otherwise, check if a detail exists for the default axis label
function extractDetailsFromAxisLabel(
configLabel?: string,
defaultLabel?: string
): string[] {
if (configLabel) {
return extractDetailsFromSyntax(configLabel)
} else if (defaultLabel) {
return [
makeDetailIdFromText({
text: defaultLabel,
type: "indicator",
}),
]
}
return []
}
// We are toying with the idea of automatically looking for a detail with a specific prefix
// (e.g. grapher_indicator_per-capita-emissions) when an indicator name is used as the default axis label.
// This feature is disabled for now, but we might want to enable it in the future.
//
// // if a custom axis label is given, extract details from it;
// // otherwise, check if a detail exists for the default axis label
// function extractDetailsFromAxisLabel(
// configLabel?: string,
// defaultLabel?: string
// ): string[] {
// if (configLabel) {
// return extractDetailsFromSyntax(configLabel)
// } else if (defaultLabel) {
// return [
// makeDetailIdFromText({
// text: defaultLabel,
// type: "indicator",
// }),
// ]
// }
// return []
// }
//
// // extract details from axis labels
// const yAxisDetails = extractDetailsFromAxisLabel(
// this.yAxisConfig.label,
// this.defaultYAxisLabel
// )
// const xAxisDetails = extractDetailsFromAxisLabel(
// this.xAxisConfig.label,
// this.defaultXAxisLabel
// )

// extract details from supporting text
const subtitleDetails = !this.hideSubtitle
Expand All @@ -1289,13 +1302,11 @@ export class Grapher
: []

// extract details from axis labels
const yAxisDetails = extractDetailsFromAxisLabel(
this.yAxisConfig.label,
this.defaultYAxisLabel
const yAxisDetails = extractDetailsFromSyntax(
this.yAxisConfig.label || ""
)
const xAxisDetails = extractDetailsFromAxisLabel(
this.xAxisConfig.label,
this.defaultXAxisLabel
const xAxisDetails = extractDetailsFromSyntax(
this.xAxisConfig.label || ""
)

// text fragments are ordered by appearance
Expand Down

0 comments on commit 49d0330

Please sign in to comment.