-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
150 additions
and
28 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
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
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
33 changes: 33 additions & 0 deletions
33
app/subscriber/src/features/my-reports/edit/settings/template/utils/calcAutoSize.ts
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,33 @@ | ||
import { IChartSectionSettingsModel } from 'tno-core'; | ||
|
||
/** | ||
* Determines if the size of the chart will fit the axis labels. | ||
* If not it will generate a new chart section settings. | ||
* @param axisLabelCount The number of axis labels. | ||
* @param chartSectionSettings The chart section settings. | ||
* @param minAxisColumnWidth The minimum size of an axis column (defaults 30). | ||
* @returns Updated chart section settings. | ||
*/ | ||
export const calcAutoSize = ( | ||
axisLabelCount: number, | ||
chartSectionSettings: IChartSectionSettingsModel, | ||
minAxisColumnWidth: number = 30, | ||
) => { | ||
const size = chartSectionSettings.isHorizontal | ||
? chartSectionSettings.width | ||
: chartSectionSettings.height; | ||
if (!size || !axisLabelCount) return chartSectionSettings; | ||
const axisColumnWidth = size / axisLabelCount; | ||
if (axisColumnWidth < minAxisColumnWidth) { | ||
const newSize = minAxisColumnWidth * axisLabelCount; | ||
const width = chartSectionSettings.isHorizontal ? newSize : chartSectionSettings.width; | ||
const height = chartSectionSettings.isHorizontal ? chartSectionSettings.height : newSize; | ||
return { | ||
...chartSectionSettings, | ||
width, | ||
height, | ||
aspectRatio: height ? undefined : chartSectionSettings.aspectRatio, | ||
}; | ||
} | ||
return chartSectionSettings; | ||
}; |
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
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
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
21 changes: 21 additions & 0 deletions
21
app/subscriber/src/features/my-reports/edit/settings/template/utils/shouldResizeChart.ts
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,21 @@ | ||
import { IChartSectionSettingsModel } from 'tno-core'; | ||
|
||
/** | ||
* Determines if the size of the chart will fit the axis labels. | ||
* @param axisLabelCount The number of axis labels. | ||
* @param chartSectionSettings The chart section settings. | ||
* @param minAxisColumnWidth The minimum size of an axis column (defaults 30). | ||
* @returns True if the chart should resize. | ||
*/ | ||
export const shouldResizeChart = ( | ||
axisLabelCount: number, | ||
chartSectionSettings: IChartSectionSettingsModel, | ||
minAxisColumnWidth: number = 30, | ||
) => { | ||
const size = !chartSectionSettings.isHorizontal | ||
? chartSectionSettings.height | ||
: chartSectionSettings.width; | ||
if (!size || !axisLabelCount) return false; | ||
const axisColumnWidth = size / axisLabelCount; | ||
return axisColumnWidth < minAxisColumnWidth; | ||
}; |
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
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
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