forked from shen100/wemall
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
刘珅
committed
Apr 8, 2017
1 parent
39fc973
commit d7133ee
Showing
9 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"plugins": [ | ||
"transform-runtime", | ||
"recharts", | ||
["import", { libraryName: "antd", style: "css" }] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
nodejs/static/javascripts/admin/actions/requestRecentPV.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
REQUEST_RECENT_PV | ||
} from '../constants'; | ||
|
||
function receiveRecentPV(json) { | ||
return { | ||
type: REQUEST_RECENT_PV, | ||
recentPV: json.list | ||
}; | ||
} | ||
|
||
export default function() { | ||
return dispatch => { | ||
var url = pageConfig.apiURL + '/admin/visit/pv/latest/30'; | ||
return fetch(url) | ||
.then(response => response.json()) | ||
.then(json => dispatch(receiveRecentPV(json.data))) | ||
}; | ||
} |
119 changes: 119 additions & 0 deletions
119
nodejs/static/javascripts/admin/components/LineChart.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import React, { Component } from 'react'; | ||
import echarts from 'echarts'; | ||
|
||
export default class extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
windowWidth: window.innerWidth | ||
}; | ||
this.onResize = this.onResize.bind(this); | ||
this.updateChart = this.updateChart.bind(this); | ||
} | ||
componentDidMount() { | ||
this.updateChart(); | ||
window.addEventListener('resize', this.onResize); | ||
} | ||
componentWillUnmount() { | ||
window.removeEventListener('resize', this.onResize); | ||
} | ||
componentDidUpdate(prevProps, prevState) { | ||
this.updateChart(); | ||
} | ||
onResize() { | ||
if (this.state.windowWidth != window.innerWidth) { | ||
this.setState({ | ||
windowWidth: window.innerWidth | ||
}); | ||
} | ||
} | ||
updateChart() { | ||
var myChart = echarts.init(this.refs.chart); | ||
myChart.setOption(this.getChartOption()); | ||
} | ||
getChartOption() { | ||
let data = this.props.data; | ||
let xName = this.props.xName; | ||
let yName = this.props.yName; | ||
let title = this.props.title; | ||
let xArr = []; | ||
let yArr = []; | ||
for (let i = 0; i < data.length; i++) { | ||
xArr.push(data[i][xName]); | ||
yArr.push(data[i][yName]); | ||
} | ||
return { | ||
title: { | ||
text: title, | ||
left: 'center' | ||
}, | ||
tooltip: { | ||
trigger: 'axis', | ||
axisPointer: { | ||
lineStyle: { | ||
type: 'dashed', | ||
color: '#ddd' | ||
} | ||
}, | ||
formatter: '{b}<br/>' + title + ': {c}' | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
splitLine: {show: false}, | ||
data: xArr, | ||
axisLine: { | ||
lineStyle: { | ||
color: '#ccc', | ||
width: 1 | ||
} | ||
} | ||
}, | ||
grid: { | ||
left: '3%', | ||
right: '4%', | ||
top: '40px', | ||
bottom: '3%', | ||
containLabel: true | ||
}, | ||
yAxis: { | ||
type: 'log', | ||
splitLine: { | ||
lineStyle: { | ||
type: 'dashed', | ||
color: '#ddd' | ||
} | ||
}, | ||
axisLine: { | ||
lineStyle: { | ||
color: '#ccc', | ||
width: 1 | ||
} | ||
} | ||
}, | ||
series: [ | ||
{ | ||
type: 'line', | ||
data: yArr, | ||
itemStyle: { | ||
normal: { | ||
color: '#00c184', | ||
lineStyle: { | ||
color: '#00c184', | ||
width: 2 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}; | ||
} | ||
render() { | ||
var style = { | ||
width : '100%', | ||
height : '100%' | ||
}; | ||
return ( | ||
<div style={style} ref="chart"></div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters