Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-webcomponents-rc-6
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusNotheis authored Apr 1, 2020
2 parents 31c28f8 + e0ea6d6 commit 64b9951
Show file tree
Hide file tree
Showing 21 changed files with 172 additions and 123 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.9.0-rc.8](https://github.com/SAP/ui5-webcomponents-react/compare/v0.9.0-rc.7...v0.9.0-rc.8) (2020-04-01)


### Bug Fixes

* **AnalyticalTable:** avoid scrollbar overlaying last column ([#396](https://github.com/SAP/ui5-webcomponents-react/issues/396)) ([fb282c7](https://github.com/SAP/ui5-webcomponents-react/commit/fb282c7e453fdf3edfab23053e59bfc8879b7ad5))





# [0.9.0-rc.7](https://github.com/SAP/ui5-webcomponents-react/compare/v0.9.0-rc.6...v0.9.0-rc.7) (2020-03-31)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.9.0-rc.7",
"version": "0.9.0-rc.8",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
8 changes: 8 additions & 0 deletions packages/charts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.9.0-rc.8](https://github.com/SAP/ui5-webcomponents-react/compare/v0.9.0-rc.7...v0.9.0-rc.8) (2020-04-01)

**Note:** Version bump only for package @ui5/webcomponents-react-charts





# [0.9.0-rc.7](https://github.com/SAP/ui5-webcomponents-react/compare/v0.9.0-rc.6...v0.9.0-rc.7) (2020-03-31)


Expand Down
2 changes: 1 addition & 1 deletion packages/charts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ui5/webcomponents-react-charts",
"version": "0.9.0-rc.7",
"version": "0.9.0-rc.8",
"description": "Charts for ui5-webcomponents-react",
"main": "index.cjs.js",
"module": "index.esm.js",
Expand Down
25 changes: 13 additions & 12 deletions packages/charts/src/components/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
strokeOpacity: 1,
fillOpacity: 1,
stacked: false,
dataLabel: false,
dataLabel: true,
referenceLine: {
label: undefined,
value: undefined,
Expand Down Expand Up @@ -117,9 +117,18 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
true
);

const marginChart = useChartMargin(dataset, yAxisFormatter, labelKey, chartConfig.margin, true);
const marginChart = useChartMargin(
dataset,
yAxisFormatter,
labelKey,
chartConfig.margin,
true,
secondaryDimensionKey,
chartConfig.zoomingTool
);

const XAxisLabel = useAxisLabel(xAxisFormatter, chartConfig.xAxisUnit);
const YAxisLabel = useAxisLabel(yAxisFormatter, chartConfig.yAxisUnit, true);
const SecondaryDimensionLabel = useSecondaryDimensionLabel(true, yAxisFormatter);

return (
Expand All @@ -143,10 +152,10 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
/>
{(chartConfig.xAxisVisible ?? true) && <XAxis interval={0} type="number" tick={XAxisLabel} />}
<YAxis
tickFormatter={yAxisFormatter}
unit={chartConfig.yAxisUnit}
axisLine={chartConfig.yAxisVisible ?? false}
tickLine={false}
tick={YAxisLabel}
type="category"
dataKey={labelKey}
interval={0}
Expand Down Expand Up @@ -178,15 +187,7 @@ const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<a
onClick={onDataPointClickInternal}
/>
))}
{!noLegend && (
<Legend
wrapperStyle={{
paddingBottom: 20
}}
verticalAlign={chartConfig.legendPosition ?? 'top'}
onClick={onItemLegendClick}
/>
)}
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition ?? 'top'} onClick={onItemLegendClick} />}
{chartConfig.referenceLine && (
<ReferenceLine
stroke={chartConfig.referenceLine.color}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const defaultStory = () => (
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
width={text('width', '97%')}
width={text('width', '100%')}
height={text('height', '95vh')}
loading={boolean('loading', false)}
noLegend={boolean('noLegend', false)}
Expand Down Expand Up @@ -141,8 +141,8 @@ export const withSecondardDimension = () => (
labelKey={'name'}
secondaryDimensionKey={'dimension'}
color={'lightblue'}
width={text('width', '95%')}
height={text('height', '70vh')}
width={'100%'}
height={'60vh'}
chartConfig={{ dataLabel: true, barSize: 20 }}
/>
);
Expand Down
15 changes: 4 additions & 11 deletions packages/charts/src/components/ColumnChart/ColumnChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const ColumnChart: FC<ColumnChartProps> = forwardRef((props: ColumnChartProps, r
strokeOpacity: 1,
fillOpacity: 1,
stacked: false,
dataLabel: false,
dataLabel: true,
secondYAxis: {
dataKey: undefined,
name: undefined,
Expand Down Expand Up @@ -131,7 +131,8 @@ const ColumnChart: FC<ColumnChartProps> = forwardRef((props: ColumnChartProps, r
yAxisFormatter,
chartConfig.margin,
false,
secondaryDimensionKey
secondaryDimensionKey,
chartConfig.zoomingTool
);

return (
Expand Down Expand Up @@ -198,15 +199,7 @@ const ColumnChart: FC<ColumnChartProps> = forwardRef((props: ColumnChartProps, r
onClick={onDataPointClickInternal}
/>
))}
{!noLegend && (
<Legend
wrapperStyle={{
paddingBottom: 20
}}
verticalAlign={chartConfig.legendPosition ?? 'top'}
onClick={onItemLegendClick}
/>
)}
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition ?? 'top'} onClick={onItemLegendClick} />}
{chartConfig.referenceLine && (
<ReferenceLine
stroke={chartConfig.referenceLine.color}
Expand Down
15 changes: 4 additions & 11 deletions packages/charts/src/components/ComposedChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
yAxisColor: ThemingParameters.sapList_BorderColor,
legendPosition: 'top',
zoomingTool: false,
dataLabel: false,
dataLabel: true,
barSize: undefined,
barGap: undefined,
secondYAxis: {
Expand Down Expand Up @@ -180,7 +180,8 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
labelKey,
chartConfig.margin,
false,
secondaryDimensionKey
secondaryDimensionKey,
chartConfig.zoomingTool
);

return (
Expand Down Expand Up @@ -240,15 +241,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
/>
)}
<Tooltip />
{!noLegend && (
<Legend
onClick={onItemLegendClick}
verticalAlign={chartConfig.legendPosition ?? 'top'}
wrapperStyle={{
paddingBottom: 20
}}
/>
)}
{!noLegend && <Legend onClick={onItemLegendClick} verticalAlign={chartConfig.legendPosition ?? 'top'} />}
{elements?.map((config, index) => {
const {
type,
Expand Down
2 changes: 1 addition & 1 deletion packages/charts/src/components/DonutChart/DonutChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DonutChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref) =>
const {
chartConfig = {
legendPosition: 'bottom',
dataLabel: false,
dataLabel: true,
paddingAngle: 0,
innerRadius: undefined
}
Expand Down
15 changes: 4 additions & 11 deletions packages/charts/src/components/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const LineChart: FC<LineChartProps> = forwardRef((props: LineChartProps, ref: Re
strokeWidth: 1,
zoomingTool: false,
strokeOpacity: 1,
dataLabel: false,
dataLabel: true,
xAxisUnit: '',
yAxisUnit: '',
secondYAxis: {
Expand Down Expand Up @@ -116,7 +116,8 @@ const LineChart: FC<LineChartProps> = forwardRef((props: LineChartProps, ref: Re
labelKey,
chartConfig.margin,
false,
secondaryDimensionKey
secondaryDimensionKey,
chartConfig.zoomingTool
);

return (
Expand Down Expand Up @@ -181,15 +182,7 @@ const LineChart: FC<LineChartProps> = forwardRef((props: LineChartProps, ref: Re
activeDot={{ onClick: onDataPointClickInternal }}
/>
))}
{!noLegend && (
<Legend
wrapperStyle={{
paddingBottom: 20
}}
verticalAlign={chartConfig.legendPosition ?? 'top'}
onClick={onItemLegendClick}
/>
)}
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition ?? 'top'} onClick={onItemLegendClick} />}
{chartConfig.referenceLine && (
<ReferenceLine
stroke={chartConfig.referenceLine.color}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ export const renderStory = () => {
onDataPointClick={action('onDataPointClick')}
onLegendClick={action('onLegendClick')}
dataset={complexDataSet}
width={'95%'}
height={'40vh'}
loading={true}
width={'100%'}
height={'60vh'}
/>
);
};
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/components/PieChart/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
strokeWidth: 1,
zoomingTool: false,
strokeOpacity: 1,
dataLabel: false,
dataLabel: true,
paddingAngle: 0,
innerRadius: undefined
},
Expand All @@ -57,7 +57,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a

const chartRef = useConsolidatedRef<any>(ref);

const currentDataKeys = useResolveDataKeys(dataKeys, labelKey, dataset);
const currentDataKeys = useResolveDataKeys(dataKeys, labelKey, dataset, undefined);

const onItemLegendClick = useLegendItemClick(onLegendClick, () => currentDataKeys[0]);

Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/components/RadarChart/RadarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const RadarChart: FC<RadarChartProps> = forwardRef((props: RadarChartProps, ref:
chartConfig = {
margin: {},
legendPosition: 'bottom',
dataLabel: false,
dataLabel: true,
polarGridType: 'circle'
},
style,
Expand All @@ -58,7 +58,7 @@ const RadarChart: FC<RadarChartProps> = forwardRef((props: RadarChartProps, ref:

const chartRef = useConsolidatedRef<any>(ref);

const currentDataKeys = useResolveDataKeys(dataKeys, labelKey, dataset);
const currentDataKeys = useResolveDataKeys(dataKeys, labelKey, dataset, undefined);

const onItemLegendClick = useLegendItemClick(onLegendClick);

Expand Down
10 changes: 5 additions & 5 deletions packages/charts/src/hooks/useChartMargin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { getTextWidth } from '../util/Utils';

export const useChartMargin = (dataset, formatter, labelKey, margin, bar?, secondaryDimension?) =>
export const useChartMargin = (dataset, formatter, labelKey, margin, bar?, secondaryDimension?, zoomingTool?) =>
useMemo(() => {
let marginLeft = 0;
if (dataset && bar && typeof margin?.left !== 'number') {
Expand All @@ -13,9 +13,9 @@ export const useChartMargin = (dataset, formatter, labelKey, margin, bar?, secon
);
}
return {
right: margin?.right ?? 30,
top: margin?.top ?? 40,
bottom: margin?.bottom ?? secondaryDimension ? 100 : 30,
left: margin?.left ?? bar ? marginLeft / 2 : secondaryDimension ? 20 : 0
right: margin?.right ?? 60,
top: margin?.top ?? zoomingTool ? 40 : 10,
bottom: margin?.bottom ?? (!bar && secondaryDimension) ? 100 : 30,
left: margin?.left ?? bar ? (secondaryDimension ? marginLeft : marginLeft / 2) : secondaryDimension ? 20 : 0
};
}, [dataset, labelKey, margin]);
13 changes: 10 additions & 3 deletions packages/charts/src/hooks/useLabelElements.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { useCallback, useMemo } from 'react';
import { DataLabel, SecondaryDimensionTicksXAxis, SecondaryDimensionTicksYAxis } from '../internal/CustomElements';
import {
DataLabel,
SecondaryDimensionTicksXAxis,
SecondaryDimensionTicksYAxis,
YAxisTicks
} from '../internal/CustomElements';
import { ThemingParameters } from '@ui5/webcomponents-react-base/lib/ThemingParameters';
import { renderAxisTicks } from '../util/Utils';

Expand All @@ -25,10 +30,12 @@ export const usePieDataLabel = (dataLabel, dataLabelCustomElement, dataLabelForm
: false;
}, [dataLabelFormatter, dataLabelCustomElement, dataLabel]);

export const useAxisLabel = (AxisFormatter, AxisUnit) => {
export const useAxisLabel = (AxisFormatter, AxisUnit, yAxis?) => {
return useCallback(
(labelProps) => {
return renderAxisTicks(labelProps, AxisFormatter, AxisUnit);
return yAxis
? YAxisTicks(labelProps, AxisFormatter, AxisUnit)
: renderAxisTicks(labelProps, AxisFormatter, AxisUnit);
},
[AxisFormatter, AxisUnit]
);
Expand Down
21 changes: 16 additions & 5 deletions packages/charts/src/internal/CustomElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,27 @@ export const XAxisTicks = (props, formatter, unit = '', rotate) => {
);
};

export const YAxisTicks = (props, formatter, unit = '') => {
const { x, y, payload } = props;
const tickValue =
formatter(payload.value).length > 10 ? `${formatter(payload.value).slice(0, 13)}...` : formatter(payload.value);
return (
<g transform={`translate(${x},${y + 3})`}>
<text fill={ThemingParameters.sapNeutralBorderColor} textAnchor={'end'}>
{`${tickValue}${unit}`}
</text>
</g>
);
};

export const SecondaryDimensionTicksXAxis = (props) => {
const { x, y, payload } = props;

const tickValue = payload.value.length > 12 && globalRotate ? payload.value.slice(0, 12) + '...' : payload.value;
const dy = globalRotate ? 40 : 10;
const dy = globalRotate ? 40 : 0;

return (
<g transform={`translate(${x},${y + dy})`}>
{' '}
<text fill={ThemingParameters.sapNeutralBorderColor}>|</text>
<text
fill={ThemingParameters.sapNeutralBorderColor}
Expand All @@ -52,9 +64,8 @@ export const SecondaryDimensionTicksYAxis = (props, yAxisFormatter) => {
const tickValue = yAxisFormatter(payload.value);

return (
<g transform={`translate(${x - 90},${y})`}>
{' '}
<text fill={ThemingParameters.sapNeutralBorderColor} textAnchor={'start'}>
<g transform={`translate(${x - 35},${y})`}>
<text fill={ThemingParameters.sapNeutralBorderColor} transform={'rotate(-35)'} textAnchor={'end'}>
{`${tickValue}`}
</text>
</g>
Expand Down
Loading

0 comments on commit 64b9951

Please sign in to comment.