mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
Some more improvements on how chart height is calculated
This commit is contained in:
parent
7cf49d2c1a
commit
cf6f9028f2
1 changed files with 9 additions and 1 deletions
|
@ -51,6 +51,14 @@ const generateGraphData = (title, isBarChart, labels, data, highlightedData) =>
|
|||
|
||||
const dropLabelIfHidden = (label) => label.startsWith('hidden') ? '' : label;
|
||||
|
||||
const determineHeight = (isBarChart, labels) => {
|
||||
if (!isBarChart && labels.length > 8) {
|
||||
return 200;
|
||||
}
|
||||
|
||||
return isBarChart && labels.length > 20 ? labels.length * 8 : null;
|
||||
};
|
||||
|
||||
const renderGraph = (title, isBarChart, stats, max, highlightedStats, onClick) => {
|
||||
const hasHighlightedStats = highlightedStats && Object.keys(highlightedStats).length > 0;
|
||||
const Component = isBarChart ? HorizontalBar : Doughnut;
|
||||
|
@ -88,7 +96,7 @@ const renderGraph = (title, isBarChart, stats, max, highlightedStats, onClick) =
|
|||
}),
|
||||
};
|
||||
const graphData = generateGraphData(title, isBarChart, labels, data, highlightedData);
|
||||
const height = isBarChart && labels.length > 20 ? labels.length * 8 : 200;
|
||||
const height = determineHeight(isBarChart, labels);
|
||||
|
||||
// Provide a key based on the height, so that every time the dataset changes, a new graph is rendered
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue