Skip to content

Commit

Permalink
Update AccidentCountByRoadLight (#1174)
Browse files Browse the repository at this point in the history
* update AccidentCountByRoadLight as piechart
  • Loading branch information
atalyaalon authored Dec 18, 2024
1 parent 8dd3606 commit 7a01b6c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
20 changes: 16 additions & 4 deletions src/components/molecules/widgets/AccidentCountByRoadLight.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import React, { FC } from 'react';
import { IWidgetAccidentCountByRoadLight } from 'models/WidgetData';
import PieChartView from 'components/molecules/PieChartView';

const ROAD_LIGHT = 'road_light';
const COUNT = 'count';
const INNER_RADIUS = '40%';
const OUTER_RADIUS = '70%';
interface IProps {
data: IWidgetAccidentCountByRoadLight;
segmentText: string;
}

const AccidentCountByRoadLight: FC<IProps> = () => {
return <div> {} </div>;
const AccidentCountByRoadLight: FC<IProps> = ({ data }) => {
return (
<PieChartView
data={data.items}
xLabel={ROAD_LIGHT}
yLabel={COUNT}
outerRadius={OUTER_RADIUS}
innerRadius={INNER_RADIUS}
/>
);
};
export default AccidentCountByRoadLight;
export default AccidentCountByRoadLight;
4 changes: 1 addition & 3 deletions src/components/molecules/widgets/WidgetWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ const WidgetWrapper: FC<IProps> = ({ widget, locationText, sizeOptions, editorBa
break;
}
case WidgetName.accident_count_by_road_light: {
widgetComponent = (
<AccidentCountByRoadLight data={data as IWidgetAccidentCountByRoadLight} segmentText={locationText} />
);
widgetComponent = <AccidentCountByRoadLight data={data as IWidgetAccidentCountByRoadLight} />;
break;
}
case WidgetName.accident_count_by_driver_type: {
Expand Down
5 changes: 4 additions & 1 deletion src/models/WidgetData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ export interface IWidgetTopRoadSegmentsAccidentsPerKm extends IWidgetDataBase {
items: {}[];
}
export interface IWidgetAccidentCountByRoadLight extends IWidgetDataBase {
items: {}[];
items: {
count: number;
road_light: string;
}[];
}
export interface IWidgetAccidentCountByDriverType extends IWidgetDataBase {
items: {
Expand Down

0 comments on commit 7a01b6c

Please sign in to comment.