Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.3.0 #486

Merged
merged 44 commits into from
Aug 22, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3d8e00e
Introduce new architecture
masayuki0812 Jun 29, 2014
566f1e2
Define concat in grant task
masayuki0812 Jun 29, 2014
7e59cb1
Refactor
masayuki0812 Jul 22, 2014
c770dad
Refactor
masayuki0812 Jul 26, 2014
d5d85c7
Fix jshint
masayuki0812 Jul 26, 2014
2d676fb
Merge diff to master
masayuki0812 Jul 26, 2014
476aa98
Make arc plugable
masayuki0812 Jul 27, 2014
841f76b
Make subchart plugable
masayuki0812 Jul 27, 2014
c649a1c
Use closure variables for minify
masayuki0812 Jul 27, 2014
f720eb3
Refactor config
masayuki0812 Jul 29, 2014
4fee43b
Refactor for minify
masayuki0812 Jul 30, 2014
7e3d23d
Modify hasType interface
masayuki0812 Jul 31, 2014
07b31a8
Revert "Modify hasType interface"
masayuki0812 Jul 31, 2014
f9b46bb
Revert "Refactor for minify"
masayuki0812 Jul 31, 2014
63edd6d
Ref CLASS key
masayuki0812 Jul 31, 2014
e2a31ff
Refactor hasType
masayuki0812 Jul 31, 2014
39afb5e
Fix trivial
masayuki0812 Jul 31, 2014
6ea5dbc
Fix class ref name
masayuki0812 Jul 31, 2014
47e95ec
Refactor init of internal params
masayuki0812 Jul 31, 2014
6fd0279
Remove inner y axis
masayuki0812 Jul 31, 2014
26638a3
Make plugable legend
masayuki0812 Aug 1, 2014
06f36e0
Make plugble zoom
masayuki0812 Aug 1, 2014
fe5a71a
Separete src files
masayuki0812 Aug 1, 2014
3aae9ba
Fix gauge
masayuki0812 Aug 1, 2014
bc8226a
Fix bugs
masayuki0812 Aug 2, 2014
da90124
Enable additional config
masayuki0812 Aug 4, 2014
3ce01be
Fix trivial
masayuki0812 Aug 4, 2014
a0801cb
Merge master fix
masayuki0812 Aug 9, 2014
1d105c1
Update c3.js and c3.min.js
masayuki0812 Aug 9, 2014
8e9bd1a
Separate axis
masayuki0812 Aug 15, 2014
991edd3
Modularize grid
masayuki0812 Aug 16, 2014
248324d
Fix position of data label on flow
masayuki0812 Aug 16, 2014
2fa6a3b
Remove isFunction
masayuki0812 Aug 16, 2014
1e6867a
Modularize region
masayuki0812 Aug 16, 2014
55c1a2a
Modularize text
masayuki0812 Aug 16, 2014
5ef894a
Modularize bar
masayuki0812 Aug 16, 2014
1669ec4
Fix tick format for timeseries
masayuki0812 Aug 16, 2014
f2f7545
Modularize line, area and circle
masayuki0812 Aug 16, 2014
0516616
Modularize event rect
masayuki0812 Aug 17, 2014
0b4a324
Use bind instead of my function
masayuki0812 Aug 17, 2014
adbfd48
Separate api
masayuki0812 Aug 17, 2014
a6ab889
Modularize api.flow
masayuki0812 Aug 17, 2014
24e06dd
Move transformTo to api.transform.js
masayuki0812 Aug 17, 2014
ae7bc0c
Fix updateSize
masayuki0812 Aug 19, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove isFunction
  • Loading branch information
masayuki0812 committed Aug 16, 2014
commit 2fa6a3b53ffbde916d7f587984d6be6231235e9b
68 changes: 26 additions & 42 deletions c3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 --*/

Expand Down Expand Up @@ -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]);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 --*/

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -911,7 +899,7 @@
$$.withoutFadeIn[id] = true;
});

if (isFunction($$.updateZoom)) { $$.updateZoom(); }
if ($$.updateZoom) { $$.updateZoom(); }
};

c3_chart_internal_fn.updateAndRedraw = function (options) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -2608,7 +2592,7 @@
};
c3_chart_internal_fn.unload = function (targetIds, done) {
var $$ = this;
if (!isFunction(done)) {
if (!done) {
done = function () {};
}
// filter existing target
Expand Down Expand Up @@ -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);
}
})
Expand All @@ -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);
}
});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
}
}
Expand Down Expand Up @@ -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(); }
});
};

Expand Down
8 changes: 4 additions & 4 deletions c3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
44 changes: 16 additions & 28 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 --*/

Expand Down Expand Up @@ -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]);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 --*/

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions src/data.load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
})
Expand All @@ -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);
}
});
Expand Down
4 changes: 1 addition & 3 deletions src/scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
};