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
12b94554
Commit
12b94554
authored
3 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Bar chart race: use id and prefLabel
parent
ba49a59d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client/components/facet_results/BarChartRace.js
+23
-18
23 additions, 18 deletions
src/client/components/facet_results/BarChartRace.js
src/server/sparql/Mappers.js
+0
-1
0 additions, 1 deletion
src/server/sparql/Mappers.js
with
23 additions
and
19 deletions
src/client/components/facet_results/BarChartRace.js
+
23
−
18
View file @
12b94554
...
...
@@ -8,8 +8,7 @@ import Paper from '@material-ui/core/Paper'
// https://www.amcharts.com/docs/v5/
const
stepDuration
=
2000
// const startYear = 1400
const
startYear
=
1000
const
startYear
=
500
let
year
=
startYear
const
yearIncrement
=
10
class
BarChartRace
extends
React
.
Component
{
...
...
@@ -80,6 +79,8 @@ class BarChartRace extends React.Component {
// hide grid
yRenderer
.
grid
.
template
.
set
(
'
visible
'
,
false
)
// console.log(yRenderer.labels.template)
this
.
yAxis
=
chart
.
yAxes
.
push
(
am5xy
.
CategoryAxis
.
new
(
root
,
{
maxDeviation
:
0
,
extraMax
:
0.1
,
...
...
@@ -87,6 +88,10 @@ class BarChartRace extends React.Component {
renderer
:
yRenderer
}))
this
.
yAxis
.
get
(
'
renderer
'
).
labels
.
template
.
adapters
.
add
(
'
text
'
,
(
label
,
target
,
key
)
=>
{
return
target
.
dataItem
.
dataContext
.
prefLabel
})
const
xAxis
=
chart
.
xAxes
.
push
(
am5xy
.
ValueAxis
.
new
(
root
,
{
maxDeviation
:
0
,
min
:
0
,
...
...
@@ -149,30 +154,30 @@ class BarChartRace extends React.Component {
setInitialData
=
()
=>
{
const
step
=
this
.
props
.
results
[
year
]
for
(
const
id
in
step
)
{
const
{
prefLabel
}
=
step
[
id
]
this
.
series
.
data
.
push
({
category
:
prefLabel
,
value
:
0
,
id
})
this
.
yAxis
.
data
.
push
({
category
:
prefLabel
})
const
{
prefLabel
,
value
}
=
step
[
id
]
this
.
series
.
data
.
push
({
category
:
id
,
value
,
prefLabel
})
this
.
yAxis
.
data
.
push
({
category
:
id
,
prefLabel
})
}
this
.
yAxis
.
zoomToIndexes
(
0
,
1
)
// hack to fix initial pan / zoom
}
updateData
=
()
=>
{
let
itemsWithNonZero
=
0
//
let itemsWithNonZero = 0
if
(
this
.
props
.
results
[
year
])
{
for
(
const
[
key
,
value
]
of
Object
.
entries
(
this
.
props
.
results
[
year
]))
{
const
{
prefLabel
}
=
value
const
dataItem
=
this
.
getSeriesItem
(
prefLabel
)
const
dataItem
=
this
.
getSeriesItem
(
key
)
if
(
dataItem
==
null
)
{
this
.
series
.
data
.
push
({
category
:
prefLabel
,
value
:
value
.
value
,
id
:
key
})
this
.
yAxis
.
data
.
push
({
category
:
prefLabel
})
this
.
series
.
data
.
push
({
category
:
key
,
value
:
value
.
value
,
prefLabel
:
value
.
prefLabel
})
this
.
yAxis
.
data
.
push
({
category
:
key
,
prefLabel
:
value
.
prefLabel
})
}
}
this
.
label
.
set
(
'
text
'
,
year
.
toString
())
am5
.
array
.
each
(
this
.
series
.
dataItems
,
dataItem
=>
{
const
{
id
}
=
dataItem
.
dataContext
const
value
=
this
.
props
.
results
[
year
][
id
].
value
if
(
value
>
0
)
{
itemsWithNonZero
++
}
const
category
=
dataItem
.
get
(
'
categoryY
'
)
const
value
=
this
.
props
.
results
[
year
][
category
].
value
//
if (value > 0) {
//
itemsWithNonZero++
//
}
dataItem
.
animate
({
key
:
'
valueX
'
,
to
:
value
,
...
...
@@ -186,7 +191,8 @@ class BarChartRace extends React.Component {
easing
:
am5
.
ease
.
linear
})
})
this
.
yAxis
.
zoom
(
0
,
itemsWithNonZero
/
this
.
yAxis
.
dataItems
.
length
)
this
.
yAxis
.
zoomToIndexes
(
0
,
15
)
// this.yAxis.zoom(0, itemsWithNonZero / this.yAxis.dataItems.length)
}
}
...
...
@@ -196,8 +202,7 @@ class BarChartRace extends React.Component {
// year++
year
+=
yearIncrement
if
(
year
>
1200
)
{
console
.
log
(
year
)
if
(
year
>
1900
)
{
clearInterval
(
interval
)
clearInterval
(
this
.
sortInterval
)
// sort category axis one more time
...
...
This diff is collapsed.
Click to expand it.
src/server/sparql/Mappers.js
+
0
−
1
View file @
12b94554
...
...
@@ -306,6 +306,5 @@ const mergeDataItems = (itemA, itemB) => {
merged
[
itemBkey
]
=
itemB
[
itemBkey
]
}
}
merged
[
'
http://ldf.fi/mmm/place/
'
]
=
{
prefLabel
:
'
0
'
,
value
:
0
}
return
merged
}
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