Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support single point in area chart #25842

Merged
merged 4 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Support single point in area chart",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -576,16 +576,33 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
onMouseOver={this._onRectMouseMove}
{...points[index]!.lineOptions}
/>
<path
id={`${index}-graph-${this._uniqueIdForGraph}`}
d={area(singleStackedData)!}
fill={this._colors[index]}
opacity={this._opacity[index]}
fillOpacity={this._getOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
/>
{singleStackedData.length === 1 ? (
<circle
id={`${index}-graph-${this._uniqueIdForGraph}`}
cx={xScale(singleStackedData[0].xVal)}
cy={yScale(singleStackedData[0].values[1])}
r={6}
stroke={this._colors[index]}
strokeWidth={3}
fill={this._colors[index]}
opacity={this._opacity[index]}
fillOpacity={this._getOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
/>
) : (
<path
id={`${index}-graph-${this._uniqueIdForGraph}`}
d={area(singleStackedData)!}
fill={this._colors[index]}
opacity={this._opacity[index]}
fillOpacity={this._getOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
/>
)}
</React.Fragment>,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ const chartPoints = {
lineChartData: points,
};

const singlePoint = [
{
legend: 'metaData1',
data: [{ x: 20, y: 50 }],
color: 'red',
},
];
const singleChartPoint = {
chartTitle: 'AreaChart',
lineChartData: singlePoint,
};

describe('AreaChart snapShot testing', () => {
it('renders Areachart correctly', () => {
const component = renderer.create(<AreaChart data={chartPoints} />);
Expand Down Expand Up @@ -86,6 +98,12 @@ describe('AreaChart snapShot testing', () => {
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

it('renders Areachart with single point correctly', () => {
const component = renderer.create(<AreaChart data={singleChartPoint} />);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
});

describe('AreaChart - basic props', () => {
Expand Down
Loading