forked from elastic/elastic-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(areacharts): fix misaligned rendering props
There was a misalignment between the animated props and the non animated ones that causes the area line to use the fill instead of stroke wrongly rendering the line on the chart. fix elastic#140
- Loading branch information
Showing
2 changed files
with
245 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { buildAreaLineProps, buildAreaPointProps, buildAreaProps } from './area_geometries'; | ||
|
||
describe('[canvas] Area Geometries', () => { | ||
test('can build area point props', () => { | ||
const props = buildAreaPointProps({ | ||
areaIndex: 1, | ||
pointIndex: 2, | ||
x: 10, | ||
y: 20, | ||
radius: 30, | ||
strokeWidth: 2, | ||
color: 'red', | ||
opacity: 0.5, | ||
}); | ||
expect(props).toEqual({ | ||
key: 'area-point-1-2', | ||
x: 10, | ||
y: 20, | ||
radius: 30, | ||
strokeWidth: 2, | ||
strokeEnabled: true, | ||
stroke: 'red', | ||
fill: 'white', | ||
opacity: 0.5, | ||
strokeHitEnabled: false, | ||
perfectDrawEnabled: false, | ||
listening: false, | ||
}); | ||
|
||
const propsNoStroke = buildAreaPointProps({ | ||
areaIndex: 1, | ||
pointIndex: 2, | ||
x: 10, | ||
y: 20, | ||
radius: 30, | ||
strokeWidth: 0, | ||
color: 'red', | ||
opacity: 0.5, | ||
}); | ||
expect(propsNoStroke).toEqual({ | ||
key: 'area-point-1-2', | ||
x: 10, | ||
y: 20, | ||
radius: 30, | ||
strokeWidth: 0, | ||
strokeEnabled: false, | ||
stroke: 'red', | ||
fill: 'white', | ||
opacity: 0.5, | ||
strokeHitEnabled: false, | ||
perfectDrawEnabled: false, | ||
listening: false, | ||
}); | ||
}); | ||
test('can build area path props', () => { | ||
const props = buildAreaProps({ | ||
index: 1, | ||
areaPath: 'M0,0L10,10Z', | ||
color: 'red', | ||
opacity: 0.5, | ||
}); | ||
expect(props).toEqual({ | ||
key: 'area-1', | ||
data: 'M0,0L10,10Z', | ||
fill: 'red', | ||
lineCap: 'round', | ||
lineJoin: 'round', | ||
opacity: 0.5, | ||
strokeHitEnabled: false, | ||
perfectDrawEnabled: false, | ||
listening: false, | ||
}); | ||
}); | ||
test('can build area line path props', () => { | ||
const props = buildAreaLineProps({ | ||
index: 1, | ||
linePath: 'M0,0L10,10Z', | ||
color: 'red', | ||
strokeWidth: 1, | ||
geometryStyle: { | ||
opacity: 0.5, | ||
}, | ||
}); | ||
expect(props).toEqual({ | ||
key: `area-line-1`, | ||
data: 'M0,0L10,10Z', | ||
stroke: 'red', | ||
strokeWidth: 1, | ||
lineCap: 'round', | ||
lineJoin: 'round', | ||
opacity: 0.5, | ||
strokeHitEnabled: false, | ||
perfectDrawEnabled: false, | ||
listening: false, | ||
}); | ||
expect(props.fill).toBeFalsy(); | ||
}); | ||
}); |
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