Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Sascha Herzinger
AdaCharts
Commits
ec6bc08e
Commit
ec6bc08e
authored
Mar 29, 2019
by
Sascha Herzinger
Browse files
fixed positioning of cat bars
parent
01b1e3d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/assets/css/barplot.css
View file @
ec6bc08e
...
...
@@ -10,7 +10,7 @@
}
.ac-bar-bar
text
{
color
:
#797979
;
fill
:
#797979
;
}
.ac-bar-bar
rect
:hover
{
...
...
src/charts/impl/Barplot.js
View file @
ec6bc08e
...
...
@@ -3,7 +3,8 @@ import Chart from '../Chart';
import
'
../../assets/css/barplot.css
'
;
import
textUtils
from
'
../../utils/textwrappers
'
;
const
BAR_PADDING_FACTOR
=
0.2
;
const
BAR_PADDING_FACTOR
=
0.1
;
const
CATEGORY_PADDING_FACTOR
=
0.2
;
const
OUTER_PADDING_FACTOR
=
0.1
;
export
default
class
extends
Chart
{
...
...
@@ -96,7 +97,7 @@ export default class extends Chart {
if
(
dataType
.
startsWith
(
'
cat
'
))
{
return
d3
.
scaleBand
()
.
domain
(
uniXValues
)
.
range
([
outerPadding
,
width
-
outerPadding
]);
.
range
([
0
,
width
]);
}
return
d3
.
scaleLinear
()
.
domain
(
d3
.
extent
(
data
.
map
(
d
=>
d
.
x
)))
...
...
@@ -105,7 +106,7 @@ export default class extends Chart {
const
barWidth
=
(()
=>
{
if
(
dataType
.
startsWith
(
'
cat
'
))
{
return
(
width
/
x
Values
.
length
)
*
(
1
-
BAR
_PADDING_FACTOR
);
return
width
/
uniX
Values
.
length
*
(
1
-
CATEGORY
_PADDING_FACTOR
)
/
groups
.
length
;
}
let
minDist
=
outerPadding
*
2
;
groups
.
forEach
((
group
)
=>
{
...
...
@@ -127,7 +128,7 @@ export default class extends Chart {
const
categoryWidth
=
width
/
uniXValues
.
length
;
const
catIdx
=
uniXValues
.
indexOf
(
d
.
x
);
const
groupIdx
=
groups
.
indexOf
(
d
.
group
);
return
catIdx
*
categoryWidth
+
groupIdx
*
barWidth
;
return
catIdx
*
categoryWidth
+
groupIdx
*
barWidth
+
barWidth
*
0.75
;
}
const
y
=
d3
.
scaleLinear
()
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment