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
bc815a87
Commit
bc815a87
authored
Oct 14, 2015
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move exploded pie implementation
parent
328f718a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
68 deletions
+63
-68
arc.js
src/arc.js
+59
-68
config.js
src/config.js
+1
-0
util.js
src/util.js
+3
-0
No files found.
src/arc.js
View file @
bc815a87
...
...
@@ -11,8 +11,10 @@ c3_chart_internal_fn.initPie = function () {
c3_chart_internal_fn
.
updateRadius
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
w
=
config
.
gauge_width
||
config
.
donut_width
;
$$
.
radiusExpanded
=
Math
.
min
(
$$
.
arcWidth
,
$$
.
arcHeight
)
/
2
;
$$
.
radius
=
$$
.
radiusExpanded
*
0.95
;
$$
.
radius
-=
config
.
explodeRadius
;
$$
.
innerRadiusRatio
=
w
?
(
$$
.
radius
-
w
)
/
$$
.
radius
:
0.6
;
$$
.
innerRadius
=
$$
.
hasType
(
'donut'
)
||
$$
.
hasType
(
'gauge'
)
?
$$
.
radius
*
$$
.
innerRadiusRatio
:
0
;
};
...
...
@@ -260,47 +262,8 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
this
.
_current
=
d
;
});
mainArc
.
attr
(
"transform"
,
function
(
d
)
{
return
!
$$
.
isGaugeType
(
d
.
data
)
&&
withTransform
?
"scale(0)"
:
""
;
}
)
.
attr
(
"transform"
,
withTransform
?
"scale(0)"
:
$$
.
wrapExplode
()
)
.
style
(
"opacity"
,
function
(
d
)
{
return
d
===
this
.
_current
?
0
:
1
;
})
.
on
(
'mouseover'
,
config
.
interaction_enabled
?
function
(
d
)
{
var
updated
,
arcData
;
if
(
$$
.
transiting
)
{
// skip while transiting
return
;
}
updated
=
$$
.
updateAngle
(
d
);
arcData
=
$$
.
convertToArcData
(
updated
);
// transitions
$$
.
expandArc
(
updated
.
data
.
id
);
$$
.
api
.
focus
(
updated
.
data
.
id
);
$$
.
toggleFocusLegend
(
updated
.
data
.
id
,
true
);
$$
.
config
.
data_onmouseover
(
arcData
,
this
);
}
:
null
)
.
on
(
'mousemove'
,
config
.
interaction_enabled
?
function
(
d
)
{
var
updated
=
$$
.
updateAngle
(
d
),
arcData
=
$$
.
convertToArcData
(
updated
),
selectedData
=
[
arcData
];
$$
.
showTooltip
(
selectedData
,
this
);
}
:
null
)
.
on
(
'mouseout'
,
config
.
interaction_enabled
?
function
(
d
)
{
var
updated
,
arcData
;
if
(
$$
.
transiting
)
{
// skip while transiting
return
;
}
updated
=
$$
.
updateAngle
(
d
);
arcData
=
$$
.
convertToArcData
(
updated
);
// transitions
$$
.
unexpandArc
(
updated
.
data
.
id
);
$$
.
api
.
revert
();
$$
.
revertLegend
();
$$
.
hideTooltip
();
$$
.
config
.
data_onmouseout
(
arcData
,
this
);
}
:
null
)
.
on
(
'click'
,
config
.
interaction_enabled
?
function
(
d
,
i
)
{
var
updated
=
$$
.
updateAngle
(
d
),
arcData
=
$$
.
convertToArcData
(
updated
);
if
(
$$
.
toggleShape
)
{
$$
.
toggleShape
(
this
,
arcData
,
i
);
}
$$
.
config
.
data_onclick
.
call
(
$$
.
api
,
arcData
,
this
);
}
:
null
)
.
each
(
function
()
{
$$
.
transiting
=
true
;
})
.
transition
().
duration
(
duration
)
.
attrTween
(
"d"
,
function
(
d
)
{
...
...
@@ -308,12 +271,6 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
if
(
!
updated
)
{
return
function
()
{
return
"M 0 0"
;
};
}
// if (this._current === d) {
// this._current = {
// startAngle: Math.PI*2,
// endAngle: Math.PI*2,
// };
// }
if
(
isNaN
(
this
.
_current
.
endAngle
))
{
this
.
_current
.
endAngle
=
this
.
_current
.
startAngle
;
}
...
...
@@ -325,7 +282,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
return
$$
.
getArc
(
interpolated
,
true
);
};
})
.
attr
(
"transform"
,
withTransform
?
"scale(1)"
:
""
)
.
attr
(
"transform"
,
withTransform
?
"scale(1)"
:
$$
.
wrapExplode
()
)
.
style
(
"fill"
,
function
(
d
)
{
return
$$
.
levelColor
?
$$
.
levelColor
(
d
.
data
.
values
[
0
].
value
)
:
$$
.
color
(
d
.
data
.
id
);
})
// Where gauge reading color would receive customization.
...
...
@@ -347,29 +304,63 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
main
.
select
(
'.'
+
CLASS
.
chartArcsTitle
)
.
style
(
"opacity"
,
$$
.
hasType
(
'donut'
)
||
$$
.
hasType
(
'gauge'
)
?
1
:
0
);
if
(
$$
.
hasType
(
'gauge'
))
{
$$
.
arcs
.
select
(
'.'
+
CLASS
.
chartArcsBackground
)
.
attr
(
"d"
,
function
()
{
var
d
=
{
data
:
[{
value
:
config
.
gauge_max
}],
startAngle
:
-
1
*
(
Math
.
PI
/
2
),
endAngle
:
Math
.
PI
/
2
};
return
$$
.
getArc
(
d
,
true
,
true
);
});
$$
.
arcs
.
select
(
'.'
+
CLASS
.
chartArcsGaugeUnit
)
.
attr
(
"dy"
,
".75em"
)
.
text
(
config
.
gauge_label_show
?
config
.
gauge_units
:
''
);
$$
.
arcs
.
select
(
'.'
+
CLASS
.
chartArcsGaugeMin
)
.
attr
(
"dx"
,
-
1
*
(
$$
.
innerRadius
+
((
$$
.
radius
-
$$
.
innerRadius
)
/
2
))
+
"px"
)
.
attr
(
"dy"
,
"1.2em"
)
.
text
(
config
.
gauge_label_show
?
config
.
gauge_min
:
''
);
$$
.
arcs
.
select
(
'.'
+
CLASS
.
chartArcsGaugeMax
)
.
attr
(
"dx"
,
$$
.
innerRadius
+
((
$$
.
radius
-
$$
.
innerRadius
)
/
2
)
+
"px"
)
.
attr
(
"dy"
,
"1.2em"
)
.
text
(
config
.
gauge_label_show
?
config
.
gauge_max
:
''
);
if
(
$$
.
config
.
hasSubs
||
$$
.
config
.
isSub
){
$$
.
buffer
.
onlastfinish
(
"draw-lines"
,
function
(){
$$
.
ed3Internal
.
redrawLinesOnBoth
();
$$
.
ed3Internal
.
redrawLinesOnBoth
();
});
}
};
c3_chart_internal_fn
.
getAngle
=
function
(
d
){
var
$$
=
this
;
$$
.
config
.
newd
=
d
;
};
c3_chart_internal_fn
.
wrapExplode
=
function
(){
var
$$
=
this
;
explode
.
offset
=
$$
.
config
.
explodeRadius
;
explode
.
updateAngle
=
$$
.
updateAngle
.
bind
(
$$
);
explode
.
turn
=
$$
.
api
.
turn
.
bind
(
$$
.
api
);
explode
.
config
=
$$
.
config
;
explode
.
getAngle
=
$$
.
getAngle
.
bind
(
$$
);
return
explode
;
};
function
explode
(
d
,
index
)
{
d
=
explode
.
updateAngle
(
d
);
if
(
isNull
(
d
)){
return
""
;
}
var
offset
=
explode
.
offset
;
var
angle
=
(
d
.
startAngle
+
d
.
endAngle
)
/
2
;
var
xOff
=
Math
.
sin
(
angle
)
*
offset
;
var
yOff
=
-
Math
.
cos
(
angle
)
*
offset
;
if
(
index
===
0
&&
explode
.
config
.
hasSubs
){
if
(
!
explode
.
config
.
turned
){
explode
.
getAngle
(
d
);
var
turnAngle
=
((
d
.
startAngle
-
d
.
endAngle
)
/
2
%
(
2
*
Math
.
PI
))
+
toRadians
(
90
);
explode
.
turn
({
radians
:
turnAngle
});
explode
.
config
.
turned
=
true
;
}
}
if
(
!
offset
){
return
"translate(0, 0)"
;
}
return
'translate('
+
xOff
+
','
+
yOff
+
')'
;
}
c3_chart_internal_fn
.
initGauge
=
function
()
{
var
arcs
=
this
.
arcs
;
if
(
this
.
hasType
(
'gauge'
))
{
...
...
src/config.js
View file @
bc815a87
...
...
@@ -162,6 +162,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
pie_label_format
:
undefined
,
pie_label_threshold
:
0.05
,
pie_expand
:
true
,
explodeRadius
:
0
,
// gauge
gauge_label_show
:
true
,
gauge_label_format
:
undefined
,
...
...
src/util.js
View file @
bc815a87
...
...
@@ -10,6 +10,9 @@ var isValue = c3_chart_internal_fn.isValue = function (v) {
isUndefined
=
c3_chart_internal_fn
.
isUndefined
=
function
(
v
)
{
return
typeof
v
===
'undefined'
;
},
isNull
=
c3_chart_internal_fn
.
isNull
=
function
(
v
){
return
v
===
null
;
},
isDefined
=
c3_chart_internal_fn
.
isDefined
=
function
(
v
)
{
return
typeof
v
!==
'undefined'
;
},
...
...
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