|
3 | 3 | <br>
|
4 | 4 | <a href="https://vue-data-ui.graphieros.com/"><img width="100%" src="https://github.com/user-attachments/assets/0474eb0e-0918-43e1-9756-30a5a8052d82"></a>
|
5 | 5 |
|
6 |
| - |
7 | 6 | </p>
|
8 | 7 |
|
9 | 8 | # vue-data-ui
|
@@ -895,6 +894,8 @@ import {
|
895 | 894 | lightenColor,
|
896 | 895 | shiftColorHue,
|
897 | 896 | createTSpans,
|
| 897 | + getCumulativeAverage, |
| 898 | + getCumulativeMedian, |
898 | 899 | } from "vue-data-ui";
|
899 | 900 | ```
|
900 | 901 |
|
@@ -966,6 +967,60 @@ const textContent = createTSpans({
|
966 | 967 | />
|
967 | 968 | ```
|
968 | 969 |
|
| 970 | +### getCumulativeAverage |
| 971 | + |
| 972 | +```js |
| 973 | +import { getCumulativeAverage } from "vue-data-ui"; |
| 974 | + |
| 975 | +// simple usage |
| 976 | +const arr = [0, 1, 2, 3, 4]; |
| 977 | +const cumulativeAvg = getCumulativeAverage({ values: arr }); |
| 978 | + |
| 979 | +// Ignore invalid values entirely |
| 980 | +const arrWithInvalid = [1, null, 2, Infinity, NaN, undefined]; |
| 981 | +const cumulativeAvgNoInvalid = getCumulativeAverage({ |
| 982 | + values: arrWithInvalid, |
| 983 | + config: { |
| 984 | + keepInvalid: false, |
| 985 | + }, |
| 986 | +}); |
| 987 | + |
| 988 | +// Convert invalid values to zero |
| 989 | +const cumulativeAvgZeroed = getCumulativeAverage({ |
| 990 | + values: arrWithInvalid, |
| 991 | + config: { |
| 992 | + convertInvalidToZero: true, |
| 993 | + }, |
| 994 | +}); |
| 995 | +``` |
| 996 | + |
| 997 | +### getCumulativeMedian |
| 998 | + |
| 999 | +```js |
| 1000 | +import { getCumulativeMedian } from "vue-data-ui"; |
| 1001 | + |
| 1002 | +// simple usage |
| 1003 | +const arr = [0, 1, 2, 3, 4]; |
| 1004 | +const cumulativeMed = getCumulativeMedian({ values: arr }); |
| 1005 | + |
| 1006 | +// Ignore invalid values entirely |
| 1007 | +const arrWithInvalid = [1, null, 2, Infinity, NaN, undefined]; |
| 1008 | +const cumulativeMedNoInvalid = getCumulativeMedian({ |
| 1009 | + values: arrWithInvalid, |
| 1010 | + config: { |
| 1011 | + keepInvalid: false, |
| 1012 | + }, |
| 1013 | +}); |
| 1014 | + |
| 1015 | +// Convert invalid values to zero |
| 1016 | +const cumulativeMedZeroed = getCumulativeMedian({ |
| 1017 | + values: arrWithInvalid, |
| 1018 | + config: { |
| 1019 | + convertInvalidToZero: true, |
| 1020 | + }, |
| 1021 | +}); |
| 1022 | +``` |
| 1023 | + |
969 | 1024 | ## PDF generation
|
970 | 1025 |
|
971 | 1026 | This package requires jspdf as a peer dependency. Please install it in your project if you intend on using the PDF printing feature.
|
0 commit comments