This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from AndresMorelos/Statistics
Adding statistics views.
- Loading branch information
Showing
35 changed files
with
890 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Libs | ||
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ResponsiveCalendar } from '@nivo/calendar'; | ||
|
||
// Component | ||
class CalendarChart extends PureComponent { | ||
render() { | ||
const { data } = this.props; | ||
return ( | ||
<ResponsiveCalendar | ||
data={data} | ||
from={new Date(new Date().getFullYear(), 0, 1)} | ||
to={new Date(new Date().getFullYear(), 12, 0)} | ||
granularity="month" | ||
emptyColor="#eeeeee" | ||
colors={['#61cdbb', '#97e3d5', '#e8c1a0', '#f47560']} | ||
margin={{ top: 40, right: 40, bottom: 40, left: 40 }} | ||
yearSpacing={40} | ||
monthBorderColor="#ffffff" | ||
dayBorderWidth={2} | ||
dayBorderColor="#ffffff" | ||
legends={[ | ||
{ | ||
anchor: 'bottom-right', | ||
direction: 'row', | ||
translateY: 36, | ||
itemCount: 4, | ||
itemWidth: 42, | ||
itemHeight: 36, | ||
itemsSpacing: 14, | ||
itemDirection: 'right-to-left', | ||
}, | ||
]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
CalendarChart.propTypes = { | ||
data: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
}; | ||
|
||
export default CalendarChart; |
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,23 @@ | ||
import React from 'react' | ||
|
||
const CustomSymbol = function({ size, color, borderWidth, borderColor }){ | ||
return ( | ||
<g> | ||
<circle | ||
fill="#fff" | ||
r={size / 2} | ||
strokeWidth={borderWidth} | ||
stroke={borderColor} | ||
/> | ||
<circle | ||
r={size / 5} | ||
strokeWidth={borderWidth} | ||
stroke={borderColor} | ||
fill={color} | ||
fillOpacity={0.35} | ||
/> | ||
</g> | ||
) | ||
}; | ||
|
||
export default CustomSymbol; |
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,72 @@ | ||
// Libs | ||
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ResponsivePie } from '@nivo/pie'; | ||
|
||
const commonProperties = { | ||
margin: { top: 80, right: 120, bottom: 80, left: 120 }, | ||
animate: true, | ||
activeOuterRadiusOffset: 8, | ||
}; | ||
|
||
// Component | ||
class PieChart extends PureComponent { | ||
render() { | ||
const { data } = this.props; | ||
return ( | ||
<ResponsivePie | ||
data={data} | ||
margin={{ top: 40, right: 80, bottom: 80, left: 80 }} | ||
innerRadius={0.5} | ||
padAngle={0.7} | ||
cornerRadius={3} | ||
activeOuterRadiusOffset={8} | ||
borderWidth={1} | ||
borderColor={{ | ||
from: 'color', | ||
modifiers: [['darker', 0.2]], | ||
}} | ||
arcLinkLabelsSkipAngle={10} | ||
arcLinkLabelsTextColor="#333333" | ||
arcLinkLabelsThickness={2} | ||
arcLinkLabelsColor={{ from: 'color' }} | ||
arcLabelsSkipAngle={10} | ||
arcLabelsTextColor={{ | ||
from: 'color', | ||
modifiers: [['darker', 2]], | ||
}} | ||
legends={[ | ||
{ | ||
anchor: 'bottom', | ||
direction: 'row', | ||
justify: false, | ||
translateX: 0, | ||
translateY: 56, | ||
itemsSpacing: 0, | ||
itemWidth: 100, | ||
itemHeight: 18, | ||
itemTextColor: '#999', | ||
itemDirection: 'left-to-right', | ||
itemOpacity: 1, | ||
symbolSize: 18, | ||
symbolShape: 'circle', | ||
effects: [ | ||
{ | ||
on: 'hover', | ||
style: { | ||
itemTextColor: '#000', | ||
}, | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
PieChart.propTypes = { | ||
data: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
}; | ||
|
||
export default PieChart; |
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,93 @@ | ||
// Libs | ||
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ResponsiveLine } from '@nivo/line'; | ||
import CustomSymbol from './CustomSymbol'; | ||
|
||
const commonProperties = { | ||
margin: { top: 50, right: 20, bottom: 60, left: 80 }, | ||
animate: true, | ||
enableSlices: 'x', | ||
}; | ||
|
||
// Component | ||
class TimeLineChart extends PureComponent { | ||
render() { | ||
const { data, yLegend, xLegend } = this.props; | ||
return ( | ||
<ResponsiveLine | ||
{...commonProperties} | ||
data={data} | ||
xScale={{ | ||
type: 'time', | ||
format: '%Y-%m-%d', | ||
useUTC: false, | ||
precision: 'day', | ||
}} | ||
xFormat="time:%Y/%m/%d" | ||
yScale={{ | ||
type: 'linear', | ||
stacked: false, | ||
}} | ||
yFormat=" >-$.2f" | ||
axisLeft={{ | ||
legend: yLegend, | ||
legendOffset: -60, | ||
legendPosition: 'middle', | ||
}} | ||
axisBottom={{ | ||
format: '%b %d', | ||
tickValues: 'every 2 days', | ||
legend: xLegend, | ||
legendOffset: 36, | ||
legendPosition: 'middle', | ||
}} | ||
curve="monotoneX" | ||
enablePointLabel | ||
pointSymbol={CustomSymbol} | ||
pointSize={16} | ||
pointLabelYOffset={-12} | ||
pointBorderWidth={1} | ||
pointBorderColor={{ | ||
from: 'color', | ||
modifiers: [['darker', 0.3]], | ||
}} | ||
useMesh | ||
colors={{ scheme: 'category10' }} | ||
enableSlices={false} | ||
legends={[ | ||
{ | ||
anchor: 'bottom-right', | ||
direction: 'row', | ||
translateX: 0, | ||
translateY: 60, | ||
itemsSpacing: 15, | ||
itemWidth: 80, | ||
itemHeight: 20, | ||
itemOpacity: 0.75, | ||
symbolSize: 12, | ||
symbolShape: 'circle', | ||
symbolBorderColor: 'rgba(0, 0, 0, .5)', | ||
effects: [ | ||
{ | ||
on: 'hover', | ||
style: { | ||
itemBackground: 'rgba(0, 0, 0, .03)', | ||
itemOpacity: 1, | ||
}, | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
TimeLineChart.propTypes = { | ||
data: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
yLegend: PropTypes.string.isRequired, | ||
xLegend: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default TimeLineChart; |
Oops, something went wrong.