Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Sascha Herzinger
AdaCharts
Commits
49364c64
Commit
49364c64
authored
Jan 28, 2019
by
Sascha Herzinger
Browse files
added axis
parent
14781e4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/test-scatterplot.html
View file @
49364c64
...
...
@@ -40,7 +40,7 @@
function
update
()
{
scatterplot
.
update
({
values
:
generateRandomData
(
5
000
,
-
100
,
100
),
values
:
generateRandomData
(
1
000
,
-
100
,
100
),
});
}
...
...
src/assets/css/scatterplot.css
View file @
49364c64
...
...
@@ -3,3 +3,23 @@
.ac-scatter-canvas
{
position
:
absolute
;
}
.ac-scatter-axis
{
shape-rendering
:
crispEdges
;
}
.ac-scatter-axis
.tick
{
shape-rendering
:
crispEdges
;
}
.ac-scatter-axis
path
{
stroke
:
none
;
}
.ac-scatter-axis
.tick
line
{
stroke
:
#c4c4c4
;
}
.ac-scatter-axis
.tick
text
{
font-size
:
1em
;
}
src/charts/impl/Scatterplot.js
View file @
49364c64
...
...
@@ -40,13 +40,15 @@ export default class extends Chart {
const
width
=
this
.
containerWidth
-
margin
.
left
-
margin
.
right
;
const
height
=
this
.
containerWidth
-
margin
.
top
-
margin
.
bottom
;
const
padding
=
width
/
40
;
const
x
=
d3
.
scaleLinear
()
.
domain
(
d3
.
extent
(
values
.
map
(
d
=>
d
[
0
])))
.
range
([
0
,
width
]);
.
range
([
padding
,
width
-
padding
]);
const
y
=
d3
.
scaleLinear
()
.
domain
(
d3
.
extent
(
values
.
map
(
d
=>
d
[
1
])))
.
range
([
height
,
0
]);
.
range
([
height
-
padding
,
padding
]);
const
color
=
d3
.
scaleSequential
(
d3
.
interpolateBlues
)
.
domain
(
d3
.
extent
(
values
.
map
(
d
=>
d
[
2
])));
...
...
@@ -63,19 +65,37 @@ export default class extends Chart {
this
.
svg
.
attr
(
'
transform
'
,
`translate(
${
margin
.
left
}
,
${
margin
.
top
}
)`
);
const
xAxis
=
d3
.
axisBottom
(
x
);
const
yAxis
=
d3
.
axisLeft
(
y
);
const
xAxisBottom
=
d3
.
axisBottom
(
x
);
const
xAxisTop
=
d3
.
axisBottom
(
x
)
.
tickSizeInner
(
height
)
.
tickFormat
(
''
);
const
yAxisLeft
=
d3
.
axisLeft
(
y
);
const
yAxisRight
=
d3
.
axisLeft
(
y
)
.
tickSizeInner
(
width
)
.
tickFormat
(
''
);
this
.
svg
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
ac-scatter-x-axis ac-scatter-axis
'
)
.
attr
(
'
transform
'
,
`translate(0,
${
height
}
)`
)
.
call
(
xAxis
);
.
call
(
xAxisBottom
);
this
.
svg
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
ac-scatter-x-axis ac-scatter-axis
'
)
.
call
(
xAxisTop
);
this
.
svg
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
ac-scatter-y-axis ac-scatter-axis
'
)
.
call
(
yAxisLeft
);
this
.
svg
.
append
(
'
g
'
)
.
attr
(
'
class
'
,
'
ac-scatter-y-axis ac-scatter-axis
'
)
.
call
(
yAxis
);
.
attr
(
'
transform
'
,
`translate(
${
width
}
, 0)`
)
.
call
(
yAxisRight
);
const
point
=
this
.
memory
.
selectAll
(
'
.ac-scatter-point
'
)
.
data
(
values
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment