Max Red - Corrected to work even if the response of system/get-stats is not the full week/month/year etc.. [skip ci]
This commit is contained in:
parent
9861bfb023
commit
19f25657ef
|
@ -44,7 +44,7 @@ class StatsChart extends React.Component {
|
|||
label: i18n('CHART_' + stroke.name),
|
||||
data: stroke.values.map((val) => val.value),
|
||||
fill: false,
|
||||
borderWidth: 4, // ESTO PODRIA CAMBIAR DEPENDIENDO DEL PERIOD, MIENTRA MAS HALLA, DEBERIA SER MAS FINO
|
||||
borderWidth: this.getBorderWidth(),
|
||||
borderColor: color[stroke.name],
|
||||
pointBorderColor: color[stroke.name],
|
||||
pointRadius: 0,
|
||||
|
@ -63,6 +63,10 @@ class StatsChart extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
getBorderWidth() {
|
||||
return (this.props.period <= 90) ? 4 : 2;
|
||||
}
|
||||
|
||||
getLabels() {
|
||||
let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
let labels = [];
|
||||
|
@ -77,9 +81,9 @@ class StatsChart extends React.Component {
|
|||
}
|
||||
|
||||
hitRadius() {
|
||||
if (this.props.period === 7) return 20;
|
||||
if (this.props.period === 30) return 15;
|
||||
if (this.props.period === 90) return 10;
|
||||
if (this.props.period <= 7) return 20;
|
||||
if (this.props.period <= 30) return 15;
|
||||
if (this.props.period <= 90) return 10;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,8 @@ class AdminPanelStats extends React.Component {
|
|||
}
|
||||
];
|
||||
|
||||
let realPeriod = result.data.length / 4;
|
||||
|
||||
for (let i = 0; i < result.data.length; i++) {
|
||||
newState[result.data[i].type] += result.data[i].value * 1;
|
||||
|
||||
|
@ -217,7 +219,7 @@ class AdminPanelStats extends React.Component {
|
|||
});
|
||||
}
|
||||
|
||||
this.setState({stats: newState, strokes: newStrokes, period: period});
|
||||
this.setState({stats: newState, strokes: newStrokes, period: realPeriod});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue