Skip to content

Commit

Permalink
enhance: show static preview of chart view
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Dec 19, 2024
1 parent ac62f0e commit 566ee00
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions adminSiteClient/ChartViewIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AdminAppContext } from "./AdminAppContext.js"
import { Timeago } from "./Forms.js"
import { ColumnsType } from "antd/es/table/InternalTable.js"
import { ApiChartViewOverview } from "../adminShared/AdminTypes.js"
import { BAKED_GRAPHER_URL } from "../settings/clientSettings.js"
import { GRAPHER_DYNAMIC_THUMBNAIL_URL } from "../settings/clientSettings.js"
import { Link } from "./Link.js"
import {
buildSearchWordsFromSearchString,
Expand All @@ -27,7 +27,7 @@ function createColumns(
width: 200,
render: (chartConfigId) => (
<img
src={`${BAKED_GRAPHER_URL}/by-uuid/${chartConfigId}.svg`}
src={`${GRAPHER_DYNAMIC_THUMBNAIL_URL}/by-uuid/${chartConfigId}.svg`}
style={{ maxWidth: 200, maxHeight: 200 }}
/>
),
Expand Down
30 changes: 26 additions & 4 deletions site/gdocs/components/NarrativeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ import cx from "classnames"
import { GRAPHER_PREVIEW_CLASS } from "../../SiteConstants.js"
import { BlockErrorFallback } from "./BlockErrorBoundary.js"
import { DocumentContext } from "../OwidGdoc.js"
import { GRAPHER_CHART_VIEW_EMBEDDED_FIGURE_CONFIG_ATTR } from "@ourworldindata/grapher"
import {
DEFAULT_GRAPHER_HEIGHT,
DEFAULT_GRAPHER_WIDTH,
GRAPHER_CHART_VIEW_EMBEDDED_FIGURE_CONFIG_ATTR,
} from "@ourworldindata/grapher"
import {
BAKED_GRAPHER_URL,
GRAPHER_DYNAMIC_THUMBNAIL_URL,
} from "../../../settings/clientSettings.js"
import { queryParamsToStr } from "@ourworldindata/utils"
import GrapherImage from "../../GrapherImage.js"

Check warning on line 19 in site/gdocs/components/NarrativeChart.tsx

View workflow job for this annotation

GitHub Actions / eslint

'GrapherImage' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 19 in site/gdocs/components/NarrativeChart.tsx

View workflow job for this annotation

GitHub Actions / eslint

'GrapherImage' is defined but never used. Allowed unused vars must match /^_/u
import InteractionNotice from "../../InteractionNotice.js"

export default function NarrativeChart({
d,
Expand Down Expand Up @@ -40,6 +51,10 @@ export default function NarrativeChart({

const metadataStringified = JSON.stringify(viewMetadata)

const resolvedUrl = `${BAKED_GRAPHER_URL}/${viewMetadata.parentChartSlug}${queryParamsToStr(
viewMetadata.queryParamsForParentChart
)}`

return (
<div
className={cx(d.position, className, {
Expand All @@ -61,10 +76,17 @@ export default function NarrativeChart({
metadataStringified,
}}
>
{/* <a href={resolvedUrl} target="_blank" rel="noopener">
<GrapherImage slug={resolvedSlug} alt={d.title} />
<a href={resolvedUrl} target="_blank" rel="noopener">
<img
src={`${GRAPHER_DYNAMIC_THUMBNAIL_URL}/by-uuid/${viewMetadata.chartConfigId}.svg`}
alt={viewMetadata.title}
width={DEFAULT_GRAPHER_WIDTH}
height={DEFAULT_GRAPHER_HEIGHT}
loading="lazy"
data-no-lightbox
/>
<InteractionNotice />
</a> */}
</a>
</figure>
{d.caption ? (
<figcaption>{renderSpans(d.caption)}</figcaption>
Expand Down

0 comments on commit 566ee00

Please sign in to comment.