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
2fa6a3b5
Commit
2fa6a3b5
authored
Aug 16, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove isFunction
parent
248324db
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
52 additions
and
84 deletions
+52
-84
c3.js
c3.js
+26
-42
c3.min.js
c3.min.js
+0
-0
api.js
src/api.js
+1
-1
axis.js
src/axis.js
+1
-1
core.js
src/core.js
+16
-28
data.load.js
src/data.load.js
+2
-4
format.js
src/format.js
+2
-2
legend.js
src/legend.js
+3
-3
scale.js
src/scale.js
+1
-3
No files found.
c3.js
View file @
2fa6a3b5
...
...
@@ -134,9 +134,9 @@
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
var
main
,
eventRect
,
binding
=
true
;
if
(
isFunction
(
$$
.
initPie
)
)
{
$$
.
initPie
();
}
if
(
isFunction
(
$$
.
initBrush
)
)
{
$$
.
initBrush
();
}
if
(
isFunction
(
$$
.
initZoom
)
)
{
$$
.
initZoom
();
}
if
(
$$
.
initPie
)
{
$$
.
initPie
();
}
if
(
$$
.
initBrush
)
{
$$
.
initBrush
();
}
if
(
$$
.
initZoom
)
{
$$
.
initZoom
();
}
$$
.
selectChart
=
d3
.
select
(
config
[
__bindto
]);
if
(
$$
.
selectChart
.
empty
())
{
...
...
@@ -201,9 +201,9 @@
// Define regions
main
=
$$
.
main
=
$$
.
svg
.
append
(
"g"
).
attr
(
"transform"
,
$$
.
getTranslate
(
'main'
));
if
(
isFunction
(
$$
.
initSubchart
)
)
{
$$
.
initSubchart
();
}
if
(
isFunction
(
$$
.
initTooltip
)
)
{
$$
.
initTooltip
();
}
if
(
isFunction
(
$$
.
initLegend
)
)
{
$$
.
initLegend
();
}
if
(
$$
.
initSubchart
)
{
$$
.
initSubchart
();
}
if
(
$$
.
initTooltip
)
{
$$
.
initTooltip
();
}
if
(
$$
.
initLegend
)
{
$$
.
initLegend
();
}
/*-- Main Region --*/
...
...
@@ -240,12 +240,8 @@
.
attr
(
"class"
,
CLASS
[
_chartLines
]);
// Define g for arc chart area
if
(
isFunction
(
$$
.
initArc
))
{
$$
.
initArc
();
}
if
(
isFunction
(
$$
.
initGauge
))
{
$$
.
initGauge
();
}
if
(
$$
.
initArc
)
{
$$
.
initArc
();
}
if
(
$$
.
initGauge
)
{
$$
.
initGauge
();
}
main
.
select
(
'.'
+
CLASS
[
_chart
]).
append
(
"g"
)
.
attr
(
"class"
,
CLASS
[
_chartTexts
]);
...
...
@@ -261,7 +257,7 @@
// Set default extent if defined
if
(
config
[
__axis_x_default
])
{
$$
.
brush
.
extent
(
!
isFunction
(
config
[
__axis_x_default
])
?
config
[
__axis_x_default
]
:
config
[
__axis_x_default
](
$$
.
getXDomain
())
);
$$
.
brush
.
extent
(
isFunction
(
config
[
__axis_x_default
])
?
config
[
__axis_x_default
](
$$
.
getXDomain
())
:
config
[
__axis_x_default
]
);
}
// Add Axis
...
...
@@ -363,7 +359,7 @@
}
// for legend
if
(
isFunction
(
$$
.
updateSizeForLegend
)
)
{
$$
.
updateSizeForLegend
(
legendHeight
,
legendWidth
);
}
if
(
$$
.
updateSizeForLegend
)
{
$$
.
updateSizeForLegend
(
legendHeight
,
legendWidth
);
}
$$
.
width
=
$$
.
currentWidth
-
$$
.
margin
.
left
-
$$
.
margin
.
right
;
$$
.
height
=
$$
.
currentHeight
-
$$
.
margin
.
top
-
$$
.
margin
.
bottom
;
...
...
@@ -378,9 +374,7 @@
// for arc
$$
.
arcWidth
=
$$
.
width
-
(
$$
.
isLegendRight
?
legendWidth
+
10
:
0
);
$$
.
arcHeight
=
$$
.
height
-
(
$$
.
isLegendRight
?
0
:
10
);
if
(
isFunction
(
$$
.
updateRadius
))
{
$$
.
updateRadius
();
}
if
(
$$
.
updateRadius
)
{
$$
.
updateRadius
();
}
if
(
$$
.
isLegendRight
&&
hasArc
)
{
$$
.
margin3
.
left
=
$$
.
arcWidth
/
2
+
$$
.
radiusExpanded
*
1.1
;
...
...
@@ -446,12 +440,8 @@
// MEMO: can not keep same color...
//mainLineUpdate.exit().remove();
if
(
isFunction
(
$$
.
updateTargetsForArc
))
{
$$
.
updateTargetsForArc
(
targets
);
}
if
(
isFunction
(
$$
.
updateTargetsForSubchart
))
{
$$
.
updateTargetsForSubchart
(
targets
);
}
if
(
$$
.
updateTargetsForArc
)
{
$$
.
updateTargetsForArc
(
targets
);
}
if
(
$$
.
updateTargetsForSubchart
)
{
$$
.
updateTargetsForSubchart
(
targets
);
}
/*-- Show --*/
...
...
@@ -658,12 +648,10 @@
}
// arc
if
(
isFunction
(
$$
.
redrawArc
))
{
$$
.
redrawArc
(
duration
,
durationForExit
,
withTransform
);
}
if
(
$$
.
redrawArc
)
{
$$
.
redrawArc
(
duration
,
durationForExit
,
withTransform
);
}
// subchart
if
(
isFunction
(
$$
.
redrawSubchart
)
)
{
if
(
$$
.
redrawSubchart
)
{
$$
.
redrawSubchart
(
withSubchart
,
transitions
,
duration
,
durationForExit
,
areaIndices
,
barIndices
,
lineIndices
);
}
...
...
@@ -911,7 +899,7 @@
$$
.
withoutFadeIn
[
id
]
=
true
;
});
if
(
isFunction
(
$$
.
updateZoom
)
)
{
$$
.
updateZoom
();
}
if
(
$$
.
updateZoom
)
{
$$
.
updateZoom
();
}
};
c3_chart_internal_fn
.
updateAndRedraw
=
function
(
options
)
{
...
...
@@ -1842,9 +1830,7 @@
if
(
config
[
__zoom_enabled
])
{
$$
.
zoom
.
scale
(
$$
.
x
);
}
}
// update for arc
if
(
isFunction
(
$$
.
updateArc
))
{
$$
.
updateArc
();
}
if
(
$$
.
updateArc
)
{
$$
.
updateArc
();
}
};
c3_chart_internal_fn
.
getYDomainMin
=
function
(
targets
)
{
...
...
@@ -2579,9 +2565,7 @@
// Redraw with new targets
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
if
(
isFunction
(
args
.
done
))
{
args
.
done
();
}
if
(
args
.
done
)
{
args
.
done
();
}
};
c3_chart_internal_fn
.
loadFromArgs
=
function
(
args
)
{
var
$$
=
this
;
...
...
@@ -2608,7 +2592,7 @@
};
c3_chart_internal_fn
.
unload
=
function
(
targetIds
,
done
)
{
var
$$
=
this
;
if
(
!
isFunction
(
done
)
)
{
if
(
!
done
)
{
done
=
function
()
{};
}
// filter existing target
...
...
@@ -3742,14 +3726,14 @@
.
style
(
'visibility'
,
function
(
id
)
{
return
$$
.
isLegendToShow
(
id
)
?
'visible'
:
'hidden'
;
})
.
style
(
'cursor'
,
'pointer'
)
.
on
(
'click'
,
function
(
id
)
{
isFunction
(
config
[
__legend_item_onclick
])
?
config
[
__legend_item_onclick
].
call
(
$$
,
id
)
:
$$
.
api
.
toggle
(
id
);
config
[
__legend_item_onclick
]
?
config
[
__legend_item_onclick
].
call
(
$$
,
id
)
:
$$
.
api
.
toggle
(
id
);
})
.
on
(
'mouseover'
,
function
(
id
)
{
$$
.
d3
.
select
(
this
).
classed
(
CLASS
[
_legendItemFocused
],
true
);
if
(
!
$$
.
transiting
)
{
$$
.
api
.
focus
(
id
);
}
if
(
isFunction
(
config
[
__legend_item_onmouseover
])
)
{
if
(
config
[
__legend_item_onmouseover
]
)
{
config
[
__legend_item_onmouseover
].
call
(
$$
,
id
);
}
})
...
...
@@ -3758,7 +3742,7 @@
if
(
!
$$
.
transiting
)
{
$$
.
api
.
revert
();
}
if
(
isFunction
(
config
[
__legend_item_onmouseout
])
)
{
if
(
config
[
__legend_item_onmouseout
]
)
{
config
[
__legend_item_onmouseout
].
call
(
$$
,
id
);
}
});
...
...
@@ -3903,7 +3887,7 @@
var
$$
=
this
,
config
=
$$
.
config
,
format
=
$$
.
isTimeSeries
()
?
$$
.
defaultAxisTimeFormat
:
$$
.
isCategorized
()
?
$$
.
categoryName
:
function
(
v
)
{
return
v
<
0
?
v
.
toFixed
(
0
)
:
v
;
};
if
(
config
[
__axis_x_tick_format
])
{
if
(
isFunction
(
config
[
__axis_x_tick_format
])
)
{
if
(
config
[
__axis_x_tick_format
]
)
{
format
=
config
[
__axis_x_tick_format
];
}
else
if
(
$$
.
isTimeSeries
())
{
format
=
function
(
date
)
{
...
...
@@ -5102,10 +5086,10 @@
var
$$
=
this
,
data_labels
=
$$
.
config
[
__data_labels
],
format
=
function
(
v
)
{
return
isValue
(
v
)
?
+
v
:
""
;
};
// find format according to axis id
if
(
isFunction
(
data_labels
.
format
)
)
{
if
(
data_labels
.
format
)
{
format
=
data_labels
.
format
;
}
else
if
(
typeof
data_labels
.
format
===
'object'
)
{
if
(
isFunction
(
data_labels
.
format
[
axisId
])
)
{
if
(
data_labels
.
format
[
axisId
]
)
{
format
=
data_labels
.
format
[
axisId
];
}
}
...
...
@@ -5555,7 +5539,7 @@
args
=
args
||
{};
$$
.
unload
(
$$
.
mapToTargetIds
(
args
.
ids
),
function
()
{
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
if
(
isFunction
(
args
.
done
)
)
{
args
.
done
();
}
if
(
args
.
done
)
{
args
.
done
();
}
});
};
...
...
c3.min.js
View file @
2fa6a3b5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/api.js
View file @
2fa6a3b5
...
...
@@ -140,7 +140,7 @@ c3_chart_fn.unload = function (args) {
args
=
args
||
{};
$$
.
unload
(
$$
.
mapToTargetIds
(
args
.
ids
),
function
()
{
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
if
(
isFunction
(
args
.
done
)
)
{
args
.
done
();
}
if
(
args
.
done
)
{
args
.
done
();
}
});
};
...
...
src/axis.js
View file @
2fa6a3b5
...
...
@@ -63,7 +63,7 @@ c3_chart_internal_fn.getXAxisTickFormat = function () {
var
$$
=
this
,
config
=
$$
.
config
,
format
=
$$
.
isTimeSeries
()
?
$$
.
defaultAxisTimeFormat
:
$$
.
isCategorized
()
?
$$
.
categoryName
:
function
(
v
)
{
return
v
<
0
?
v
.
toFixed
(
0
)
:
v
;
};
if
(
config
[
__axis_x_tick_format
])
{
if
(
isFunction
(
config
[
__axis_x_tick_format
])
)
{
if
(
config
[
__axis_x_tick_format
]
)
{
format
=
config
[
__axis_x_tick_format
];
}
else
if
(
$$
.
isTimeSeries
())
{
format
=
function
(
date
)
{
...
...
src/core.js
View file @
2fa6a3b5
...
...
@@ -129,9 +129,9 @@ c3_chart_internal_fn.initWithData = function (data) {
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
var
main
,
eventRect
,
binding
=
true
;
if
(
isFunction
(
$$
.
initPie
)
)
{
$$
.
initPie
();
}
if
(
isFunction
(
$$
.
initBrush
)
)
{
$$
.
initBrush
();
}
if
(
isFunction
(
$$
.
initZoom
)
)
{
$$
.
initZoom
();
}
if
(
$$
.
initPie
)
{
$$
.
initPie
();
}
if
(
$$
.
initBrush
)
{
$$
.
initBrush
();
}
if
(
$$
.
initZoom
)
{
$$
.
initZoom
();
}
$$
.
selectChart
=
d3
.
select
(
config
[
__bindto
]);
if
(
$$
.
selectChart
.
empty
())
{
...
...
@@ -196,9 +196,9 @@ c3_chart_internal_fn.initWithData = function (data) {
// Define regions
main
=
$$
.
main
=
$$
.
svg
.
append
(
"g"
).
attr
(
"transform"
,
$$
.
getTranslate
(
'main'
));
if
(
isFunction
(
$$
.
initSubchart
)
)
{
$$
.
initSubchart
();
}
if
(
isFunction
(
$$
.
initTooltip
)
)
{
$$
.
initTooltip
();
}
if
(
isFunction
(
$$
.
initLegend
)
)
{
$$
.
initLegend
();
}
if
(
$$
.
initSubchart
)
{
$$
.
initSubchart
();
}
if
(
$$
.
initTooltip
)
{
$$
.
initTooltip
();
}
if
(
$$
.
initLegend
)
{
$$
.
initLegend
();
}
/*-- Main Region --*/
...
...
@@ -235,12 +235,8 @@ c3_chart_internal_fn.initWithData = function (data) {
.
attr
(
"class"
,
CLASS
[
_chartLines
]);
// Define g for arc chart area
if
(
isFunction
(
$$
.
initArc
))
{
$$
.
initArc
();
}
if
(
isFunction
(
$$
.
initGauge
))
{
$$
.
initGauge
();
}
if
(
$$
.
initArc
)
{
$$
.
initArc
();
}
if
(
$$
.
initGauge
)
{
$$
.
initGauge
();
}
main
.
select
(
'.'
+
CLASS
[
_chart
]).
append
(
"g"
)
.
attr
(
"class"
,
CLASS
[
_chartTexts
]);
...
...
@@ -256,7 +252,7 @@ c3_chart_internal_fn.initWithData = function (data) {
// Set default extent if defined
if
(
config
[
__axis_x_default
])
{
$$
.
brush
.
extent
(
!
isFunction
(
config
[
__axis_x_default
])
?
config
[
__axis_x_default
]
:
config
[
__axis_x_default
](
$$
.
getXDomain
())
);
$$
.
brush
.
extent
(
isFunction
(
config
[
__axis_x_default
])
?
config
[
__axis_x_default
](
$$
.
getXDomain
())
:
config
[
__axis_x_default
]
);
}
// Add Axis
...
...
@@ -358,7 +354,7 @@ c3_chart_internal_fn.updateSizes = function () {
}
// for legend
if
(
isFunction
(
$$
.
updateSizeForLegend
)
)
{
$$
.
updateSizeForLegend
(
legendHeight
,
legendWidth
);
}
if
(
$$
.
updateSizeForLegend
)
{
$$
.
updateSizeForLegend
(
legendHeight
,
legendWidth
);
}
$$
.
width
=
$$
.
currentWidth
-
$$
.
margin
.
left
-
$$
.
margin
.
right
;
$$
.
height
=
$$
.
currentHeight
-
$$
.
margin
.
top
-
$$
.
margin
.
bottom
;
...
...
@@ -373,9 +369,7 @@ c3_chart_internal_fn.updateSizes = function () {
// for arc
$$
.
arcWidth
=
$$
.
width
-
(
$$
.
isLegendRight
?
legendWidth
+
10
:
0
);
$$
.
arcHeight
=
$$
.
height
-
(
$$
.
isLegendRight
?
0
:
10
);
if
(
isFunction
(
$$
.
updateRadius
))
{
$$
.
updateRadius
();
}
if
(
$$
.
updateRadius
)
{
$$
.
updateRadius
();
}
if
(
$$
.
isLegendRight
&&
hasArc
)
{
$$
.
margin3
.
left
=
$$
.
arcWidth
/
2
+
$$
.
radiusExpanded
*
1.1
;
...
...
@@ -441,12 +435,8 @@ c3_chart_internal_fn.updateTargets = function (targets) {
// MEMO: can not keep same color...
//mainLineUpdate.exit().remove();
if
(
isFunction
(
$$
.
updateTargetsForArc
))
{
$$
.
updateTargetsForArc
(
targets
);
}
if
(
isFunction
(
$$
.
updateTargetsForSubchart
))
{
$$
.
updateTargetsForSubchart
(
targets
);
}
if
(
$$
.
updateTargetsForArc
)
{
$$
.
updateTargetsForArc
(
targets
);
}
if
(
$$
.
updateTargetsForSubchart
)
{
$$
.
updateTargetsForSubchart
(
targets
);
}
/*-- Show --*/
...
...
@@ -653,12 +643,10 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
}
// arc
if
(
isFunction
(
$$
.
redrawArc
))
{
$$
.
redrawArc
(
duration
,
durationForExit
,
withTransform
);
}
if
(
$$
.
redrawArc
)
{
$$
.
redrawArc
(
duration
,
durationForExit
,
withTransform
);
}
// subchart
if
(
isFunction
(
$$
.
redrawSubchart
)
)
{
if
(
$$
.
redrawSubchart
)
{
$$
.
redrawSubchart
(
withSubchart
,
transitions
,
duration
,
durationForExit
,
areaIndices
,
barIndices
,
lineIndices
);
}
...
...
@@ -906,7 +894,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
$$
.
withoutFadeIn
[
id
]
=
true
;
});
if
(
isFunction
(
$$
.
updateZoom
)
)
{
$$
.
updateZoom
();
}
if
(
$$
.
updateZoom
)
{
$$
.
updateZoom
();
}
};
c3_chart_internal_fn
.
updateAndRedraw
=
function
(
options
)
{
...
...
src/data.load.js
View file @
2fa6a3b5
...
...
@@ -30,9 +30,7 @@ c3_chart_internal_fn.load = function (targets, args) {
// Redraw with new targets
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
if
(
isFunction
(
args
.
done
))
{
args
.
done
();
}
if
(
args
.
done
)
{
args
.
done
();
}
};
c3_chart_internal_fn
.
loadFromArgs
=
function
(
args
)
{
var
$$
=
this
;
...
...
@@ -59,7 +57,7 @@ c3_chart_internal_fn.loadFromArgs = function (args) {
};
c3_chart_internal_fn
.
unload
=
function
(
targetIds
,
done
)
{
var
$$
=
this
;
if
(
!
isFunction
(
done
)
)
{
if
(
!
done
)
{
done
=
function
()
{};
}
// filter existing target
...
...
src/format.js
View file @
2fa6a3b5
...
...
@@ -27,10 +27,10 @@ c3_chart_internal_fn.formatByAxisId = function (axisId) {
var
$$
=
this
,
data_labels
=
$$
.
config
[
__data_labels
],
format
=
function
(
v
)
{
return
isValue
(
v
)
?
+
v
:
""
;
};
// find format according to axis id
if
(
isFunction
(
data_labels
.
format
)
)
{
if
(
data_labels
.
format
)
{
format
=
data_labels
.
format
;
}
else
if
(
typeof
data_labels
.
format
===
'object'
)
{
if
(
isFunction
(
data_labels
.
format
[
axisId
])
)
{
if
(
data_labels
.
format
[
axisId
]
)
{
format
=
data_labels
.
format
[
axisId
];
}
}
...
...
src/legend.js
View file @
2fa6a3b5
...
...
@@ -197,14 +197,14 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
.
style
(
'visibility'
,
function
(
id
)
{
return
$$
.
isLegendToShow
(
id
)
?
'visible'
:
'hidden'
;
})
.
style
(
'cursor'
,
'pointer'
)
.
on
(
'click'
,
function
(
id
)
{
isFunction
(
config
[
__legend_item_onclick
])
?
config
[
__legend_item_onclick
].
call
(
$$
,
id
)
:
$$
.
api
.
toggle
(
id
);
config
[
__legend_item_onclick
]
?
config
[
__legend_item_onclick
].
call
(
$$
,
id
)
:
$$
.
api
.
toggle
(
id
);
})
.
on
(
'mouseover'
,
function
(
id
)
{
$$
.
d3
.
select
(
this
).
classed
(
CLASS
[
_legendItemFocused
],
true
);
if
(
!
$$
.
transiting
)
{
$$
.
api
.
focus
(
id
);
}
if
(
isFunction
(
config
[
__legend_item_onmouseover
])
)
{
if
(
config
[
__legend_item_onmouseover
]
)
{
config
[
__legend_item_onmouseover
].
call
(
$$
,
id
);
}
})
...
...
@@ -213,7 +213,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
if
(
!
$$
.
transiting
)
{
$$
.
api
.
revert
();
}
if
(
isFunction
(
config
[
__legend_item_onmouseout
])
)
{
if
(
config
[
__legend_item_onmouseout
]
)
{
config
[
__legend_item_onmouseout
].
call
(
$$
,
id
);
}
});
...
...
src/scale.js
View file @
2fa6a3b5
...
...
@@ -81,7 +81,5 @@ c3_chart_internal_fn.updateScales = function () {
if
(
config
[
__zoom_enabled
])
{
$$
.
zoom
.
scale
(
$$
.
x
);
}
}
// update for arc
if
(
isFunction
(
$$
.
updateArc
))
{
$$
.
updateArc
();
}
if
(
$$
.
updateArc
)
{
$$
.
updateArc
();
}
};
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