Skip to content

Commit ef32af6

Browse files
authored
Revert "Revert "Update AccidentCountByRoadLight""
1 parent bcf7628 commit ef32af6

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import React, { FC } from 'react';
22
import { IWidgetAccidentCountByRoadLight } from 'models/WidgetData';
3+
import PieChartView from 'components/molecules/PieChartView';
34

5+
const ROAD_LIGHT = 'road_light';
6+
const COUNT = 'count';
7+
const INNER_RADIUS = '40%';
8+
const OUTER_RADIUS = '70%';
49
interface IProps {
510
data: IWidgetAccidentCountByRoadLight;
6-
segmentText: string;
711
}
812

9-
const AccidentCountByRoadLight: FC<IProps> = () => {
10-
return <div> {} </div>;
13+
const AccidentCountByRoadLight: FC<IProps> = ({ data }) => {
14+
return (
15+
<PieChartView
16+
data={data.items}
17+
xLabel={ROAD_LIGHT}
18+
yLabel={COUNT}
19+
outerRadius={OUTER_RADIUS}
20+
innerRadius={INNER_RADIUS}
21+
/>
22+
);
1123
};
12-
export default AccidentCountByRoadLight;
24+
export default AccidentCountByRoadLight;

src/components/molecules/widgets/WidgetWrapper.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ const WidgetWrapper: FC<IProps> = ({ widget, locationText, sizeOptions, editorBa
199199
break;
200200
}
201201
case WidgetName.accident_count_by_road_light: {
202-
widgetComponent = (
203-
<AccidentCountByRoadLight data={data as IWidgetAccidentCountByRoadLight} segmentText={locationText} />
204-
);
202+
widgetComponent = <AccidentCountByRoadLight data={data as IWidgetAccidentCountByRoadLight} />;
205203
break;
206204
}
207205
case WidgetName.accident_count_by_driver_type: {

src/models/WidgetData.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ export interface IWidgetTopRoadSegmentsAccidentsPerKm extends IWidgetDataBase {
157157
items: {}[];
158158
}
159159
export interface IWidgetAccidentCountByRoadLight extends IWidgetDataBase {
160-
items: {}[];
160+
items: {
161+
count: number;
162+
road_light: string;
163+
}[];
161164
}
162165
export interface IWidgetAccidentCountByDriverType extends IWidgetDataBase {
163166
items: {

0 commit comments

Comments
 (0)