Skip to content

Commit

Permalink
Make literal scales honor the values provided via props (#287)
Browse files Browse the repository at this point in the history
* Populate literal scales with the value
* Better testing for line styles
* Added test for literal property
  • Loading branch information
akindr authored and apercu committed Mar 3, 2017
1 parent 37c76f5 commit 64e87fe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/scales-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function _createScaleObjectForValue(attr, value, type) {
return {
type: 'literal',
domain: [],
range: [],
range: [value],
distance: 0,
attr,
baseValue: undefined,
Expand Down
20 changes: 20 additions & 0 deletions tests/components/line-series-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,23 @@ test('LineSeries: Showcase Example - LineMarkSeries', t => {
});
t.end();
});

test('LineSeries: Line Styling', t => {
const $ = mount(
<XYPlot width={300} height={300}>
<LineSeries
{...LINE_PROPS}
opacity={0.5}
strokeWidth="3px"
stroke="rgb(255, 255, 255)"
/>
</XYPlot>
);

const lineStyle = $.find('.rv-xy-plot__series path').prop('style');

t.equal(lineStyle.opacity, 0.5, 'should render an opaque line');
t.equal(lineStyle.strokeWidth, '3px', 'should honor stroke width');
t.equal(lineStyle.stroke, 'rgb(255, 255, 255)', 'should honor stroke');
t.end();
});
3 changes: 3 additions & 0 deletions tests/utils/scales-utils-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ test('scales-utils #getAttributeValue ', t => {
// with props
result = getAttributeValue({x: 10}, 'x');
t.equal(result, 10, 'The value should be returned');
// with props including a scale type
result = getAttributeValue({opacity: 0.5, opacityType: 'literal'}, 'opacity');
t.equal(result, 0.5, 'The value should be returned');
t.end();
});

Expand Down

0 comments on commit 64e87fe

Please sign in to comment.