Skip to content

Commit bffbc59

Browse files
committed
adjust timeline padding, change back button style
1 parent 26d6901 commit bffbc59

File tree

3 files changed

+80
-41
lines changed

3 files changed

+80
-41
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ yarn-error.log*
3030
/tmp
3131
/.vscode
3232
/.idea
33-
/.DS_Store
33+
/.DS_Store
34+
35+
demo/node_modules

src/components/virusMap/hierarchicalVirusMap.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { VirusMap } from './virusMap';
1414
import { extractCitiesSeries } from '../../adapters/isaaclin';
1515

1616
type MapDataType = {
17-
[name: string]: any
17+
[name: string]: any;
1818
};
1919

2020
type STMapDataType = {
@@ -26,15 +26,14 @@ type Props = {
2626
data: any;
2727
resolution: number;
2828
type: 'overview' | 'pc' | 'mobile';
29-
}
29+
};
3030

3131
type State = {
3232
path: string[];
3333
currentChartArea: string;
34-
}
34+
};
3535

3636
class HierarchicalVirusMap extends React.Component<Props, Readonly<State>> {
37-
3837
constructor(props: Props) {
3938
super(props);
4039
this.state = {
@@ -51,7 +50,7 @@ class HierarchicalVirusMap extends React.Component<Props, Readonly<State>> {
5150
resolution: 3600000,
5251
type: 'pc',
5352
detail: true
54-
}
53+
};
5554

5655
navigateDown(params: any) {
5756
// enter province view
@@ -126,7 +125,10 @@ class HierarchicalVirusMap extends React.Component<Props, Readonly<State>> {
126125
resolution
127126
);
128127

129-
const current = data.provincesSeries[Math.max(...Object.keys(data.provincesSeries).map(t => parseInt(t, 10)))];
128+
const current =
129+
data.provincesSeries[
130+
Math.max(...Object.keys(data.provincesSeries).map(t => parseInt(t, 10)))
131+
];
130132

131133
return (
132134
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
@@ -139,27 +141,35 @@ class HierarchicalVirusMap extends React.Component<Props, Readonly<State>> {
139141
chartData={data}
140142
chartPath={path}
141143
currentChartArea={currentChartArea}
142-
chartOnClickCallBack={type === 'overview' ? () => { } : config.navigateDown}
144+
chartOnClickCallBack={
145+
type === 'overview' ? () => {} : config.navigateDown
146+
}
143147
type={type}
144-
// onDblClick={this.navigateUp.bind(this)}
148+
// onDblClick={this.navigateUp.bind(this)}
145149
/>
146150
<button
147151
style={{
148152
display: this.state.path.length > 0 ? 'block' : 'none',
149-
width: '50px',
153+
width: '30px',
150154
height: '30px',
151155
position: 'absolute',
152156
top: '50px',
153157
left: '120px',
154-
padding: '5px'
158+
padding: '5px',
159+
backgroundColor: '#86868d',
160+
border: 'none',
161+
borderRadius: '3px',
162+
fontWeight: 'bolder',
163+
color: 'white',
164+
fontSize: '13pt'
155165
}}
156166
onClick={this.navigateUp.bind(this)}
157167
>
158-
<span>back</span>
168+
<span>-</span>
159169
</button>
160170
</div>
161171
);
162172
}
163173
}
164174

165-
export default HierarchicalVirusMap;
175+
export default HierarchicalVirusMap;

src/components/virusMap/virusMap.tsx

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { VirusChart } from './virusChart';
2020
import mapUrls from '../../data/map/district';
2121

2222
type MapDataType = {
23-
[name: string]: any
23+
[name: string]: any;
2424
};
2525

2626
type STMapDataType = {
@@ -41,7 +41,7 @@ interface Props {
4141

4242
const mapName = (name: string) => {
4343
return name === '中国' ? 'china' : 'map';
44-
}
44+
};
4545

4646
const PALETTE = [
4747
'#FFFFFF',
@@ -68,8 +68,7 @@ function createPieces(breaks: number[], palette: string[]) {
6868
];
6969
}
7070

71-
export class VirusMap extends React.Component<Props> {
72-
71+
export class VirusMap extends React.Component<Props> {
7372
constructor(props: Props) {
7473
super(props);
7574
this.state = {
@@ -89,7 +88,7 @@ export class VirusMap extends React.Component<Props> {
8988
chartOnClickCallBack: (param: any, chart: any) => {
9089
console.log(param, chart);
9190
}
92-
}
91+
};
9392

9493
public state = {
9594
mapScale: 1,
@@ -190,7 +189,9 @@ export class VirusMap extends React.Component<Props> {
190189
outputArray.push('死亡:' + data[params.name].dead);
191190
}
192191
if (this.props.type === 'mobile') {
193-
outputArray.push('<br/><div id="tooltip-detail">再次点击查看详情</div>');
192+
outputArray.push(
193+
'<br/><div id="tooltip-detail">再次点击查看详情</div>'
194+
);
194195
}
195196
return outputArray.join('<br/>');
196197
}
@@ -227,6 +228,8 @@ export class VirusMap extends React.Component<Props> {
227228
// autoPlay: true,
228229
playInterval: 1500,
229230
currentIndex: data.timeline.length - 1,
231+
left: '20px',
232+
right: '20px',
230233
data: data.timeline,
231234
label: {
232235
fontSize: 10,
@@ -236,7 +239,7 @@ export class VirusMap extends React.Component<Props> {
236239
align: 'right',
237240
baseline: 'middle'
238241
},
239-
formatter: function (param: any) {
242+
formatter: function(param: any) {
240243
return new Date(parseInt(param, 10))
241244
.toLocaleDateString('zh-CN')
242245
.substring(5); // year is not necessary, standardize to ISO
@@ -254,22 +257,44 @@ export class VirusMap extends React.Component<Props> {
254257
}
255258

256259
public render() {
257-
const { name, data, chartOnClickCallBack, chartData, chartPath, currentChartArea, type } = this.props;
258-
const mapUrl = mapUrls[name]
260+
const {
261+
name,
262+
data,
263+
chartOnClickCallBack,
264+
chartData,
265+
chartPath,
266+
currentChartArea,
267+
type
268+
} = this.props;
269+
const mapUrl = mapUrls[name];
259270

260271
return (
261-
<div style={
262-
type === 'mobile' ?
263-
{ display: 'flex', flexDirection: 'column', width: '100%', height: '100%' } :
264-
{ display: 'flex', flexDirection: 'row', width: '100%', height: '100%' }
265-
}>
266-
<div style={
267-
type !== 'mobile' ?
268-
type !== 'overview' ?
269-
{ width: '65%', height: '100%' } :
270-
{ width: '100%', height: '100%' } :
271-
{ width: '100%', height: '50%' }
272-
}>
272+
<div
273+
style={
274+
type === 'mobile'
275+
? {
276+
display: 'flex',
277+
flexDirection: 'column',
278+
width: '100%',
279+
height: '100%'
280+
}
281+
: {
282+
display: 'flex',
283+
flexDirection: 'row',
284+
width: '100%',
285+
height: '100%'
286+
}
287+
}
288+
>
289+
<div
290+
style={
291+
type !== 'mobile'
292+
? type !== 'overview'
293+
? { width: '65%', height: '100%' }
294+
: { width: '100%', height: '100%' }
295+
: { width: '100%', height: '50%' }
296+
}
297+
>
273298
<EchartsMap
274299
mapUrl={mapUrl}
275300
mapName={mapName(name)}
@@ -282,13 +307,15 @@ export class VirusMap extends React.Component<Props> {
282307
mobile={type === 'mobile'}
283308
/>
284309
</div>
285-
<div style={
286-
type !== 'mobile' ?
287-
type !== 'overview' ?
288-
{ width: '65%', height: '100%' } :
289-
{ display: 'none' } :
290-
{ width: '100%', height: '50%' }
291-
}>
310+
<div
311+
style={
312+
type !== 'mobile'
313+
? type !== 'overview'
314+
? { width: '65%', height: '100%' }
315+
: { display: 'none' }
316+
: { width: '100%', height: '50%' }
317+
}
318+
>
292319
<VirusChart
293320
data={chartData}
294321
area={currentChartArea}

0 commit comments

Comments
 (0)