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
Evgeny
c3-closed
Commits
e2a31ff8
Commit
e2a31ff8
authored
Jul 31, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor hasType
parent
63edd6d0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
66 deletions
+44
-66
c3.js
c3.js
+44
-66
No files found.
c3.js
View file @
e2a31ff8
...
@@ -592,7 +592,7 @@
...
@@ -592,7 +592,7 @@
}
}
// when gauge, hide legend // TODO: fix
// when gauge, hide legend // TODO: fix
if
(
$$
.
has
GaugeType
(
$$
.
data
.
targets
))
{
if
(
$$
.
has
Type
(
'gauge'
))
{
config
[
__legend_show
]
=
false
;
config
[
__legend_show
]
=
false
;
}
}
...
@@ -786,7 +786,7 @@
...
@@ -786,7 +786,7 @@
}
}
$$
.
tooltip
.
html
(
config
[
__tooltip_contents
].
call
(
$$
,
$$
.
data
.
targets
.
map
(
function
(
d
)
{
$$
.
tooltip
.
html
(
config
[
__tooltip_contents
].
call
(
$$
,
$$
.
data
.
targets
.
map
(
function
(
d
)
{
return
$$
.
addName
(
d
.
values
[
config
[
__tooltip_init_x
]]);
return
$$
.
addName
(
d
.
values
[
config
[
__tooltip_init_x
]]);
}),
$$
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
$$
.
hasArcType
(
$$
.
data
.
targets
)),
$$
.
color
));
}),
$$
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
$$
.
hasArcType
()),
$$
.
color
));
$$
.
tooltip
.
style
(
"top"
,
config
[
__tooltip_init_position
].
top
)
$$
.
tooltip
.
style
(
"top"
,
config
[
__tooltip_init_position
].
top
)
.
style
(
"left"
,
config
[
__tooltip_init_position
].
left
)
.
style
(
"left"
,
config
[
__tooltip_init_position
].
left
)
.
style
(
"display"
,
"block"
);
.
style
(
"display"
,
"block"
);
...
@@ -837,7 +837,7 @@
...
@@ -837,7 +837,7 @@
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
legendHeight
=
$$
.
getLegendHeight
(),
legendWidth
=
$$
.
getLegendWidth
(),
var
legendHeight
=
$$
.
getLegendHeight
(),
legendWidth
=
$$
.
getLegendWidth
(),
legendHeightForBottom
=
$$
.
isLegendRight
||
$$
.
isLegendInset
?
0
:
legendHeight
,
legendHeightForBottom
=
$$
.
isLegendRight
||
$$
.
isLegendInset
?
0
:
legendHeight
,
hasArc
=
$$
.
hasArcType
(
$$
.
data
.
targets
),
hasArc
=
$$
.
hasArcType
(),
xAxisHeight
=
config
[
__axis_rotated
]
||
hasArc
?
0
:
$$
.
getHorizontalAxisHeight
(
'x'
),
xAxisHeight
=
config
[
__axis_rotated
]
||
hasArc
?
0
:
$$
.
getHorizontalAxisHeight
(
'x'
),
subchartHeight
=
config
[
__subchart_show
]
&&
!
hasArc
?
(
config
[
__subchart_size_height
]
+
xAxisHeight
)
:
0
;
subchartHeight
=
config
[
__subchart_show
]
&&
!
hasArc
?
(
config
[
__subchart_size_height
]
+
xAxisHeight
)
:
0
;
...
@@ -987,7 +987,7 @@
...
@@ -987,7 +987,7 @@
var
areaIndices
=
$$
.
getShapeIndices
(
$$
.
isAreaType
),
barIndices
=
$$
.
getShapeIndices
(
$$
.
isBarType
),
lineIndices
=
$$
.
getShapeIndices
(
$$
.
isLineType
),
maxDataCountTarget
,
tickOffset
;
var
areaIndices
=
$$
.
getShapeIndices
(
$$
.
isAreaType
),
barIndices
=
$$
.
getShapeIndices
(
$$
.
isBarType
),
lineIndices
=
$$
.
getShapeIndices
(
$$
.
isLineType
),
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
;
var
hideAxis
=
$$
.
hasArcType
(
$$
.
data
.
targets
);
var
hideAxis
=
$$
.
hasArcType
();
var
drawArea
,
drawBar
,
drawLine
,
xForText
,
yForText
;
var
drawArea
,
drawBar
,
drawLine
,
xForText
,
yForText
;
var
duration
,
durationForExit
,
durationForAxis
,
waitForDraw
;
var
duration
,
durationForExit
,
durationForAxis
,
waitForDraw
;
var
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
),
tickValues
,
i
,
intervalForCulling
;
var
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
),
tickValues
,
i
,
intervalForCulling
;
...
@@ -1602,7 +1602,7 @@
...
@@ -1602,7 +1602,7 @@
var
index
=
d
.
index
,
selectedData
,
newData
;
var
index
=
d
.
index
,
selectedData
,
newData
;
if
(
$$
.
dragging
)
{
return
;
}
// do nothing if dragging
if
(
$$
.
dragging
)
{
return
;
}
// do nothing if dragging
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
selectedData
=
$$
.
data
.
targets
.
map
(
function
(
t
)
{
selectedData
=
$$
.
data
.
targets
.
map
(
function
(
t
)
{
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
...
@@ -1632,7 +1632,7 @@
...
@@ -1632,7 +1632,7 @@
})
})
.
on
(
'mouseout'
,
function
(
d
)
{
.
on
(
'mouseout'
,
function
(
d
)
{
var
index
=
d
.
index
;
var
index
=
d
.
index
;
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
$$
.
hideXGridFocus
();
$$
.
hideXGridFocus
();
$$
.
hideTooltip
();
$$
.
hideTooltip
();
// Undo expanded shapes
// Undo expanded shapes
...
@@ -1648,7 +1648,7 @@
...
@@ -1648,7 +1648,7 @@
eventRect
=
$$
.
svg
.
select
(
'.'
+
CLASS
[
eventRect
]
+
'-'
+
index
);
eventRect
=
$$
.
svg
.
select
(
'.'
+
CLASS
[
eventRect
]
+
'-'
+
index
);
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
// Show tooltip
// Show tooltip
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
...
@@ -1701,7 +1701,7 @@
...
@@ -1701,7 +1701,7 @@
})
})
.
on
(
'click'
,
function
(
d
)
{
.
on
(
'click'
,
function
(
d
)
{
var
index
=
d
.
index
;
var
index
=
d
.
index
;
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
$$
.
cancelClick
)
{
if
(
$$
.
cancelClick
)
{
$$
.
cancelClick
=
false
;
$$
.
cancelClick
=
false
;
return
;
return
;
...
@@ -1726,7 +1726,7 @@
...
@@ -1726,7 +1726,7 @@
.
attr
(
'height'
,
$$
.
height
)
.
attr
(
'height'
,
$$
.
height
)
.
attr
(
'class'
,
CLASS
[
eventRect
])
.
attr
(
'class'
,
CLASS
[
eventRect
])
.
on
(
'mouseout'
,
function
()
{
.
on
(
'mouseout'
,
function
()
{
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
$$
.
hideXGridFocus
();
$$
.
hideXGridFocus
();
$$
.
hideTooltip
();
$$
.
hideTooltip
();
$$
.
unexpandCircles
();
$$
.
unexpandCircles
();
...
@@ -2026,7 +2026,7 @@
...
@@ -2026,7 +2026,7 @@
leftAxis
=
$$
.
main
.
select
(
'.'
+
leftAxisClass
).
node
(),
leftAxis
=
$$
.
main
.
select
(
'.'
+
leftAxisClass
).
node
(),
svgRect
=
leftAxis
?
leftAxis
.
getBoundingClientRect
()
:
{
right
:
0
},
svgRect
=
leftAxis
?
leftAxis
.
getBoundingClientRect
()
:
{
right
:
0
},
chartRect
=
$$
.
selectChart
.
node
().
getBoundingClientRect
(),
chartRect
=
$$
.
selectChart
.
node
().
getBoundingClientRect
(),
hasArc
=
$$
.
hasArcType
(
$$
.
data
.
targets
),
hasArc
=
$$
.
hasArcType
(),
svgLeft
=
svgRect
.
right
-
chartRect
.
left
-
(
hasArc
?
0
:
$$
.
getCurrentPaddingLeft
());
svgLeft
=
svgRect
.
right
-
chartRect
.
left
-
(
hasArc
?
0
:
$$
.
getCurrentPaddingLeft
());
return
svgLeft
>
0
?
svgLeft
:
0
;
return
svgLeft
>
0
?
svgLeft
:
0
;
};
};
...
@@ -2058,7 +2058,7 @@
...
@@ -2058,7 +2058,7 @@
return
$$
.
config
[
__axis_rotated
]
?
$$
.
height
:
$$
.
width
;
return
$$
.
config
[
__axis_rotated
]
?
$$
.
height
:
$$
.
width
;
}
}
maxDataCount
=
$$
.
getMaxDataCount
();
maxDataCount
=
$$
.
getMaxDataCount
();
ratio
=
(
$$
.
has
BarType
(
$$
.
data
.
targets
)
?
(
maxDataCount
-
(
$$
.
isCategorized
?
0.25
:
1
))
/
maxDataCount
:
1
);
ratio
=
(
$$
.
has
Type
(
'bar'
)
?
(
maxDataCount
-
(
$$
.
isCategorized
?
0.25
:
1
))
/
maxDataCount
:
1
);
w
=
maxDataCount
>
1
?
(
base
*
ratio
)
/
(
maxDataCount
-
1
)
:
base
;
w
=
maxDataCount
>
1
?
(
base
*
ratio
)
/
(
maxDataCount
-
1
)
:
base
;
return
w
<
1
?
1
:
w
;
return
w
<
1
?
1
:
w
;
};
};
...
@@ -2070,7 +2070,7 @@
...
@@ -2070,7 +2070,7 @@
c3_chart_internal_fn
.
showTooltip
=
function
(
selectedData
,
mouse
)
{
c3_chart_internal_fn
.
showTooltip
=
function
(
selectedData
,
mouse
)
{
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
tWidth
,
tHeight
,
svgLeft
,
tooltipLeft
,
tooltipRight
,
tooltipTop
,
chartRight
;
var
tWidth
,
tHeight
,
svgLeft
,
tooltipLeft
,
tooltipRight
,
tooltipTop
,
chartRight
;
var
forArc
=
$$
.
hasArcType
(
$$
.
data
.
targets
),
var
forArc
=
$$
.
hasArcType
(),
dataToShow
=
selectedData
.
filter
(
function
(
d
)
{
return
d
&&
isValue
(
d
.
value
);
});
dataToShow
=
selectedData
.
filter
(
function
(
d
)
{
return
d
&&
isValue
(
d
.
value
);
});
if
(
dataToShow
.
length
===
0
||
!
config
[
__tooltip_show
])
{
if
(
dataToShow
.
length
===
0
||
!
config
[
__tooltip_show
])
{
return
;
return
;
...
@@ -2123,7 +2123,7 @@
...
@@ -2123,7 +2123,7 @@
var
$$
=
this
,
dataToShow
=
selectedData
.
filter
(
function
(
d
)
{
return
d
&&
isValue
(
d
.
value
);
});
var
$$
=
this
,
dataToShow
=
selectedData
.
filter
(
function
(
d
)
{
return
d
&&
isValue
(
d
.
value
);
});
if
(
!
config
[
__tooltip_show
])
{
return
;
}
if
(
!
config
[
__tooltip_show
])
{
return
;
}
// Hide when scatter plot exists
// Hide when scatter plot exists
if
(
$$
.
has
ScatterType
(
$$
.
data
.
targets
)
||
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
has
Type
(
'scatter'
)
||
$$
.
hasArcType
(
))
{
return
;
}
var
focusEl
=
$$
.
main
.
selectAll
(
'line.'
+
CLASS
[
xgridFocus
]);
var
focusEl
=
$$
.
main
.
selectAll
(
'line.'
+
CLASS
[
xgridFocus
]);
focusEl
focusEl
.
style
(
"visibility"
,
"visible"
)
.
style
(
"visibility"
,
"visible"
)
...
@@ -3539,39 +3539,17 @@
...
@@ -3539,39 +3539,17 @@
config
[
__data_type
]
=
type
;
config
[
__data_type
]
=
type
;
}
}
};
};
c3_chart_internal_fn
.
hasType
=
function
(
targets
,
type
)
{
c3_chart_internal_fn
.
hasType
=
function
(
type
,
targets
)
{
var
$$
=
this
,
config
=
$$
.
config
,
has
=
false
;
var
$$
=
this
,
types
=
$$
.
config
[
__data_types
],
has
=
false
;
targets
.
forEach
(
function
(
t
)
{
(
targets
||
$$
.
data
.
targets
).
forEach
(
function
(
t
)
{
if
(
config
[
__data_types
][
t
.
id
]
===
type
)
{
has
=
true
;
}
if
((
types
[
t
.
id
]
&&
types
[
t
.
id
].
indexOf
(
type
)
>=
0
)
||
(
!
(
t
.
id
in
types
)
&&
type
===
'line'
))
{
if
(
!
(
t
.
id
in
config
[
__data_types
])
&&
type
===
'line'
)
{
has
=
true
;
}
has
=
true
;
}
});
});
return
has
;
return
has
;
};
};
/* not used
function hasLineType(targets) {
return hasType(targets, 'line');
}
*/
c3_chart_internal_fn
.
hasAreaType
=
function
(
targets
)
{
return
this
.
hasType
(
targets
,
'area'
)
||
this
.
hasType
(
targets
,
'area-spline'
)
||
this
.
hasType
(
targets
,
'area-step'
);
};
c3_chart_internal_fn
.
hasBarType
=
function
(
targets
)
{
return
this
.
hasType
(
targets
,
'bar'
);
};
c3_chart_internal_fn
.
hasScatterType
=
function
(
targets
)
{
return
this
.
hasType
(
targets
,
'scatter'
);
};
c3_chart_internal_fn
.
hasPieType
=
function
(
targets
)
{
return
this
.
config
[
__data_type
]
===
'pie'
||
this
.
hasType
(
targets
,
'pie'
);
};
c3_chart_internal_fn
.
hasGaugeType
=
function
(
targets
)
{
return
this
.
hasType
(
targets
,
'gauge'
);
};
c3_chart_internal_fn
.
hasDonutType
=
function
(
targets
)
{
return
this
.
config
[
__data_type
]
===
'donut'
||
this
.
hasType
(
targets
,
'donut'
);
};
c3_chart_internal_fn
.
hasArcType
=
function
(
targets
)
{
c3_chart_internal_fn
.
hasArcType
=
function
(
targets
)
{
return
this
.
has
PieType
(
targets
)
||
this
.
hasDonutType
(
targets
)
||
this
.
hasGaugeType
(
targets
);
return
this
.
has
Type
(
'pie'
,
targets
)
||
this
.
hasType
(
'donut'
,
targets
)
||
this
.
hasType
(
'gauge'
,
targets
);
};
};
c3_chart_internal_fn
.
isLineType
=
function
(
d
)
{
c3_chart_internal_fn
.
isLineType
=
function
(
d
)
{
var
config
=
this
.
config
,
id
=
isString
(
d
)
?
d
:
d
.
id
;
var
config
=
this
.
config
,
id
=
isString
(
d
)
?
d
:
d
.
id
;
...
@@ -3865,7 +3843,7 @@
...
@@ -3865,7 +3843,7 @@
domainLength
,
padding
,
padding_top
,
padding_bottom
,
domainLength
,
padding
,
padding_top
,
padding_bottom
,
center
=
axisId
===
'y2'
?
config
[
__axis_y2_center
]
:
config
[
__axis_y_center
],
center
=
axisId
===
'y2'
?
config
[
__axis_y2_center
]
:
config
[
__axis_y_center
],
yDomainAbs
,
lengths
,
diff
,
ratio
,
isAllPositive
,
isAllNegative
,
yDomainAbs
,
lengths
,
diff
,
ratio
,
isAllPositive
,
isAllNegative
,
isZeroBased
=
(
$$
.
has
BarType
(
yTargets
)
&&
config
[
__bar_zerobased
])
||
(
$$
.
hasAreaType
(
yTargets
)
&&
config
[
__area_zerobased
]),
isZeroBased
=
(
$$
.
has
Type
(
'bar'
,
yTargets
)
&&
config
[
__bar_zerobased
])
||
(
$$
.
hasType
(
'area'
,
yTargets
)
&&
config
[
__area_zerobased
]),
showHorizontalDataLabel
=
$$
.
hasDataLabel
()
&&
config
[
__axis_rotated
],
showHorizontalDataLabel
=
$$
.
hasDataLabel
()
&&
config
[
__axis_rotated
],
showVerticalDataLabel
=
$$
.
hasDataLabel
()
&&
!
config
[
__axis_rotated
];
showVerticalDataLabel
=
$$
.
hasDataLabel
()
&&
!
config
[
__axis_rotated
];
if
(
yTargets
.
length
===
0
)
{
// use current domain if target of axisId is none
if
(
yTargets
.
length
===
0
)
{
// use current domain if target of axisId is none
...
@@ -3936,7 +3914,7 @@
...
@@ -3936,7 +3914,7 @@
maxDataCount
,
padding
,
paddingLeft
,
paddingRight
;
maxDataCount
,
padding
,
paddingLeft
,
paddingRight
;
if
(
$$
.
isCategorized
)
{
if
(
$$
.
isCategorized
)
{
padding
=
0
;
padding
=
0
;
}
else
if
(
$$
.
has
BarType
(
targets
))
{
}
else
if
(
$$
.
has
Type
(
'bar'
,
targets
))
{
maxDataCount
=
$$
.
getMaxDataCount
();
maxDataCount
=
$$
.
getMaxDataCount
();
padding
=
maxDataCount
>
1
?
(
diff
/
(
maxDataCount
-
1
))
/
2
:
0.5
;
padding
=
maxDataCount
>
1
?
(
diff
/
(
maxDataCount
-
1
))
/
2
:
0.5
;
}
else
{
}
else
{
...
@@ -4343,7 +4321,7 @@
...
@@ -4343,7 +4321,7 @@
$$
.
radiusExpanded
=
Math
.
min
(
$$
.
arcWidth
,
$$
.
arcHeight
)
/
2
;
$$
.
radiusExpanded
=
Math
.
min
(
$$
.
arcWidth
,
$$
.
arcHeight
)
/
2
;
$$
.
radius
=
$$
.
radiusExpanded
*
0.95
;
$$
.
radius
=
$$
.
radiusExpanded
*
0.95
;
$$
.
innerRadiusRatio
=
w
?
(
$$
.
radius
-
w
)
/
$$
.
radius
:
0.6
;
$$
.
innerRadiusRatio
=
w
?
(
$$
.
radius
-
w
)
/
$$
.
radius
:
0.6
;
$$
.
innerRadius
=
$$
.
has
DonutType
(
$$
.
data
.
targets
)
||
$$
.
hasGaugeType
(
$$
.
data
.
targets
)
?
$$
.
radius
*
$$
.
innerRadiusRatio
:
0
;
$$
.
innerRadius
=
$$
.
has
Type
(
'donut'
)
||
$$
.
hasType
(
'gauge'
)
?
$$
.
radius
*
$$
.
innerRadiusRatio
:
0
;
};
};
c3_chart_internal_fn
.
updateArc
=
function
()
{
c3_chart_internal_fn
.
updateArc
=
function
()
{
...
@@ -4408,7 +4386,7 @@
...
@@ -4408,7 +4386,7 @@
c3_chart_internal_fn
.
transformForArcLabel
=
function
(
d
)
{
c3_chart_internal_fn
.
transformForArcLabel
=
function
(
d
)
{
var
$$
=
this
,
var
$$
=
this
,
updated
=
$$
.
updateAngle
(
d
),
c
,
x
,
y
,
h
,
ratio
,
translate
=
""
;
updated
=
$$
.
updateAngle
(
d
),
c
,
x
,
y
,
h
,
ratio
,
translate
=
""
;
if
(
updated
&&
!
$$
.
has
GaugeType
(
$$
.
data
.
targets
))
{
if
(
updated
&&
!
$$
.
has
Type
(
'gauge'
))
{
c
=
this
.
svgArc
.
centroid
(
updated
);
c
=
this
.
svgArc
.
centroid
(
updated
);
x
=
isNaN
(
c
[
0
])
?
0
:
c
[
0
];
x
=
isNaN
(
c
[
0
])
?
0
:
c
[
0
];
y
=
isNaN
(
c
[
1
])
?
0
:
c
[
1
];
y
=
isNaN
(
c
[
1
])
?
0
:
c
[
1
];
...
@@ -4422,7 +4400,7 @@
...
@@ -4422,7 +4400,7 @@
c3_chart_internal_fn
.
getArcRatio
=
function
(
d
)
{
c3_chart_internal_fn
.
getArcRatio
=
function
(
d
)
{
var
$$
=
this
,
var
$$
=
this
,
whole
=
$$
.
has
GaugeType
(
$$
.
data
.
targets
)
?
Math
.
PI
:
(
Math
.
PI
*
2
);
whole
=
$$
.
has
Type
(
'gauge'
)
?
Math
.
PI
:
(
Math
.
PI
*
2
);
return
d
?
(
d
.
endAngle
-
d
.
startAngle
)
/
whole
:
null
;
return
d
?
(
d
.
endAngle
-
d
.
startAngle
)
/
whole
:
null
;
};
};
...
@@ -4442,7 +4420,7 @@
...
@@ -4442,7 +4420,7 @@
updated
=
$$
.
updateAngle
(
d
);
updated
=
$$
.
updateAngle
(
d
);
value
=
updated
?
updated
.
value
:
null
;
value
=
updated
?
updated
.
value
:
null
;
ratio
=
$$
.
getArcRatio
(
updated
);
ratio
=
$$
.
getArcRatio
(
updated
);
if
(
!
$$
.
has
GaugeType
(
$$
.
data
.
targets
)
&&
!
$$
.
meetsArcLabelThreshold
(
ratio
))
{
return
""
;
}
if
(
!
$$
.
has
Type
(
'gauge'
)
&&
!
$$
.
meetsArcLabelThreshold
(
ratio
))
{
return
""
;
}
format
=
$$
.
getArcLabelFormat
();
format
=
$$
.
getArcLabelFormat
();
return
format
?
format
(
value
,
ratio
)
:
$$
.
defaultArcValueFormat
(
value
,
ratio
);
return
format
?
format
(
value
,
ratio
)
:
$$
.
defaultArcValueFormat
(
value
,
ratio
);
};
};
...
@@ -4486,9 +4464,9 @@
...
@@ -4486,9 +4464,9 @@
c3_chart_internal_fn
.
shouldShowArcLabel
=
function
()
{
c3_chart_internal_fn
.
shouldShowArcLabel
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
shouldShow
=
true
;
var
$$
=
this
,
config
=
$$
.
config
,
shouldShow
=
true
;
if
(
$$
.
has
DonutType
(
$$
.
data
.
targets
))
{
if
(
$$
.
has
Type
(
'donut'
))
{
shouldShow
=
config
[
__donut_label_show
];
shouldShow
=
config
[
__donut_label_show
];
}
else
if
(
$$
.
has
PieType
(
$$
.
data
.
targets
))
{
}
else
if
(
$$
.
has
Type
(
'pie'
))
{
shouldShow
=
config
[
__pie_label_show
];
shouldShow
=
config
[
__pie_label_show
];
}
}
// when gauge, always true
// when gauge, always true
...
@@ -4497,16 +4475,16 @@
...
@@ -4497,16 +4475,16 @@
c3_chart_internal_fn
.
meetsArcLabelThreshold
=
function
(
ratio
)
{
c3_chart_internal_fn
.
meetsArcLabelThreshold
=
function
(
ratio
)
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
threshold
=
$$
.
has
DonutType
(
$$
.
data
.
targets
)
?
config
[
__donut_label_threshold
]
:
config
[
__pie_label_threshold
];
threshold
=
$$
.
has
Type
(
'donut'
)
?
config
[
__donut_label_threshold
]
:
config
[
__pie_label_threshold
];
return
ratio
>=
threshold
;
return
ratio
>=
threshold
;
};
};
c3_chart_internal_fn
.
getArcLabelFormat
=
function
()
{
c3_chart_internal_fn
.
getArcLabelFormat
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
format
=
config
[
__pie_label_format
];
format
=
config
[
__pie_label_format
];
if
(
$$
.
has
GaugeType
(
$$
.
data
.
targets
))
{
if
(
$$
.
has
Type
(
'gauge'
))
{
format
=
config
[
__gauge_label_format
];
format
=
config
[
__gauge_label_format
];
}
else
if
(
$$
.
has
DonutType
(
$$
.
data
.
targets
))
{
}
else
if
(
$$
.
has
Type
(
'donut'
))
{
format
=
config
[
__donut_label_format
];
format
=
config
[
__donut_label_format
];
}
}
return
format
;
return
format
;
...
@@ -4514,7 +4492,7 @@
...
@@ -4514,7 +4492,7 @@
c3_chart_internal_fn
.
getArcTitle
=
function
()
{
c3_chart_internal_fn
.
getArcTitle
=
function
()
{
var
$$
=
this
;
var
$$
=
this
;
return
$$
.
has
DonutType
(
$$
.
data
.
targets
)
?
$$
.
config
[
__donut_title
]
:
""
;
return
$$
.
has
Type
(
'donut'
)
?
$$
.
config
[
__donut_title
]
:
""
;
};
};
c3_chart_internal_fn
.
descByStartAngle
=
function
(
a
,
b
)
{
c3_chart_internal_fn
.
descByStartAngle
=
function
(
a
,
b
)
{
...
@@ -4531,7 +4509,7 @@
...
@@ -4531,7 +4509,7 @@
mainPieEnter
.
append
(
'g'
)
mainPieEnter
.
append
(
'g'
)
.
attr
(
'class'
,
generateCall
(
$$
.
classArcs
,
$$
));
.
attr
(
'class'
,
generateCall
(
$$
.
classArcs
,
$$
));
mainPieEnter
.
append
(
"text"
)
mainPieEnter
.
append
(
"text"
)
.
attr
(
"dy"
,
$$
.
has
GaugeType
(
$$
.
data
.
targets
)
?
"-0.35em"
:
".35em"
)
.
attr
(
"dy"
,
$$
.
has
Type
(
'gauge'
)
?
"-0.35em"
:
".35em"
)
.
style
(
"opacity"
,
0
)
.
style
(
"opacity"
,
0
)
.
style
(
"text-anchor"
,
"middle"
)
.
style
(
"text-anchor"
,
"middle"
)
.
style
(
"pointer-events"
,
"none"
);
.
style
(
"pointer-events"
,
"none"
);
...
@@ -4644,7 +4622,7 @@
...
@@ -4644,7 +4622,7 @@
.
transition
().
duration
(
duration
)
.
transition
().
duration
(
duration
)
.
style
(
"opacity"
,
function
(
d
)
{
return
$$
.
isTargetToShow
(
d
.
data
.
id
)
&&
$$
.
isArcType
(
d
.
data
)
?
1
:
0
;
});
.
style
(
"opacity"
,
function
(
d
)
{
return
$$
.
isTargetToShow
(
d
.
data
.
id
)
&&
$$
.
isArcType
(
d
.
data
)
?
1
:
0
;
});
main
.
select
(
'.'
+
CLASS
[
chartArcsTitle
])
main
.
select
(
'.'
+
CLASS
[
chartArcsTitle
])
.
style
(
"opacity"
,
$$
.
has
DonutType
(
$$
.
data
.
targets
)
||
$$
.
hasGaugeType
(
$$
.
data
.
targets
)
?
1
:
0
);
.
style
(
"opacity"
,
$$
.
has
Type
(
'donut'
)
||
$$
.
hasType
(
'gauge'
)
?
1
:
0
);
};
};
...
@@ -4652,7 +4630,7 @@
...
@@ -4652,7 +4630,7 @@
c3_chart_internal_fn
.
initGauge
=
function
()
{
c3_chart_internal_fn
.
initGauge
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
arcs
;
var
$$
=
this
,
config
=
$$
.
config
,
arcs
;
if
(
$$
.
has
GaugeType
(
$$
.
data
.
targets
))
{
if
(
$$
.
has
Type
(
'gauge'
))
{
arcs
.
append
(
'path'
)
arcs
.
append
(
'path'
)
.
attr
(
"class"
,
CLASS
[
chartArcsBackground
])
.
attr
(
"class"
,
CLASS
[
chartArcsBackground
])
.
attr
(
"d"
,
function
()
{
.
attr
(
"d"
,
function
()
{
...
@@ -5100,7 +5078,7 @@
...
@@ -5100,7 +5078,7 @@
*/
*/
c3_chart_internal_fn
.
transformTo
=
function
(
targetIds
,
type
,
optionsForRedraw
)
{
c3_chart_internal_fn
.
transformTo
=
function
(
targetIds
,
type
,
optionsForRedraw
)
{
var
$$
=
this
,
var
$$
=
this
,
withTransitionForAxis
=
!
$$
.
hasArcType
(
$$
.
data
.
targets
),
withTransitionForAxis
=
!
$$
.
hasArcType
(),
options
=
optionsForRedraw
||
{
withTransitionForAxis
:
withTransitionForAxis
};
options
=
optionsForRedraw
||
{
withTransitionForAxis
:
withTransitionForAxis
};
options
.
withTransitionForTransform
=
false
;
options
.
withTransitionForTransform
=
false
;
$$
.
transiting
=
false
;
$$
.
transiting
=
false
;
...
@@ -5353,8 +5331,8 @@
...
@@ -5353,8 +5331,8 @@
*/
*/
c3_chart_internal_fn
.
getYFormat
=
function
(
forArc
)
{
c3_chart_internal_fn
.
getYFormat
=
function
(
forArc
)
{
var
$$
=
this
,
var
$$
=
this
,
formatForY
=
forArc
&&
!
$$
.
has
GaugeType
(
$$
.
data
.
targets
)
?
$$
.
defaultArcValueFormat
:
$$
.
yFormat
,
formatForY
=
forArc
&&
!
$$
.
has
Type
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
yFormat
,
formatForY2
=
forArc
&&
!
$$
.
has
GaugeType
(
$$
.
data
.
targets
)
?
$$
.
defaultArcValueFormat
:
$$
.
y2Format
;
formatForY2
=
forArc
&&
!
$$
.
has
Type
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
y2Format
;
return
function
(
v
,
ratio
,
id
)
{
return
function
(
v
,
ratio
,
id
)
{
var
format
=
$$
.
getAxisId
(
id
)
===
'y2'
?
formatForY2
:
formatForY
;
var
format
=
$$
.
getAxisId
(
id
)
===
'y2'
?
formatForY2
:
formatForY
;
return
format
.
call
(
$$
,
v
,
ratio
);
return
format
.
call
(
$$
,
v
,
ratio
);
...
@@ -5399,7 +5377,7 @@
...
@@ -5399,7 +5377,7 @@
var
$$
=
this
,
config
=
$$
.
config
,
main
=
$$
.
main
,
d3
=
$$
.
d3
;
var
$$
=
this
,
config
=
$$
.
config
,
main
=
$$
.
main
,
d3
=
$$
.
d3
;
var
sx
,
sy
,
mx
,
my
,
minX
,
maxX
,
minY
,
maxY
;
var
sx
,
sy
,
mx
,
my
,
minX
,
maxX
,
minY
,
maxY
;
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
!
config
[
__data_selection_enabled
])
{
return
;
}
// do nothing if not selectable
if
(
!
config
[
__data_selection_enabled
])
{
return
;
}
// do nothing if not selectable
if
(
config
[
__zoom_enabled
]
&&
!
$$
.
zoom
.
altDomain
)
{
return
;
}
// skip if zoomable because of conflict drag dehavior
if
(
config
[
__zoom_enabled
]
&&
!
$$
.
zoom
.
altDomain
)
{
return
;
}
// skip if zoomable because of conflict drag dehavior
if
(
!
config
[
__data_selection_multiple
])
{
return
;
}
// skip when single selection because drag is used for multiple selection
if
(
!
config
[
__data_selection_multiple
])
{
return
;
}
// skip when single selection because drag is used for multiple selection
...
@@ -5455,7 +5433,7 @@
...
@@ -5455,7 +5433,7 @@
c3_chart_internal_fn
.
dragstart
=
function
(
mouse
)
{
c3_chart_internal_fn
.
dragstart
=
function
(
mouse
)
{
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
!
config
[
__data_selection_enabled
])
{
return
;
}
// do nothing if not selectable
if
(
!
config
[
__data_selection_enabled
])
{
return
;
}
// do nothing if not selectable
$$
.
dragStart
=
mouse
;
$$
.
dragStart
=
mouse
;
$$
.
main
.
select
(
'.'
+
CLASS
[
chart
]).
append
(
'rect'
)
$$
.
main
.
select
(
'.'
+
CLASS
[
chart
]).
append
(
'rect'
)
...
@@ -5467,7 +5445,7 @@
...
@@ -5467,7 +5445,7 @@
c3_chart_internal_fn
.
dragend
=
function
()
{
c3_chart_internal_fn
.
dragend
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
!
config
[
__data_selection_enabled
])
{
return
;
}
// do nothing if not selectable
if
(
!
config
[
__data_selection_enabled
])
{
return
;
}
// do nothing if not selectable
$$
.
main
.
select
(
'.'
+
CLASS
[
dragarea
])
$$
.
main
.
select
(
'.'
+
CLASS
[
dragarea
])
.
transition
().
duration
(
100
)
.
transition
().
duration
(
100
)
...
@@ -5498,7 +5476,7 @@
...
@@ -5498,7 +5476,7 @@
this
.
defocus
();
this
.
defocus
();
focus
(
candidatesForNoneArc
.
classed
(
CLASS
[
focused
],
true
));
focus
(
candidatesForNoneArc
.
classed
(
CLASS
[
focused
],
true
));
focus
(
candidatesForArc
);
focus
(
candidatesForArc
);
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
if
(
$$
.
hasArcType
())
{
$$
.
expandArc
(
targetId
,
true
);
$$
.
expandArc
(
targetId
,
true
);
}
}
$$
.
toggleFocusLegend
(
targetId
,
true
);
$$
.
toggleFocusLegend
(
targetId
,
true
);
...
@@ -5515,7 +5493,7 @@
...
@@ -5515,7 +5493,7 @@
this
.
revert
();
this
.
revert
();
defocus
(
candidatesForNoneArc
.
classed
(
CLASS
[
focused
],
false
));
defocus
(
candidatesForNoneArc
.
classed
(
CLASS
[
focused
],
false
));
defocus
(
candidatesForArc
);
defocus
(
candidatesForArc
);
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
if
(
$$
.
hasArcType
())
{
$$
.
unexpandArc
(
targetId
);
$$
.
unexpandArc
(
targetId
);
}
}
$$
.
toggleFocusLegend
(
targetId
,
false
);
$$
.
toggleFocusLegend
(
targetId
,
false
);
...
@@ -5531,7 +5509,7 @@
...
@@ -5531,7 +5509,7 @@
}
}
revert
(
candidatesForNoneArc
.
classed
(
CLASS
[
focused
],
false
));
revert
(
candidatesForNoneArc
.
classed
(
CLASS
[
focused
],
false
));
revert
(
candidatesForArc
);
revert
(
candidatesForArc
);
if
(
$$
.
hasArcType
(
$$
.
data
.
targets
))
{
if
(
$$
.
hasArcType
())
{
$$
.
unexpandArc
(
targetId
);
$$
.
unexpandArc
(
targetId
);
}
}
$$
.
revertLegend
();
$$
.
revertLegend
();
...
...
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