-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add support for big number in the card and chart components #85
base: main
Are you sure you want to change the base?
Changes from 3 commits
b407083
9d2b48c
62383d1
c409144
c127fed
5e29cd9
6b97cee
fd57f77
214a9f5
8ec9519
15022ce
87758d6
4caf10c
e52a41c
0b6a4ef
c1c8485
3fe31b4
af78794
861ce6c
949c278
d905d37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ import { | |
QueryViewerTrendPeriod | ||
} from "@genexus/reporting-api"; | ||
import { fromDateToString, fromStringToDateISO } from "../../../utils/date"; | ||
import { GxBigNumber } from "@genexus/web-standard-functions/types/gxbignumber"; | ||
import { divide } from "@genexus/web-standard-functions/math/divide"; | ||
import { toStringBigNumber } from "@genexus/web-standard-functions/bigNumber/toString"; | ||
import { multiply } from "@genexus/web-standard-functions/math/multiply"; | ||
|
||
export type RegressionSeries = { | ||
LinearRegression: { | ||
|
@@ -302,13 +306,15 @@ const showDataAsMapping: { | |
// @todo Complete the implementation of this function by comparing it to the Web implementation | ||
export function valueOrPercentage( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
showDataAs: QueryViewerShowDataAs, | ||
value: number, | ||
value: GxBigNumber, | ||
datum: QueryViewerServiceMetaDataData | ||
) { | ||
const percentage = (value * 100) / datum.targetValue; | ||
const multiplication = multiply(value, 100); | ||
const percentage = divide(multiplication, datum.targetValue); | ||
|
||
return showDataAsMapping[showDataAs]({ | ||
value: value.toFixed(2), | ||
percentage: percentage.toFixed(2) + "%" | ||
value: toStringBigNumber(value, new GxBigNumber(), new GxBigNumber()), | ||
percentage: | ||
toStringBigNumber(percentage, new GxBigNumber(), new GxBigNumber()) + "%" | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,9 @@ import { | |
PaneOptions, | ||
PlotOptions, | ||
PointMarkerOptionsObject, | ||
SeriesLineOptions | ||
SeriesLineOptions, | ||
// ExtremesObject, | ||
// SeriesLineOptions | ||
, | ||
SeriesOptionsType, | ||
SubtitleOptions, | ||
TooltipFormatterContextObject, | ||
|
@@ -53,6 +52,7 @@ import { | |
getChartGroup | ||
} from "./chart-utils"; | ||
import { ChartMetadataAndData, XAxisDataType } from "./processDataAndMetadata"; | ||
import { GxBigNumber } from "@genexus/web-standard-functions/types/gxbignumber"; | ||
|
||
const DEFAULT_CHART_SPACING = 10; | ||
export const HOURS_PER_DAY = 24; | ||
|
@@ -1524,7 +1524,7 @@ function groupPoints( | |
dateStr: null, | ||
name: null | ||
}; | ||
let pointAdd: { x: string; y: number; name: string }; | ||
let pointAdd: { x: string; y: GxBigNumber; name: string }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
let currentYValues: number[] = []; | ||
let currentYQuantities: number[] = []; | ||
const points = []; | ||
|
@@ -1566,7 +1566,11 @@ function groupPoints( | |
} else { | ||
pointAdd = { | ||
x: lastStartPoint.dateStr, | ||
y: aggregate(aggregation, currentYValues, currentYQuantities), | ||
y: aggregate( | ||
aggregation, | ||
currentYValues.map(value => new GxBigNumber(value)), | ||
currentYQuantities | ||
), | ||
name: lastStartPoint.name | ||
}; | ||
points.push(pointAdd); | ||
|
@@ -1578,7 +1582,11 @@ function groupPoints( | |
if (currentYValues.length > 0 && currentYQuantities.length > 0) { | ||
pointAdd = { | ||
x: lastStartPoint.dateStr, | ||
y: aggregate(aggregation, currentYValues, currentYQuantities), | ||
y: aggregate( | ||
aggregation, | ||
currentYValues.map(value => new GxBigNumber(value)), | ||
currentYQuantities | ||
), | ||
name: lastStartPoint.name | ||
}; | ||
points.push(pointAdd); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import { | |
parseNumericPicture | ||
} from "../../../utils/general"; | ||
import { ChartTypes, IS_CHART_TYPE, isDatetimeXAxis } from "./chart-types"; | ||
import { GxBigNumber } from "@genexus/web-standard-functions/types/gxbignumber"; | ||
|
||
export type ChartMetadataAndData = { | ||
Categories: QueryViewerChartCategories; | ||
|
@@ -512,7 +513,7 @@ function aggregatePoints(chartSerie: QueryViewerChartSerie) { | |
}); | ||
const value = aggregate( | ||
chartSerie.Aggregation, | ||
currentYValues, | ||
currentYValues.map(val => new GxBigNumber(val)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
currentYQuantities | ||
).toString(); | ||
chartSerie.Points = [{ Value: value, Value_N: value, Value_D: "1" }]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a peer dependency to not force the version in this repo. Also, this should point to
@genexus/web-standard-functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I did this because I understood that could be necesary to modify some web-standard-function code before start working, but actually it wasn't so I will remove that. Thanks!