Vaibhav_Dashboard_Enhancement #9
@ -46,19 +46,23 @@ const HorizontalBarChart = ({
|
|||||||
// Replace 0 with 1 for visual purposes, but display "0%" in labels
|
// Replace 0 with 1 for visual purposes, but display "0%" in labels
|
||||||
const adjustedSeriesData = sortedSeriesData.map(val => (val === 0 ? 1 : val));
|
const adjustedSeriesData = sortedSeriesData.map(val => (val === 0 ? 1 : val));
|
||||||
|
|
||||||
|
// Dynamically adjust chart height if only one data point
|
||||||
|
const chartHeight = seriesData.length === 1 ? 80 : 380;
|
||||||
|
|
||||||
const chartOptions = {
|
const chartOptions = {
|
||||||
chart: {
|
chart: {
|
||||||
type: "bar",
|
type: "bar",
|
||||||
height: 380,
|
height: chartHeight,
|
||||||
toolbar: { show: false },
|
toolbar: { show: false },
|
||||||
},
|
},
|
||||||
grid: { show: false },
|
grid: { show: false },
|
||||||
plotOptions: {
|
plotOptions: {
|
||||||
bar: {
|
bar: {
|
||||||
barHeight: "60%",
|
barHeight: seriesData.length === 1 ? "30%" : "60%",
|
||||||
distributed: true,
|
distributed: true,
|
||||||
horizontal: true,
|
horizontal: true,
|
||||||
borderRadius: 10,
|
borderRadius: 3,
|
||||||
|
borderRadiusApplication: "end",
|
||||||
dataLabels: {
|
dataLabels: {
|
||||||
position: "top",
|
position: "top",
|
||||||
},
|
},
|
||||||
@ -110,7 +114,7 @@ const HorizontalBarChart = ({
|
|||||||
options={chartOptions}
|
options={chartOptions}
|
||||||
series={[{ data: adjustedSeriesData }]}
|
series={[{ data: adjustedSeriesData }]}
|
||||||
type="bar"
|
type="bar"
|
||||||
height={380}
|
height={chartHeight}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user