@@ -8,7 +8,7 @@ import subDays from 'date-fns/subDays'
88import startOfHour from 'date-fns/startOfHour'
99import 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 }
0 commit comments