-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add padAngle option for pie/donut (#2669)
* add pie.padAngle and donut.padAngle options * add API to get/set padAngle for both pie and donut * add pie.padAngle and donut.padAngle in reference doc * add padAngle option in donut sample * bind getPadAngle method to self * use chart main instead of global D3 to select chart's elements
- Loading branch information
Showing
10 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe('c3 api donut', function () { | ||
'use strict'; | ||
|
||
var chart, args; | ||
|
||
args = { | ||
data: { | ||
columns: [ | ||
['data1', 60], | ||
['data2', 40] | ||
], | ||
type: 'donut' | ||
}, | ||
donut: { | ||
padAngle: 0.5 | ||
} | ||
}; | ||
|
||
beforeAll(function (done) { | ||
chart = window.initChart(chart, args, done); | ||
}); | ||
|
||
it('can configure padAngle', function (done) { | ||
expect(chart.donut.padAngle()).toBe(0.5); | ||
|
||
const path = chart.internal.main.select('.c3-arc-data1').attr('d'); | ||
|
||
chart.donut.padAngle(0.2); | ||
|
||
setTimeout(function () { | ||
expect(chart.donut.padAngle()).toBe(0.2); | ||
expect(chart.internal.main.select('.c3-arc-data1').attr('d')).not.toBe(path); | ||
done(); | ||
}, 500); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe('c3 api pie', function () { | ||
'use strict'; | ||
|
||
var chart, args; | ||
|
||
args = { | ||
data: { | ||
columns: [ | ||
['data1', 60], | ||
['data2', 40] | ||
], | ||
type: 'pie' | ||
}, | ||
pie: { | ||
padAngle: 0.5 | ||
} | ||
}; | ||
|
||
beforeAll(function (done) { | ||
chart = window.initChart(chart, args, done); | ||
}); | ||
|
||
it('can configure padAngle', function (done) { | ||
expect(chart.pie.padAngle()).toBe(0.5); | ||
|
||
const path = chart.internal.main.select('.c3-arc-data1').attr('d'); | ||
|
||
chart.pie.padAngle(0.2); | ||
|
||
setTimeout(function () { | ||
expect(chart.pie.padAngle()).toBe(0.2); | ||
expect(chart.internal.main.select('.c3-arc-data1').attr('d')).not.toBe(path); | ||
done(); | ||
}, 500); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Chart } from './core'; | ||
|
||
Chart.prototype.donut = function() {}; | ||
|
||
Chart.prototype.donut.padAngle = function (padAngle) { | ||
if (padAngle === undefined) { | ||
return this.internal.config.donut_padAngle; | ||
} | ||
this.internal.config.donut_padAngle = padAngle; | ||
this.flush(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Chart } from './core'; | ||
|
||
Chart.prototype.pie = function() {}; | ||
|
||
Chart.prototype.pie.padAngle = function (padAngle) { | ||
if (padAngle === undefined) { | ||
return this.internal.config.pie_padAngle; | ||
} | ||
this.internal.config.pie_padAngle = padAngle; | ||
this.flush(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters