Platform
Resources
Pricing
Sign in
Get started
Samuel Gratzl
Data Visualization Engineer - Research Scientist - author of @lineupjs
Workspace
Fork
Published
By
Samuel Gratzl
Edited
Feb 20, 2020
Insert cell
md
`# LineUp.js simple example`
Insert cell
cats
=
[
'c1'
,
'c2'
,
'c3'
]
Insert cell
arr
=
{
const
arr
=
[
]
for
(
let
i
=
0
;
i
<
1000
;
++
i
)
{
arr
.
push
(
{
a
:
Math
.
random
(
)
*
10
,
d
:
'Row '
+
i
,
cat
:
cats
[
Math
.
floor
(
Math
.
random
(
)
*
3
)
]
,
cat2
:
cats
[
Math
.
floor
(
Math
.
random
(
)
*
3
)
]
}
)
}
return
arr
;
}
Insert cell
mutable
selection
=
[
]
Insert cell
{
lineup
.
on
(
'selectionChanged'
,
(
indices
)
=>
{
mutable
selection
=
indices
;
}
)
;
lineup
.
setSelection
(
selection
)
;
}
Insert cell
reset
=
{
const
b
=
html
`<button>Reset Selection</button>`
;
b
.
onclick
=
(
)
=>
mutable
selection
=
[
]
;
return
b
;
}
Insert cell
lineup
=
{
root
.
innerHTML
=
''
;
const
b
=
LineUpJS
.
builder
(
arr
)
;
b
.
deriveColumns
(
)
;
b
.
deriveColors
(
)
;
b
.
rowHeight
(
24
)
;
return
b
.
buildTaggle
(
root
)
}
Insert cell
root
=
html
`<div style="position: relative; width: 100%; height: 500px; line-height: normal !important"></div>`
Insert cell
LineUpJS
=
require
(
'lineupjs@next'
)
Insert cell
stylesheet
=
html
`<link rel='stylesheet' href='https://unpkg.com/lineupjs@next/build/LineUpJS.css' />`
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cats
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
arr
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
selection
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
reset
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
lineup
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
root
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
LineUpJS
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
stylesheet
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML