Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Advanced"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Default"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Formatter"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
22 changes: 2 additions & 20 deletions benchmarks/conformance/cases/192-shadcn-tooltip-icons/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16 - 27
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Icons"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Line Indicator"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - No Indicator"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Custom label"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRef } from 'react'
import { barY, defineChart, stack, type ChartPoint } from '@tanstack/charts'
import { RendererChart } from '@tanstack/charts/react/tooltip'
import { tooltip } from '@tanstack/charts/tooltip'
Expand Down Expand Up @@ -47,12 +46,9 @@ export function createExampleChart() {
tooltip: {
use: tooltip,
className: 'sc-chart-tooltip',
anchor: (_points, context) => ({
x: context.surface.width * 0.271,
y: context.surface.height * 0.554,
}),
anchor: 'pointer',
placement: 'bottom-right',
offset: 0,
offset: 12,
sort: 'color-domain',
content: () => ({ rows: [] }),
},
Expand Down Expand Up @@ -165,7 +161,6 @@ export interface ExampleProps {
height?: number
}
export default function Example({ width = 640, height = 600 }: ExampleProps) {
const seededTooltip = useRef(false)
const contentWidth = Math.max(1, width - 50)
const chartWidth = contentWidth
const chartHeight = (contentWidth * 9) / 16
Expand All @@ -189,19 +184,6 @@ export default function Example({ width = 640, height = 600 }: ExampleProps) {
initialWidth={chartWidth}
height={chartHeight}
ariaLabel="Tooltip - Label Formatter"
onRender={({ scene, interaction }) => {
if (seededTooltip.current) return
const point = scene.points.find(
(candidate) =>
(candidate.datum as ShadcnActivityDatum).date ===
'2024-07-16',
)
if (!point) return
seededTooltip.current = true
interaction.setControlledFocus(point, {
source: 'programmatic',
})
}}
renderTooltipBody={({ points }) => (
<ShadcnTooltipBody
points={points as readonly ChartPoint<ShadcnActivityDatum>[]}
Expand Down
Loading