Skip to content

Commit

Permalink
fix(bump): fix points keys & motion and code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Dec 18, 2019
1 parent 5098e53 commit d92a965
Show file tree
Hide file tree
Showing 41 changed files with 207 additions and 121 deletions.
12 changes: 10 additions & 2 deletions examples/typescript/src/components/ScatterPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ export default class ScatterPlot extends React.Component {
const data = [
{
id: 'group A',
data: [{ x: 0, y: 0 }, { x: 2, y: 7 }, { x: 7, y: 23 }],
data: [
{ x: 0, y: 0 },
{ x: 2, y: 7 },
{ x: 7, y: 23 },
],
},
{
id: 'group B',
data: [{ x: 3, y: 13 }, { x: 5, y: 7 }, { x: 6, y: 19 }],
data: [
{ x: 3, y: 13 },
{ x: 5, y: 7 },
{ x: 6, y: 19 },
],
},
]

Expand Down
6 changes: 5 additions & 1 deletion packages/annotations/src/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ export const computeAnnotation = ({
}

return {
points: [[computedX, computedY], [computedNoteX, computedNoteY], [noteLineX, noteLineY]],
points: [
[computedX, computedY],
[computedNoteX, computedNoteY],
[noteLineX, noteLineY],
],
text: [textX, textY],
angle: angle + 90,
}
Expand Down
50 changes: 41 additions & 9 deletions packages/bar/tests/Bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ it('should render a basic bar chart', () => {
<Bar
width={500}
height={300}
data={[{ id: 'one', value: 10 }, { id: 'two', value: 20 }, { id: 'three', value: 30 }]}
data={[
{ id: 'one', value: 10 },
{ id: 'two', value: 20 },
{ id: 'three', value: 30 },
]}
/>
)

Expand All @@ -31,7 +35,11 @@ it('should allow to disable labels', () => {
width={500}
height={300}
enableLabel={false}
data={[{ id: 'one', value: 10 }, { id: 'two', value: 20 }, { id: 'three', value: 30 }]}
data={[
{ id: 'one', value: 10 },
{ id: 'two', value: 20 },
{ id: 'three', value: 30 },
]}
/>
)

Expand All @@ -46,7 +54,11 @@ it('should allow grouped mode', () => {
height={300}
enableLabel={false}
groupMode="grouped"
data={[{ id: 'one', value: 10 }, { id: 'two', value: 20 }, { id: 'three', value: 30 }]}
data={[
{ id: 'one', value: 10 },
{ id: 'two', value: 20 },
{ id: 'three', value: 30 },
]}
/>
)

Expand All @@ -61,7 +73,11 @@ it('should allow horizontal layout', () => {
height={300}
enableLabel={false}
layout="horizontal"
data={[{ id: 'one', value: 10 }, { id: 'two', value: 20 }, { id: 'three', value: 30 }]}
data={[
{ id: 'one', value: 10 },
{ id: 'two', value: 20 },
{ id: 'three', value: 30 },
]}
/>
)

Expand All @@ -77,7 +93,11 @@ it('should allow grouped horizontal layout', () => {
enableLabel={false}
groupMode="grouped"
layout="horizontal"
data={[{ id: 'one', value: 10 }, { id: 'two', value: 20 }, { id: 'three', value: 30 }]}
data={[
{ id: 'one', value: 10 },
{ id: 'two', value: 20 },
{ id: 'three', value: 30 },
]}
/>
)

Expand All @@ -90,7 +110,10 @@ it(`should reverse legend items if chart layout is vertical`, () => {
<Bar
width={500}
height={300}
data={[{ id: 'one', A: 10, B: 13 }, { id: 'two', A: 12, B: 9 }]}
data={[
{ id: 'one', A: 10, B: 13 },
{ id: 'two', A: 12, B: 9 },
]}
keys={['A', 'B']}
layout="vertical"
legends={[
Expand Down Expand Up @@ -118,7 +141,10 @@ it(`should not reverse legend items if chart layout is vertical reversed`, () =>
<Bar
width={500}
height={300}
data={[{ id: 'one', A: 10, B: 13 }, { id: 'two', A: 12, B: 9 }]}
data={[
{ id: 'one', A: 10, B: 13 },
{ id: 'two', A: 12, B: 9 },
]}
keys={['A', 'B']}
layout="vertical"
reverse={true}
Expand Down Expand Up @@ -147,7 +173,10 @@ it(`should not reverse legend items if chart layout is horizontal`, () => {
<Bar
width={500}
height={300}
data={[{ id: 'one', A: 10, B: 13 }, { id: 'two', A: 12, B: 9 }]}
data={[
{ id: 'one', A: 10, B: 13 },
{ id: 'two', A: 12, B: 9 },
]}
keys={['A', 'B']}
layout="horizontal"
legends={[
Expand Down Expand Up @@ -175,7 +204,10 @@ it(`should reverse legend items if chart layout is horizontal reversed`, () => {
<Bar
width={500}
height={300}
data={[{ id: 'one', A: 10, B: 13 }, { id: 'two', A: 12, B: 9 }]}
data={[
{ id: 'one', A: 10, B: 13 },
{ id: 'two', A: 12, B: 9 },
]}
keys={['A', 'B']}
layout="horizontal"
reverse={true}
Expand Down
2 changes: 1 addition & 1 deletion packages/bump/src/bump/Points.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Points = ({ pointComponent, points }) => {
key,
data: point.data,
x: style.x,
y: point.y,
y: style.y,
isActive: point.isActive,
isInactive: point.isInactive,
size: Math.max(style.size, 0),
Expand Down
2 changes: 1 addition & 1 deletion packages/bump/src/bump/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const computeSeries = ({ width, height, data, xPadding, xOuterPadding, yO
y = yScale(datum.y)
}
const point = {
id: `${rawSerie.id}.${datum.x}`,
id: `${rawSerie.id}.${i}`,
serie: rawSerie,
data: datum,
x,
Expand Down
8 changes: 2 additions & 6 deletions packages/chord/src/ChordLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ const ChordLabels = ({ arcs, radius, rotation, getColor }) => {
return (
<text
key={arc.id}
transform={`translate(${textProps.x}, ${textProps.y}) rotate(${
textProps.rotate
})`}
transform={`translate(${textProps.x}, ${textProps.y}) rotate(${textProps.rotate})`}
style={{
...theme.labels.text,
pointerEvents: 'none',
Expand Down Expand Up @@ -69,9 +67,7 @@ const ChordLabels = ({ arcs, radius, rotation, getColor }) => {
return (
<text
key={key}
transform={`translate(${textProps.x}, ${textProps.y}) rotate(${
textProps.rotate
})`}
transform={`translate(${textProps.x}, ${textProps.y}) rotate(${textProps.rotate})`}
style={{
...theme.labels.text,
pointerEvents: 'none',
Expand Down
10 changes: 8 additions & 2 deletions packages/circle-packing/tests/Bubble.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ const sampleData = {
},
{
id: 'line',
children: [{ id: 'svg', value: 43 }, { id: 'canvas', value: 27 }],
children: [
{ id: 'svg', value: 43 },
{ id: 'canvas', value: 27 },
],
},
{
id: 'pie',
children: [{ id: 'svg', value: 17 }, { id: 'canvas', value: 23 }],
children: [
{ id: 'svg', value: 17 },
{ id: 'canvas', value: 23 },
],
},
],
}
Expand Down
8 changes: 2 additions & 6 deletions packages/colors/src/ordinalColorScale.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export const getOrdinalColorScale = (instruction, identity) => {
(instruction.size < 3 || instruction.size > 11)
) {
throw new Error(
`Invalid size '${instruction.size}' for diverging color scheme '${
instruction.scheme
}', must be between 3~11`
`Invalid size '${instruction.size}' for diverging color scheme '${instruction.scheme}', must be between 3~11`
)
}

Expand All @@ -81,9 +79,7 @@ export const getOrdinalColorScale = (instruction, identity) => {
(instruction.size < 3 || instruction.size > 9)
) {
throw new Error(
`Invalid size '${instruction.size}' for sequential color scheme '${
instruction.scheme
}', must be between 3~9`
`Invalid size '${instruction.size}' for sequential color scheme '${instruction.scheme}', must be between 3~9`
)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/colors/tests/inheritedColor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ describe(`from datum`, () => {
it(`should be able to chain several modifiers on inherited color`, () => {
const getColor = getInheritedColorGenerator({
from: 'color',
modifiers: [['darker', 2], ['opacity', 0.5]],
modifiers: [
['darker', 2],
['opacity', 0.5],
],
})

const expectedColor = rgb('#ff0099').darker(2)
Expand Down
16 changes: 4 additions & 12 deletions packages/colors/tests/ordinalColorScale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,14 @@ it(`should throw if trying to generate a scale from diverging colors with a size
expect(() => {
getOrdinalColorScale({ scheme: divergingColorSchemeIds[0], size: 2 })
}).toThrow(
`Invalid size '2' for diverging color scheme '${
divergingColorSchemeIds[0]
}', must be between 3~11`
`Invalid size '2' for diverging color scheme '${divergingColorSchemeIds[0]}', must be between 3~11`
)
})
it(`should throw if trying to generate a scale from diverging colors with a size greater than 11`, () => {
expect(() => {
getOrdinalColorScale({ scheme: divergingColorSchemeIds[0], size: 13 })
}).toThrow(
`Invalid size '13' for diverging color scheme '${
divergingColorSchemeIds[0]
}', must be between 3~11`
`Invalid size '13' for diverging color scheme '${divergingColorSchemeIds[0]}', must be between 3~11`
)
})

Expand All @@ -100,18 +96,14 @@ it(`should throw if trying to generate a scale from sequential colors with a siz
expect(() => {
getOrdinalColorScale({ scheme: sequentialColorSchemeIds[0], size: 2 })
}).toThrow(
`Invalid size '2' for sequential color scheme '${
sequentialColorSchemeIds[0]
}', must be between 3~9`
`Invalid size '2' for sequential color scheme '${sequentialColorSchemeIds[0]}', must be between 3~9`
)
})
it(`should throw if trying to generate a scale from sequential colors with a size greater than 9`, () => {
expect(() => {
getOrdinalColorScale({ scheme: sequentialColorSchemeIds[0], size: 11 })
}).toThrow(
`Invalid size '11' for sequential color scheme '${
sequentialColorSchemeIds[0]
}', must be between 3~9`
`Invalid size '11' for sequential color scheme '${sequentialColorSchemeIds[0]}', must be between 3~9`
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ const CartesianMarkersItem = ({
})
legendNode = (
<text
transform={`translate(${legendProps.x}, ${legendProps.y}) rotate(${
legendProps.rotation
})`}
transform={`translate(${legendProps.x}, ${legendProps.y}) rotate(${legendProps.rotation})`}
textAnchor={legendProps.textAnchor}
dominantBaseline="central"
style={textStyle}
Expand Down
5 changes: 4 additions & 1 deletion packages/core/tests/lib/getLabelGenerator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ describe('getLabelGenerator()', () => {
})

it(`should handle custom access & formatting functions`, () => {
const getLabel = getLabelGenerator(d => d.value[1], v => v + 10)
const getLabel = getLabelGenerator(
d => d.value[1],
v => v + 10
)
expect(getLabel({ value: [18, 19] })).toBe(29)
})
})
4 changes: 1 addition & 3 deletions packages/core/tests/lib/polar/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ const boundingBoxCases = [
for (let boundingBoxCase of boundingBoxCases) {
const { args, expected } = boundingBoxCase

test(`computeArcBoundingBox() for position ${args[0]}, ${args[1]} with radius ${
args[2]
}, starting at ${args[3]}°, ending at ${args[4]}°`, () => {
test(`computeArcBoundingBox() for position ${args[0]}, ${args[1]} with radius ${args[2]}, starting at ${args[3]}°, ending at ${args[4]}°`, () => {
const box = computeArcBoundingBox(...args)

for (let prop in expected) {
Expand Down
Loading

0 comments on commit d92a965

Please sign in to comment.