Commit c5fab489 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Accept d3.selection object for bindto - #715

parent 1d6b4302
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
if ($$.initBrush) { $$.initBrush(); } if ($$.initBrush) { $$.initBrush(); }
if ($$.initZoom) { $$.initZoom(); } if ($$.initZoom) { $$.initZoom(); }
$$.selectChart = d3.select(config.bindto); $$.selectChart = typeof config.bindto.node === 'function' ? config.bindto : d3.select(config.bindto);
if ($$.selectChart.empty()) { if ($$.selectChart.empty()) {
$$.selectChart = d3.select(document.createElement('div')).style('opacity', 0); $$.selectChart = d3.select(document.createElement('div')).style('opacity', 0);
$$.observeInserted($$.selectChart); $$.observeInserted($$.selectChart);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -56,4 +56,18 @@ describe('c3 chart', function () { ...@@ -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();
});
});
}); });
...@@ -146,7 +146,7 @@ c3_chart_internal_fn.initWithData = function (data) { ...@@ -146,7 +146,7 @@ c3_chart_internal_fn.initWithData = function (data) {
if ($$.initBrush) { $$.initBrush(); } if ($$.initBrush) { $$.initBrush(); }
if ($$.initZoom) { $$.initZoom(); } if ($$.initZoom) { $$.initZoom(); }
$$.selectChart = d3.select(config.bindto); $$.selectChart = typeof config.bindto.node === 'function' ? config.bindto : d3.select(config.bindto);
if ($$.selectChart.empty()) { if ($$.selectChart.empty()) {
$$.selectChart = d3.select(document.createElement('div')).style('opacity', 0); $$.selectChart = d3.select(document.createElement('div')).style('opacity', 0);
$$.observeInserted($$.selectChart); $$.observeInserted($$.selectChart);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment