Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
5edc9b3c
Commit
5edc9b3c
authored
3 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Bar chart race: use arrow functions
parent
0790732c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/client/components/facet_results/BarChartRace.js
+22
-18
22 additions, 18 deletions
src/client/components/facet_results/BarChartRace.js
with
22 additions
and
18 deletions
src/client/components/facet_results/BarChartRace.js
+
22
−
18
View file @
5edc9b3c
...
@@ -3,6 +3,7 @@ import React from 'react'
...
@@ -3,6 +3,7 @@ import React from 'react'
import
*
as
am5
from
'
@amcharts/amcharts5
'
import
*
as
am5
from
'
@amcharts/amcharts5
'
import
*
as
am5xy
from
'
@amcharts/amcharts5/xy
'
import
*
as
am5xy
from
'
@amcharts/amcharts5/xy
'
import
am5themesAnimated
from
'
@amcharts/amcharts5/themes/Animated
'
import
am5themesAnimated
from
'
@amcharts/amcharts5/themes/Animated
'
import
Paper
from
'
@material-ui/core/Paper
'
/**
/**
* ---------------------------------------
* ---------------------------------------
...
@@ -379,7 +380,7 @@ const allData = {
...
@@ -379,7 +380,7 @@ const allData = {
const
stepDuration
=
2000
const
stepDuration
=
2000
cons
t
year
=
2002
le
t
year
=
2002
class
BarChartRace
extends
React
.
Component
{
class
BarChartRace
extends
React
.
Component
{
componentDidMount
=
()
=>
{
componentDidMount
=
()
=>
{
...
@@ -455,11 +456,11 @@ class BarChartRace extends React.Component {
...
@@ -455,11 +456,11 @@ class BarChartRace extends React.Component {
this
.
series
.
columns
.
template
.
setAll
({
cornerRadiusBR
:
5
,
cornerRadiusTR
:
5
})
this
.
series
.
columns
.
template
.
setAll
({
cornerRadiusBR
:
5
,
cornerRadiusTR
:
5
})
// Make each column to be of a different color
// Make each column to be of a different color
this
.
series
.
columns
.
template
.
adapters
.
add
(
'
fill
'
,
function
(
fill
,
target
)
{
this
.
series
.
columns
.
template
.
adapters
.
add
(
'
fill
'
,
(
fill
,
target
)
=>
{
return
chart
.
get
(
'
colors
'
).
getIndex
(
this
.
series
.
columns
.
indexOf
(
target
))
return
chart
.
get
(
'
colors
'
).
getIndex
(
this
.
series
.
columns
.
indexOf
(
target
))
})
})
this
.
series
.
columns
.
template
.
adapters
.
add
(
'
stroke
'
,
function
(
stroke
,
target
)
{
this
.
series
.
columns
.
template
.
adapters
.
add
(
'
stroke
'
,
(
stroke
,
target
)
=>
{
return
chart
.
get
(
'
colors
'
).
getIndex
(
this
.
series
.
columns
.
indexOf
(
target
))
return
chart
.
get
(
'
colors
'
).
getIndex
(
this
.
series
.
columns
.
indexOf
(
target
))
})
})
...
@@ -488,22 +489,22 @@ class BarChartRace extends React.Component {
...
@@ -488,22 +489,22 @@ class BarChartRace extends React.Component {
}))
}))
// update data with values each 1.5 sec
// update data with values each 1.5 sec
//
const interval = setInterval(
function ()
{
const
interval
=
setInterval
(
()
=>
{
//
year++
year
++
//
if (year > 2018) {
if
(
year
>
2018
)
{
//
clearInterval(interval)
clearInterval
(
interval
)
//
clearInterval(this.sortInterval)
clearInterval
(
this
.
sortInterval
)
//
}
}
//
this.updateData()
this
.
updateData
()
//
}, stepDuration)
},
stepDuration
)
//
this.setInitialData()
this
.
setInitialData
()
//
setTimeout(
function ()
{
setTimeout
(
()
=>
{
//
year++
year
++
//
this.updateData()
this
.
updateData
()
//
}, 50)
},
50
)
// Make stuff animate on load
// Make stuff animate on load
// https://www.amcharts.com/docs/v5/concepts/animations/
// https://www.amcharts.com/docs/v5/concepts/animations/
...
@@ -583,7 +584,7 @@ class BarChartRace extends React.Component {
...
@@ -583,7 +584,7 @@ class BarChartRace extends React.Component {
})
})
// go through each axis item
// go through each axis item
am5
.
array
.
each
(
this
.
yAxis
.
dataItems
,
function
(
dataItem
)
{
am5
.
array
.
each
(
this
.
yAxis
.
dataItems
,
dataItem
=>
{
// get corresponding series item
// get corresponding series item
const
seriesDataItem
=
this
.
getSeriesItem
(
dataItem
.
get
(
'
category
'
))
const
seriesDataItem
=
this
.
getSeriesItem
(
dataItem
.
get
(
'
category
'
))
...
@@ -617,7 +618,10 @@ class BarChartRace extends React.Component {
...
@@ -617,7 +618,10 @@ class BarChartRace extends React.Component {
render
()
{
render
()
{
return
(
return
(
<
div
id
=
'
chartdiv
'
style
=
{{
width
:
'
100%
'
,
height
:
'
500px
'
}}
/
>
<
Paper
>
<
div
id
=
'
chartdiv
'
style
=
{{
width
:
'
100%
'
,
height
:
'
700px
'
}}
/
>
<
/Paper
>
)
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment