@byu-oit/pie-chart
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -5,7 +5,7 @@ import {scaleOrdinal} from 'd3-scale' | ||
export default function ({data = [1], labels = [1]}) { | ||
export default function ({data = [1], labels = [1], colors = schemeSet1}) { | ||
const segments = () => { | ||
const radius = 50 | ||
const color = scaleOrdinal(schemeSet1) | ||
const color = scaleOrdinal(colors) | ||
@@ -12,0 +12,0 @@ const shapeArc = arc() |
{ | ||
"name": "@byu-oit/pie-chart", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Generate a pie chart in svg format. Intended to be used to generate an API response.", | ||
@@ -5,0 +5,0 @@ "main": "dist/pie-chart.js", |
const test = require('tape') | ||
const pie = require('../dist/pie-chart') | ||
const fs = require('fs') | ||
const path = require('path') | ||
@@ -12,3 +13,3 @@ test('pie', (assert) => { | ||
fs.writeFileSync('/tmp/pie-chart.svg', chart) | ||
fs.writeFileSync(path.resolve(__dirname, '../example/pie-chart.svg'), chart) | ||
@@ -18,1 +19,21 @@ assert.deepEqual(actual, expected, 'chart') | ||
}) | ||
test('custom colors', (assert) => { | ||
const colors = [ | ||
'#c6dbef', | ||
'#9ecae1', | ||
'#6baed6', | ||
'#3182bd', | ||
'#08519c' | ||
] | ||
const data = [20, 20, 20, 20, 20] | ||
const labels = ['One', 'Two', 'Three', 'Four', 'Five'] | ||
const expected = 5 | ||
const chart = pie({data, labels, colors}) | ||
const actual = (chart.match(/<path/g) || []).length | ||
fs.writeFileSync(path.resolve(__dirname, '../example/custom-colors.svg'), chart) | ||
assert.deepEqual(actual, expected, 'chart') | ||
assert.end() | ||
}) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
2779
12
120738