Browse Source

Accept d3.selection object for bindto - #715

pull/729/head
Masayuki Tanaka 10 years ago
parent
commit
c5fab4897f
  1. 2
      c3.js
  2. 4
      c3.min.js
  3. 14
      spec/core-spec.js
  4. 2
      src/core.js

2
c3.js

@ -151,7 +151,7 @@
if ($$.initBrush) { $$.initBrush(); }
if ($$.initZoom) { $$.initZoom(); }
$$.selectChart = d3.select(config.bindto);
$$.selectChart = typeof config.bindto.node === 'function' ? config.bindto : d3.select(config.bindto);
if ($$.selectChart.empty()) {
$$.selectChart = d3.select(document.createElement('div')).style('opacity', 0);
$$.observeInserted($$.selectChart);

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

14
spec/core-spec.js

@ -56,4 +56,18 @@ describe('c3 chart', function () {
});
describe('bindto', function () {
it('should accept d3.selection object', function () {
args.bindto = d3.select('#chart');
expect(true).toBeTruthy();
});
it('should be created', function () {
var svg = d3.select('#chart svg');
expect(svg).not.toBeNull();
});
});
});

2
src/core.js

@ -146,7 +146,7 @@ c3_chart_internal_fn.initWithData = function (data) {
if ($$.initBrush) { $$.initBrush(); }
if ($$.initZoom) { $$.initZoom(); }
$$.selectChart = d3.select(config.bindto);
$$.selectChart = typeof config.bindto.node === 'function' ? config.bindto : d3.select(config.bindto);
if ($$.selectChart.empty()) {
$$.selectChart = d3.select(document.createElement('div')).style('opacity', 0);
$$.observeInserted($$.selectChart);

Loading…
Cancel
Save