Skip to content

Commit

Permalink
Merge pull request #1 from ziwu7/qrz
Browse files Browse the repository at this point in the history
Addition of epidemic data statistics page
  • Loading branch information
ziwu7 authored Aug 3, 2024
2 parents 94b16ae + 380592f commit 036b9bc
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"classnames": "^2.5.1",
"dom-renderer": "^2.1.8",
"echarts": "^5.5.0",
"echarts-jsx": "^1.2.0",
"echarts-jsx": "^1.2.1",
"github-web-widget": "^4.0.0-rc.2",
"koajax": "^1.1.2",
"mobx": "^6.12.4",
Expand Down
69 changes: 40 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 133 additions & 0 deletions source/page/Statistics/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { observable } from 'mobx';
import {component,observer} from 'web-cell';
import {Overall,AreaData,getOverall,getArea } from '../../service/Epidemic';
import 'echarts-jsx/dist/renderers/SVG';
import 'echarts-jsx/dist/components/title';
import 'echarts-jsx/dist/components/legend';
import 'echarts-jsx/dist/components/tooltip';
import 'echarts-jsx/dist/components/grid';
import 'echarts-jsx/dist/components/x-axis';
import 'echarts-jsx/dist/components/y-axis';
import 'echarts-jsx/dist/charts/line';
import 'echarts-jsx/dist/charts/bar';

@component({ tagName: 'statistics-page' })
@observer
export default class StatisticsPage extends HTMLElement {

@observable
accessor virusData : {
overAll: Overall[];
areaData:AreaData[];
}
async mountedCallback() {
const [overall,areadata] =await Promise.all([getOverall(),getArea()])

this.virusData = {
overAll:overall,
areaData:areadata,
}
}
toMonth(dateString){
let date = new Date(dateString);
let year = date.getFullYear();
let month = date.getMonth();
return new Date(year, month);
}

render(){
if(this.virusData){
let confirmedCount = this.virusData.overAll.map(item=>[this.toMonth(item.updateTime),item.confirmedCount])
let suspectedCount = this.virusData.overAll.map(item=>[this.toMonth(item.updateTime),item.suspectedCount])
let curedCount = this.virusData.overAll.map(item=>[this.toMonth(item.updateTime),item.curedCount])
let deadCount = this.virusData.overAll.map(item=>[this.toMonth(item.updateTime),item.deadCount])
let seriousCount = this.virusData.overAll.map(item=>[this.toMonth(item.updateTime),item.seriousCount])

let cityData = this.virusData.areaData.filter((item)=>{
if(item.provinceName==='广东省'){return item}
})
let city_confirmedCounts = cityData.map((item)=>[item.cityName,item.city_confirmedCount])
let city_curedCounts = cityData.map((item)=>[item.cityName,item.city_curedCount])
let city_suspectedCounts = cityData.map((item)=>[item.cityName,item.city_suspectedCount])
let city_deadCounts = cityData.map((item)=>[item.cityName,item.city_deadCount])
return (
<div>
<ec-svg-renderer
className="w-100 h-50"
>
<ec-title text="患者人数数据" top="5%" x="center" />
<ec-legend
orient="horizontal"
bottom="13%"
data={['确诊',"恢复",'严重',"疑似",'死亡']}
/>
<ec-tooltip trigger="axis" />
<ec-grid bottom="25%" left={60} />
<ec-x-axis name="日期" type="time" nameGap={5} />
<ec-y-axis id='y1' name="确诊&恢复&严重人数" type="value" nameGap={10} />
<ec-y-axis id='y2' name="疑似&死亡人数" type="value" nameGap={10} />

<ec-bar-chart
data={confirmedCount}
name="确诊"
/>
<ec-bar-chart
data={curedCount}
name="恢复"
/>
<ec-bar-chart
data={seriousCount}
name="严重"
/>
<ec-line-chart
data={suspectedCount}
yAxisIndex={1}
name="疑似"
/>
<ec-line-chart
data={deadCount}
yAxisIndex={1}
name="死亡"
/>
</ec-svg-renderer>

<ec-svg-renderer
className="w-100 h-50"
>
<ec-title text="患者人数地市分布" top="5%" x="center" />
<ec-legend
orient="horizontal"
bottom="13%"
data={['确诊',"恢复",'疑似','死亡']}
/>
<ec-tooltip trigger="axis" />
<ec-grid bottom="25%" left={60} />
<ec-x-axis name="地市" type="category" nameGap={5} />
<ec-y-axis id='y1' name="确诊&恢复人数" type="value" nameGap={10} />
<ec-y-axis id='y2' name="疑似&死亡人数" type="value" nameGap={10} />

<ec-bar-chart
data={city_confirmedCounts}
name="确诊"
/>
<ec-bar-chart
data={city_curedCounts}
name="恢复"
/>
<ec-line-chart
data={city_suspectedCounts}
name="疑似"
yAxisIndex={1}
/>
<ec-line-chart
data={city_deadCounts}
name="死亡"
yAxisIndex={1}
/>

</ec-svg-renderer>
</div>
);
}
}
}
7 changes: 6 additions & 1 deletion source/page/data/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export enum RouteRoot {
Clinic = 'clinic',
Maps = 'maps',
Admin = 'admin',
Community = 'community'
Community = 'community',
Statistics = 'statistics'
}

export default [
Expand Down Expand Up @@ -58,5 +59,9 @@ export default [
{
title: '开放社区',
href: RouteRoot.Community
},
{
title: '疫情统计',
href: RouteRoot.Statistics
}
];
Loading

0 comments on commit 036b9bc

Please sign in to comment.