Skip to content

Commit

Permalink
Add Negative Y Value Support and Example for Vertical Bar Chart (micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush2303 authored Dec 5, 2024
1 parent 0f490a4 commit f42240c
Show file tree
Hide file tree
Showing 18 changed files with 3,747 additions and 1,302 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "support negative y values in Vertical Bar chart",
"packageName": "@fluentui/react-charting",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 2 additions & 1 deletion packages/charts/react-charting/etc/react-charting.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export interface ICartesianChartProps {
showXAxisLablesTooltip?: boolean;
strokeWidth?: number;
styles?: IStyleFunctionOrObject<ICartesianChartStyleProps, ICartesianChartStyles>;
supportNegativeData?: boolean;
svgProps?: React_2.SVGProps<SVGSVGElement>;
theme?: ITheme;
tickFormat?: string;
Expand Down Expand Up @@ -1043,7 +1044,7 @@ export interface IModifiedCartesianChartProps extends ICartesianChartProps {
createStringYAxis: (yAxisParams: IYAxisParams, dataPoints: string[], isRtl: boolean, barWidth: number | undefined) => ScaleBand<string>;
// Warning: (ae-forgotten-export) The symbol "IYAxisParams" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "IAxisData" needs to be exported by the entry point index.d.ts
createYAxis: (yAxisParams: IYAxisParams, isRtl: boolean, axisData: IAxisData, isIntegralDataset: boolean, useSecondaryYScale?: boolean) => ScaleLinear<number, number, never>;
createYAxis: (yAxisParams: IYAxisParams, isRtl: boolean, axisData: IAxisData, isIntegralDataset: boolean, useSecondaryYScale?: boolean, supportNegativeData?: boolean) => ScaleLinear<number, number, never>;
culture?: string;
customizedCallout?: any;
datasetForXAxisDomain?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4186,12 +4186,12 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
font-family="sans-serif"
font-size="10"
id="yAxisGElementSecondarychart_6"
text-anchor="end"
text-anchor="start"
transform="translate(610, 0)"
>
<path
class="domain"
d="M-6,257.5H0.5V20.5H-6"
d="M6,257.5H0.5V20.5H6"
stroke="currentColor"
/>
<g
Expand All @@ -4201,13 +4201,13 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
0
</text>
Expand All @@ -4219,13 +4219,13 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
25
</text>
Expand All @@ -4237,13 +4237,13 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
50
</text>
Expand All @@ -4255,13 +4255,13 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
75
</text>
Expand All @@ -4273,13 +4273,13 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
100
</text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,23 @@ export class CartesianChartBase extends React.Component<IModifiedCartesianChartP
yAxisPadding: this.props.yAxisPadding,
};

yScaleSecondary = this.props.createYAxis(YAxisParamsSecondary, this._isRtl, axisData, this.isIntegralDataset);
yScaleSecondary = yScaleSecondary = this.props.createYAxis(
YAxisParamsSecondary,
this._isRtl,
axisData,
this.isIntegralDataset,
true,
this.props.supportNegativeData!,
);
}
yScale = this.props.createYAxis(YAxisParams, this._isRtl, axisData, this.isIntegralDataset);
yScale = this.props.createYAxis(
YAxisParams,
this._isRtl,
axisData,
this.isIntegralDataset,
false,
this.props.supportNegativeData!,
);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ export interface ICartesianChartProps {
* @default true
*/
useUTC?: boolean;

/**
* @default false
* Used for enabling negative values in Y axis.
*/
supportNegativeData?: boolean;
}

export interface IYValueHover {
Expand Down Expand Up @@ -651,6 +657,7 @@ export interface IModifiedCartesianChartProps extends ICartesianChartProps {
axisData: IAxisData,
isIntegralDataset: boolean,
useSecondaryYScale?: boolean,
supportNegativeData?: boolean,
) => ScaleLinear<number, number, never>;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5971,12 +5971,12 @@ exports[`Line chart rendering Should render the line chart with secondary Y axis
font-family="sans-serif"
font-size="10"
id="yAxisGElementSecondarychart_9"
text-anchor="end"
text-anchor="start"
transform="translate(610, 0)"
>
<path
class="domain"
d="M-6,257.5H0.5V20.5H-6"
d="M6,257.5H0.5V20.5H6"
stroke="currentColor"
/>
<g
Expand All @@ -5986,13 +5986,13 @@ exports[`Line chart rendering Should render the line chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
0
</text>
Expand All @@ -6004,13 +6004,13 @@ exports[`Line chart rendering Should render the line chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
25
</text>
Expand All @@ -6022,13 +6022,13 @@ exports[`Line chart rendering Should render the line chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
50
</text>
Expand All @@ -6040,13 +6040,13 @@ exports[`Line chart rendering Should render the line chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
75
</text>
Expand All @@ -6058,13 +6058,13 @@ exports[`Line chart rendering Should render the line chart with secondary Y axis
>
<line
stroke="currentColor"
x2="570"
x2="-570"
/>
<text
aria-hidden="true"
dy="0.32em"
fill="currentColor"
x="-10"
x="10"
>
100
</text>
Expand Down
Loading

0 comments on commit f42240c

Please sign in to comment.