tweak: minor aesthetic chart tweaks
This commit is contained in:
parent
51bdfc915d
commit
3afbb647da
|
@ -3,9 +3,11 @@ import {
|
||||||
VictoryAxis,
|
VictoryAxis,
|
||||||
VictoryChart,
|
VictoryChart,
|
||||||
VictoryGroup,
|
VictoryGroup,
|
||||||
|
VictoryStack,
|
||||||
VictoryLabel,
|
VictoryLabel,
|
||||||
VictoryLine,
|
VictoryLine,
|
||||||
VictoryScatter,
|
VictoryScatter,
|
||||||
|
VictoryArea,
|
||||||
VictoryTheme,
|
VictoryTheme,
|
||||||
VictoryTooltip,
|
VictoryTooltip,
|
||||||
VictoryVoronoiContainer,
|
VictoryVoronoiContainer,
|
||||||
|
@ -20,10 +22,12 @@ const getVictoryGroup = ({
|
||||||
data,
|
data,
|
||||||
i,
|
i,
|
||||||
highlight,
|
highlight,
|
||||||
|
isBinary,
|
||||||
}: {
|
}: {
|
||||||
data: ChartSeries;
|
data: ChartSeries;
|
||||||
i: number;
|
i: number;
|
||||||
highlight?: boolean;
|
highlight?: boolean;
|
||||||
|
isBinary?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<VictoryGroup color={chartColors[i] || "darkgray"} data={data} key={i}>
|
<VictoryGroup color={chartColors[i] || "darkgray"} data={data} key={i}>
|
||||||
|
@ -33,10 +37,20 @@ const getVictoryGroup = ({
|
||||||
data: {
|
data: {
|
||||||
// strokeOpacity: highlight ? 1 : 0.5,
|
// strokeOpacity: highlight ? 1 : 0.5,
|
||||||
strokeOpacity: 0.6,
|
strokeOpacity: 0.6,
|
||||||
strokeWidth: 3,
|
strokeWidth: isBinary ? 4 : 3,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{isBinary ? (
|
||||||
|
<VictoryArea
|
||||||
|
standalone={false}
|
||||||
|
style={{
|
||||||
|
data: { fill: chartColors[i], fillOpacity: 0.1, strokeOpacity: 0 },
|
||||||
|
}}
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<VictoryScatter
|
<VictoryScatter
|
||||||
name={`scatter-${i}`}
|
name={`scatter-${i}`}
|
||||||
size={({ active }) => (active || highlight ? 0 : 0)} //(active || highlight ? 3.75 : 3)}
|
size={({ active }) => (active || highlight ? 0 : 0)} //(active || highlight ? 3.75 : 3)}
|
||||||
|
@ -63,9 +77,12 @@ export const InnerChart: React.FC<Props> = ({
|
||||||
right: 17,
|
right: 17,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isBinary = seriesList.length == 1;
|
||||||
|
console.log(isBinary);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VictoryChart
|
<VictoryChart
|
||||||
domainPadding={20}
|
domainPadding={0}
|
||||||
padding={padding}
|
padding={padding}
|
||||||
theme={VictoryTheme.material}
|
theme={VictoryTheme.material}
|
||||||
height={height}
|
height={height}
|
||||||
|
@ -157,24 +174,32 @@ export const InnerChart: React.FC<Props> = ({
|
||||||
// tickFormat specifies how ticks should be displayed
|
// tickFormat specifies how ticks should be displayed
|
||||||
tickFormat={(x) => `${x * 100}%`}
|
tickFormat={(x) => `${x * 100}%`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{[...Array(seriesList.length).keys()]
|
{[...Array(seriesList.length).keys()]
|
||||||
.reverse() // affects svg render order, we want to render largest datasets on top of others
|
.reverse() // affects svg render order, we want to render largest datasets on top of others
|
||||||
.filter((i) => i !== highlight)
|
//.filter((i) => i !== highlight)
|
||||||
.map((i) =>
|
.map((i) =>
|
||||||
getVictoryGroup({
|
getVictoryGroup({
|
||||||
data: seriesList[i],
|
data: seriesList[i],
|
||||||
i,
|
i,
|
||||||
highlight: false,
|
highlight: i == highlight, // false
|
||||||
|
isBinary: isBinary,
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
{highlight === undefined
|
|
||||||
|
{
|
||||||
|
// note: this produces an annoying change of color effect
|
||||||
|
/*
|
||||||
|
highlight === undefined
|
||||||
? null
|
? null
|
||||||
: // render highlighted series on top of everything else
|
: // render highlighted series on top of everything else
|
||||||
getVictoryGroup({
|
getVictoryGroup({
|
||||||
data: seriesList[highlight],
|
data: seriesList[highlight],
|
||||||
i: highlight,
|
i: highlight,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
})}
|
})
|
||||||
|
*/
|
||||||
|
}
|
||||||
</VictoryChart>
|
</VictoryChart>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,7 +61,7 @@ const LargeQuestionCard: React.FC<{
|
||||||
</a>
|
</a>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div className="flex gap-2 mb-3">
|
<div className="flex gap-2 mb-5">
|
||||||
<a
|
<a
|
||||||
className="text-black no-underline border-2 rounded-lg border-gray-400 rounded p-1 px-2 text-2xs hover:text-gray-600"
|
className="text-black no-underline border-2 rounded-lg border-gray-400 rounded p-1 px-2 text-2xs hover:text-gray-600"
|
||||||
href={question.url}
|
href={question.url}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user