Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charts
c3-closed
Commits
ed80b78a
Commit
ed80b78a
authored
May 09, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix padding - #129 #219
parent
7b653344
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
35 deletions
+37
-35
c3.js
c3.js
+37
-35
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
ed80b78a
...
@@ -109,10 +109,10 @@
...
@@ -109,10 +109,10 @@
var
__size_width
=
getConfig
([
'size'
,
'width'
]),
var
__size_width
=
getConfig
([
'size'
,
'width'
]),
__size_height
=
getConfig
([
'size'
,
'height'
]);
__size_height
=
getConfig
([
'size'
,
'height'
]);
var
__padding_left
=
getConfig
([
'padding'
,
'left'
]
,
50
),
var
__padding_left
=
getConfig
([
'padding'
,
'left'
]),
__padding_right
=
getConfig
([
'padding'
,
'right'
]
,
10
),
__padding_right
=
getConfig
([
'padding'
,
'right'
]),
__padding_top
=
getConfig
([
'padding'
,
'top'
]
,
0
),
__padding_top
=
getConfig
([
'padding'
,
'top'
]),
__padding_bottom
=
getConfig
([
'padding'
,
'bottom'
]
,
0
);
__padding_bottom
=
getConfig
([
'padding'
,
'bottom'
]);
var
__zoom_enabled
=
getConfig
([
'zoom'
,
'enabled'
],
false
),
var
__zoom_enabled
=
getConfig
([
'zoom'
,
'enabled'
],
false
),
__zoom_extent
=
getConfig
([
'zoom'
,
'extent'
]),
__zoom_extent
=
getConfig
([
'zoom'
,
'extent'
]),
...
@@ -421,9 +421,9 @@
...
@@ -421,9 +421,9 @@
// for main, context
// for main, context
if
(
__axis_rotated
)
{
if
(
__axis_rotated
)
{
margin
=
{
margin
=
{
top
:
getHorizontalAxisHeight
(
'y2'
)
+
__padding_top
,
top
:
getHorizontalAxisHeight
(
'y2'
)
+
getCurrentPaddingTop
()
,
right
:
hasArc
?
0
:
getCurrentPaddingRight
(),
right
:
hasArc
?
0
:
getCurrentPaddingRight
(),
bottom
:
getHorizontalAxisHeight
(
'y'
)
+
legendHeightForBottom
+
__padding_bottom
,
bottom
:
getHorizontalAxisHeight
(
'y'
)
+
legendHeightForBottom
+
getCurrentPaddingBottom
()
,
left
:
subchartHeight
+
(
hasArc
?
0
:
getCurrentPaddingLeft
())
left
:
subchartHeight
+
(
hasArc
?
0
:
getCurrentPaddingLeft
())
};
};
margin2
=
{
margin2
=
{
...
@@ -434,9 +434,9 @@
...
@@ -434,9 +434,9 @@
};
};
}
else
{
}
else
{
margin
=
{
margin
=
{
top
:
4
+
__padding_top
,
// for top tick text
top
:
4
+
getCurrentPaddingTop
()
,
// for top tick text
right
:
hasArc
?
0
:
getCurrentPaddingRight
(),
right
:
hasArc
?
0
:
getCurrentPaddingRight
(),
bottom
:
xAxisHeight
+
subchartHeight
+
legendHeightForBottom
+
__padding_bottom
,
bottom
:
xAxisHeight
+
subchartHeight
+
legendHeightForBottom
+
getCurrentPaddingBottom
()
,
left
:
hasArc
?
0
:
getCurrentPaddingLeft
()
left
:
hasArc
?
0
:
getCurrentPaddingLeft
()
};
};
margin2
=
{
margin2
=
{
...
@@ -501,26 +501,29 @@
...
@@ -501,26 +501,29 @@
var
h
=
__size_height
?
__size_height
:
getParentHeight
();
var
h
=
__size_height
?
__size_height
:
getParentHeight
();
return
h
>
0
?
h
:
320
;
return
h
>
0
?
h
:
320
;
}
}
function
getCurrentPaddingTop
()
{
return
__padding_top
?
__padding_top
:
0
;
}
function
getCurrentPaddingBottom
()
{
return
__padding_bottom
?
__padding_bottom
:
0
;
}
function
getCurrentPaddingLeft
()
{
function
getCurrentPaddingLeft
()
{
var
defaultPadding
=
1
;
if
(
__padding_left
)
{
if
(
__padding_left
)
{
return
__padding_left
;
return
__padding_left
;
}
else
if
(
__axis_rotated
)
{
}
else
if
(
__axis_rotated
)
{
return
!
__axis_x_show
?
defaultPadding
:
getAxisWidthByAxisId
(
'x'
);
return
!
__axis_x_show
?
1
:
ceil10
(
getAxisWidthByAxisId
(
'x'
)
);
}
else
{
}
else
{
return
!
__axis_y_show
||
__axis_y_inner
?
defaultPadding
:
getAxisWidthByAxisId
(
'y'
);
return
!
__axis_y_show
||
__axis_y_inner
?
1
:
ceil10
(
getAxisWidthByAxisId
(
'y'
)
);
}
}
}
}
function
getCurrentPaddingRight
()
{
function
getCurrentPaddingRight
()
{
var
defaultPadding
=
1
;
var
defaultPadding
=
1
0
,
legendWidthOnRight
=
isLegendRight
?
getLegendWidth
()
+
20
:
0
;
if
(
__padding_right
)
{
if
(
__padding_right
)
{
return
__padding_right
;
return
__padding_right
;
}
else
if
(
isLegendRight
)
{
}
else
if
(
__axis_rotated
)
{
return
getLegendWidth
()
+
20
+
(
__axis_y2_show
&&
!
__axis_rotated
?
getAxisWidthByAxisId
(
'y2'
)
:
defaultPadding
);
return
defaultPadding
+
legendWidthOnRight
;
}
else
if
(
__axis_y2_show
)
{
return
__axis_y2_inner
||
__axis_rotated
?
defaultPadding
:
getAxisWidthByAxisId
(
'y2'
);
}
else
{
}
else
{
return
defaultPadding
;
return
(
!
__axis_y2_show
||
__axis_y2_inner
?
defaultPadding
:
ceil10
(
getAxisWidthByAxisId
(
'y2'
)))
+
legendWidthOnRight
;
}
}
}
}
function
getAxisWidthByAxisId
(
id
)
{
function
getAxisWidthByAxisId
(
id
)
{
...
@@ -2108,6 +2111,10 @@
...
@@ -2108,6 +2111,10 @@
return
isDefined
(
options
[
key
])
?
options
[
key
]
:
defaultValue
;
return
isDefined
(
options
[
key
])
?
options
[
key
]
:
defaultValue
;
}
}
function
ceil10
(
v
)
{
return
Math
.
ceil
(
v
/
10
)
*
10
;
}
//-- Selection --//
//-- Selection --//
function
selectPoint
(
target
,
d
,
i
)
{
function
selectPoint
(
target
,
d
,
i
)
{
...
@@ -2663,22 +2670,8 @@
...
@@ -2663,22 +2670,8 @@
// Set targets
// Set targets
updateTargets
(
c3
.
data
.
targets
);
updateTargets
(
c3
.
data
.
targets
);
// Update ticks for width calculation
if
(
__axis_rotated
)
{
main
.
select
(
'.'
+
CLASS
.
axisX
).
style
(
"opacity"
,
0
).
call
(
xAxis
);
}
else
{
main
.
select
(
'.'
+
CLASS
.
axisY
).
style
(
"opacity"
,
0
).
call
(
yAxis
);
main
.
select
(
'.'
+
CLASS
.
axisY2
).
style
(
"opacity"
,
0
).
call
(
y2Axis
);
}
// Update sizes according to tick width updated by above
updateSizes
();
updateScales
();
updateSvgSize
();
transformAll
(
false
);
// Draw with targets
// Draw with targets
redraw
({
withTransform
:
true
,
withUpdateXDomain
:
true
,
withUpdateOrgXDomain
:
true
,
withTransitionForAxis
:
false
});
redraw
({
with
UpdateTranslate
:
true
,
with
Transform
:
true
,
withUpdateXDomain
:
true
,
withUpdateOrgXDomain
:
true
,
withTransitionForAxis
:
false
});
// Show tooltip if needed
// Show tooltip if needed
if
(
__tooltip_init_show
)
{
if
(
__tooltip_init_show
)
{
...
@@ -3033,7 +3026,7 @@
...
@@ -3033,7 +3026,7 @@
var
mainLine
,
mainArea
,
mainCircle
,
mainBar
,
mainArc
,
mainRegion
,
mainText
,
contextLine
,
contextBar
,
eventRect
,
eventRectUpdate
;
var
mainLine
,
mainArea
,
mainCircle
,
mainBar
,
mainArc
,
mainRegion
,
mainText
,
contextLine
,
contextBar
,
eventRect
,
eventRectUpdate
;
var
barIndices
=
getBarIndices
(),
maxDataCountTarget
,
tickOffset
;
var
barIndices
=
getBarIndices
(),
maxDataCountTarget
,
tickOffset
;
var
rectX
,
rectW
;
var
rectX
,
rectW
;
var
withY
,
withSubchart
,
withTransition
,
withTransitionForExit
,
withTransitionForAxis
,
withTransform
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withLegend
;
var
withY
,
withSubchart
,
withTransition
,
withTransitionForExit
,
withTransitionForAxis
,
withTransform
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withLegend
,
withUpdateTranslate
;
var
hideAxis
=
hasArcType
(
c3
.
data
.
targets
);
var
hideAxis
=
hasArcType
(
c3
.
data
.
targets
);
var
drawBar
,
drawBarOnSub
,
xForText
,
yForText
;
var
drawBar
,
drawBarOnSub
,
xForText
,
yForText
;
var
duration
,
durationForExit
,
durationForAxis
;
var
duration
,
durationForExit
,
durationForAxis
;
...
@@ -3046,6 +3039,7 @@
...
@@ -3046,6 +3039,7 @@
withTransform
=
getOption
(
options
,
"withTransform"
,
false
);
withTransform
=
getOption
(
options
,
"withTransform"
,
false
);
withUpdateXDomain
=
getOption
(
options
,
"withUpdateXDomain"
,
false
);
withUpdateXDomain
=
getOption
(
options
,
"withUpdateXDomain"
,
false
);
withUpdateOrgXDomain
=
getOption
(
options
,
"withUpdateOrgXDomain"
,
false
);
withUpdateOrgXDomain
=
getOption
(
options
,
"withUpdateOrgXDomain"
,
false
);
withUpdateTranslate
=
getOption
(
options
,
"withUpdateTranslate"
,
false
);
withLegend
=
getOption
(
options
,
"withLegend"
,
false
);
withLegend
=
getOption
(
options
,
"withLegend"
,
false
);
withTransitionForExit
=
getOption
(
options
,
"withTransitionForExit"
,
withTransition
);
withTransitionForExit
=
getOption
(
options
,
"withTransitionForExit"
,
withTransition
);
withTransitionForAxis
=
getOption
(
options
,
"withTransitionForAxis"
,
withTransition
);
withTransitionForAxis
=
getOption
(
options
,
"withTransitionForAxis"
,
withTransition
);
...
@@ -3103,6 +3097,14 @@
...
@@ -3103,6 +3097,14 @@
// Update axis label
// Update axis label
updateAxisLabels
(
withTransition
);
updateAxisLabels
(
withTransition
);
// MEMO: need to be called after axis updated because updated tick's width will be used
if
(
withUpdateTranslate
)
{
updateSizes
();
updateScales
();
updateSvgSize
();
transformAll
(
false
);
}
// show/hide if manual culling needed
// show/hide if manual culling needed
if
(
withUpdateXDomain
&&
targetsToShow
.
length
)
{
if
(
withUpdateXDomain
&&
targetsToShow
.
length
)
{
if
(
__axis_x_tick_culling
&&
tickValues
)
{
if
(
__axis_x_tick_culling
&&
tickValues
)
{
...
@@ -4536,12 +4538,12 @@
...
@@ -4536,12 +4538,12 @@
function
axisX
(
selection
,
x
)
{
function
axisX
(
selection
,
x
)
{
selection
.
attr
(
"transform"
,
function
(
d
)
{
selection
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
Math
.
ceil
(
x
(
d
)
+
tickOffset
)
+
", 0)"
;
return
"translate("
+
Math
.
round
(
x
(
d
)
+
tickOffset
)
+
", 0)"
;
});
});
}
}
function
axisY
(
selection
,
y
)
{
function
axisY
(
selection
,
y
)
{
selection
.
attr
(
"transform"
,
function
(
d
)
{
selection
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate(0,"
+
Math
.
ceil
(
y
(
d
))
+
")"
;
return
"translate(0,"
+
Math
.
round
(
y
(
d
))
+
")"
;
});
});
}
}
function
scaleExtent
(
domain
)
{
function
scaleExtent
(
domain
)
{
...
...
c3.min.js
View file @
ed80b78a
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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