Skip to content

Commit bdeaebd

Browse files
committed
✨ Add absolute nation diff chart
Use custom fixed build of async-component with ctrlplusb/react-async-component#93
1 parent cc88cee commit bdeaebd

File tree

5 files changed

+534
-5
lines changed

5 files changed

+534
-5
lines changed

Diff for: src/components/AsyncLineChart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { asyncComponent } from 'react-async-component'
2+
import { asyncComponent } from '../vendor/react-async-component'
33
import LoadBlock from './LoadBlock'
44

55
const AsyncLineChart = asyncComponent({

Diff for: src/components/ChromeRivals/OnlineCountChart.js

+39-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import subDays from 'date-fns/subDays'
88
import startOfHour from 'date-fns/startOfHour'
99
import startOfday from 'date-fns/startOfDay'
1010

11-
const options = (scale = 'day') => {
11+
const options = (scale = 'day', yLabelString = 'Pl. Count') => {
1212
return {
1313
elements: {
1414
point: { radius: 0 }
@@ -47,7 +47,7 @@ const options = (scale = 'day') => {
4747

4848
scaleLabel: {
4949
display: true,
50-
labelString: 'Pl. Count'
50+
labelString: yLabelString
5151
}
5252
}
5353
]
@@ -159,6 +159,7 @@ class PlayerFameChart extends Component {
159159
const startDate = subDays(new Date(), backdays)
160160

161161
let serieses = { BCU: [], ANI: [] }
162+
let diffSerieses = { BCU: [], ANI: [] }
162163

163164
data.forEach(row => {
164165
const dt = row.timestamp
@@ -175,6 +176,15 @@ class PlayerFameChart extends Component {
175176
x: dt,
176177
y: row.ani
177178
})
179+
180+
diffSerieses.ANI.push({
181+
x: dt,
182+
y: Math.max(0, row.ani - row.bcu)
183+
})
184+
diffSerieses.BCU.push({
185+
x: dt,
186+
y: Math.max(0, row.bcu - row.ani)
187+
})
178188
})
179189

180190
let datasets = Object.keys(serieses).map(function(seriesKey) {
@@ -191,6 +201,20 @@ class PlayerFameChart extends Component {
191201
pointRadius: 3
192202
}
193203
})
204+
let datasetsDiff = Object.keys(diffSerieses).map(function(seriesKey) {
205+
return {
206+
fill: true,
207+
borderColor: seriesColorCoding[seriesKey],
208+
backgroundColor: seriesColorCoding[seriesKey],
209+
borderWidth: 0,
210+
//cubicInterpolationMode:'monotone',
211+
steppedLine: true,
212+
//showLine: false,
213+
label: seriesKey,
214+
data: diffSerieses[seriesKey],
215+
pointRadius: 0
216+
}
217+
})
194218

195219
let width = 45 * backdays
196220

@@ -209,6 +233,19 @@ class PlayerFameChart extends Component {
209233
type="line"
210234
/>
211235
</div>
236+
<div
237+
style={{
238+
width: width > window.innerWidth ? width + 'px' : '100%',
239+
height: '200px',
240+
position: 'relative'
241+
}}
242+
>
243+
<AsyncLineChart
244+
options={options(backdays < 4 ? 'hour' : 'day', 'Nation diff')}
245+
data={{ datasets: datasetsDiff }}
246+
type="line"
247+
/>
248+
</div>
212249
</div>
213250
)
214251
}

Diff for: src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ScrollToTop from './components/ScrollToTop'
1414
import App from './containers/App'
1515
import * as serviceWorker from './serviceWorker'
1616

17-
import { AsyncComponentProvider } from 'react-async-component'
17+
import { AsyncComponentProvider } from './vendor/react-async-component'
1818

1919
import toast from './utils/toast'
2020

Diff for: src/routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Home from './components/Home'
55
import NoMatch from './components/NoMatch'
66

77
import lazyImport from './utils/lazyImportHack'
8-
import { asyncComponent } from 'react-async-component'
8+
import { asyncComponent } from './vendor/react-async-component'
99
import LoadBlock from './components/LoadBlock'
1010

1111
export const crTopKillsIntervalUrl = '/killsBetween'

0 commit comments

Comments
 (0)