victory icon indicating copy to clipboard operation
victory copied to clipboard

Tooltip and custom label

Open ksavic opened this issue 6 years ago • 7 comments

Hi,

I would like to add custom label above group bars along with custom tooltip. Can this be done? Any examples would be appreciated.

Thank you.

ksavic avatar May 20 '20 16:05 ksavic

Hi @ksavic, this should be documented in the Victory docs. If you have further questions, please check to see if there are duplicate discussions, and then open a Q&A discussion thread. Thanks!

becca-bailey avatar Feb 15 '22 23:02 becca-bailey

Label usage and tooltip usage are documented but using both label and tooltip in same chart is not documented. There is some old instructions here for class based components but they don't work any more: https://github.com/FormidableLabs/victory/issues/551

kallepyorala avatar Dec 23 '22 18:12 kallepyorala

Yea we need a modern, updated approach for doing this, with Typescript examples. Having a hell of a time getting the example working passing props to the components that are typed differently.

wadehammes avatar Feb 15 '23 00:02 wadehammes

I was able to get around this by creating two nearly identical charts (pie charts in my case), one with a label, and one with a tool tip.

The pie chart with the tool tip was given transparent fill for each of the slices, and the pie chart with the label was given actual colors.

Then I positioned the pie chart with the tool tips absolutely over the pie chart with the labels.

Super hacky, but it gets the job done.

TeddyBurnsides avatar Mar 23 '23 18:03 TeddyBurnsides

how do you make the slices have a transparent fill? @TeddyBurnsides

k-walsh avatar Aug 31 '23 22:08 k-walsh

how do you make the slices have a transparent fill? @TeddyBurnsides

Here's what I did:

<VictoryPie
	padding={{ top: 0, bottom: 0, left: 60, right: 60 }}
	labelComponent={
		<VictoryTooltip
			constrainToVisibleArea
			cornerRadius={3}
			flyoutPadding={{ top: 4, bottom: 4, left: 10, right: 10 }}
			flyoutStyle={{
				stroke: "rgba(0,0,0,.4)",
				fill: "rgba(255,255,255,.9)",
			}}
		/>
	}
	colorScale={["transparent"]}
	data={series}
	style={{
		labels: {
			fontFamily: "Inter",
			fontSize: "10",
		},
	}}
/>

TeddyBurnsides avatar Sep 01 '23 13:09 TeddyBurnsides

how do you make the slices have a transparent fill? @TeddyBurnsides

Here's what I did:

<VictoryPie
	padding={{ top: 0, bottom: 0, left: 60, right: 60 }}
	labelComponent={
		<VictoryTooltip
			constrainToVisibleArea
			cornerRadius={3}
			flyoutPadding={{ top: 4, bottom: 4, left: 10, right: 10 }}
			flyoutStyle={{
				stroke: "rgba(0,0,0,.4)",
				fill: "rgba(255,255,255,.9)",
			}}
		/>
	}
	colorScale={["transparent"]}
	data={series}
	style={{
		labels: {
			fontFamily: "Inter",
			fontSize: "10",
		},
	}}
/>

TeddyBurnsides avatar Sep 01 '23 13:09 TeddyBurnsides