Skip to content

Commit

Permalink
Change design in bar widgets (#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaked-hayek authored Dec 24, 2023
1 parent 24e2992 commit d432d0e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/components/molecules/GenericBarChart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { FC } from 'react';
import { ResponsiveContainer, BarChart, LabelList, XAxis, Bar, Tooltip, Legend } from 'recharts';
import { roseColor, honeyColor, yellowColor, blackColor, whiteColor } from 'style';
import { Typography } from 'components/atoms';
import tinycolor from 'tinycolor2';

const colors = [roseColor, honeyColor, yellowColor];
Expand Down Expand Up @@ -54,7 +53,6 @@ const CustomizedLabel = (props: CustomizedLabelProps) => {
const BarChartContainer: FC<IBarChartBaseProps> = ({ data, textLabel, subtitle, children, isStacked }) => {
return (
<>
{!subtitle && <Typography.Body3>{textLabel}</Typography.Body3>}
<ResponsiveContainer>
<BarChart data={data} margin={{ bottom: 20 }}>
<XAxis
Expand All @@ -66,7 +64,7 @@ const BarChartContainer: FC<IBarChartBaseProps> = ({ data, textLabel, subtitle,
style={{ fill: blackColor }}
/>
<Tooltip />
{isStacked && <Legend verticalAlign="top" align="right" iconType="circle" height={35} />}
{isStacked && <Legend verticalAlign="bottom" align="right" iconType="circle" height={35} />}
{children}
</BarChart>
</ResponsiveContainer>
Expand Down
4 changes: 3 additions & 1 deletion src/components/molecules/widgets/CountByYearBarWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ interface IProps {
const CountByYearBarWidget: FC<IProps> = ({ data, editorBarOptions }) => {
const { text } = data;
const multiBarSeries = createBarWidget(data, editorBarOptions)
return <MultiBarChart isStacked={true} isPercentage={false} data={multiBarSeries} textLabel={text.title}
return <MultiBarChart isStacked={true} isPercentage={false} data={multiBarSeries}
textLabel={text.title}
subtitle={text.subtitle}
editorBarOptions={editorBarOptions} />;
};
export default CountByYearBarWidget;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ interface IProps {
const CountInjuredByYearBarWidget: FC<IProps> = ({ data, editorBarOptions }) => {
const { text } = data;
const multiBarSeries = createBarWidget(data, editorBarOptions);
return <MultiBarChart isStacked={true} isPercentage={false} data={multiBarSeries} textLabel={text.title}
return <MultiBarChart isStacked={true} isPercentage={false} data={multiBarSeries}
textLabel={text.title}
subtitle={text.subtitle}
editorBarOptions={editorBarOptions} />;
};
export default CountInjuredByYearBarWidget;
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ svg {
::-webkit-scrollbar-thumb:hover {
background: #555;
}

/* Add left padding for legend icons (for hebrew compatibility) */
.recharts-legend-item-text {
padding-right: 5px;
}
1 change: 1 addition & 0 deletions src/models/WidgetData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export interface IWidgetMultiBarData extends IWidgetDataBase {
items: MultiSeriesDataItems[];
text: {
title?: string;
subtitle?: string;
labels_map: LabelsMap;
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/widgets.style.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const widgetVariants: { [index: string]: CardVariant } = {
footer: FooterVariant.LogoWithRange,
},
[WidgetName.accident_count_by_accident_type]: { header: HeaderVariant.Centered, footer: FooterVariant.Logo },
[WidgetName.accident_count_by_accident_year]: { header: HeaderVariant.Logo, footer: FooterVariant.None },
[WidgetName.injured_count_by_accident_year]: { header: HeaderVariant.Logo, footer: FooterVariant.None },
[WidgetName.accident_count_by_accident_year]: { header: HeaderVariant.Centered, footer: FooterVariant.LogoWithRange },
[WidgetName.injured_count_by_accident_year]: { header: HeaderVariant.Centered, footer: FooterVariant.LogoWithRange },
[WidgetName.accident_count_by_day_night]: { header: HeaderVariant.Centered, footer: FooterVariant.LogoWithRange },
[WidgetName.head_on_collisions_comparison]: { header: HeaderVariant.Label, footer: FooterVariant.LogoWithRange },
[WidgetName.head_on_collisions_comparison_percentage]: {
Expand Down

0 comments on commit d432d0e

Please sign in to comment.