@formant/ava 3.4.1-formant
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/dist/ava.min.js +1 -0
- package/esm/advisor/advise-pipeline/advicesForChart.js +68 -0
- package/esm/advisor/advise-pipeline/data-to-advices.js +241 -0
- package/esm/advisor/advise-pipeline/index.js +1 -0
- package/esm/advisor/advise-pipeline/spec-mapping.js +500 -0
- package/esm/advisor/advisor.js +35 -0
- package/esm/advisor/constants.js +13 -0
- package/esm/advisor/index.js +2 -0
- package/esm/advisor/lint-pipeline/check-rules.js +43 -0
- package/esm/advisor/lint-pipeline/getChartType.js +109 -0
- package/esm/advisor/lint-pipeline/index.js +0 -0
- package/esm/advisor/lint-pipeline/lintRules.js +32 -0
- package/esm/advisor/ruler/index.js +74 -0
- package/esm/advisor/ruler/rules/aggregation-single-row.js +21 -0
- package/esm/advisor/ruler/rules/all-can-be-table.js +17 -0
- package/esm/advisor/ruler/rules/bar-series-qty.js +36 -0
- package/esm/advisor/ruler/rules/bar-without-axis-min.js +41 -0
- package/esm/advisor/ruler/rules/constants.js +6 -0
- package/esm/advisor/ruler/rules/data-check.js +40 -0
- package/esm/advisor/ruler/rules/data-field-qty.js +26 -0
- package/esm/advisor/ruler/rules/diff-pie-sector.js +33 -0
- package/esm/advisor/ruler/rules/index.js +68 -0
- package/esm/advisor/ruler/rules/landscape-or-portrait.js +40 -0
- package/esm/advisor/ruler/rules/limit-series.js +47 -0
- package/esm/advisor/ruler/rules/line-field-time-ordinal.js +25 -0
- package/esm/advisor/ruler/rules/no-redundant-field.js +32 -0
- package/esm/advisor/ruler/rules/nominal-enum-combinatorial.js +54 -0
- package/esm/advisor/ruler/rules/purpose-check.js +27 -0
- package/esm/advisor/ruler/rules/series-qty-limit.js +34 -0
- package/esm/advisor/ruler/rules/x-axis-line-fading.js +41 -0
- package/esm/advisor/ruler/types.js +1 -0
- package/esm/advisor/ruler/utils.js +54 -0
- package/esm/advisor/types.js +1 -0
- package/esm/advisor/utils/clone.js +32 -0
- package/esm/advisor/utils/compare.js +14 -0
- package/esm/advisor/utils/computeScore.js +25 -0
- package/esm/advisor/utils/deep-mix.js +76 -0
- package/esm/advisor/utils/hasSubset.js +3 -0
- package/esm/advisor/utils/index.js +8 -0
- package/esm/advisor/utils/inferDataType.js +70 -0
- package/esm/advisor/utils/intersects.js +3 -0
- package/esm/advisor/utils/isNil.js +4 -0
- package/esm/ckb/base.js +1310 -0
- package/esm/ckb/ckb.js +55 -0
- package/esm/ckb/constants.js +197 -0
- package/esm/ckb/i18n/index.js +23 -0
- package/esm/ckb/i18n/types.js +1 -0
- package/esm/ckb/i18n/zh-CN.js +525 -0
- package/esm/ckb/index.js +14 -0
- package/esm/ckb/types.js +1 -0
- package/esm/common/types.js +1 -0
- package/esm/data/analysis/field/index.js +336 -0
- package/esm/data/analysis/field/types.js +1 -0
- package/esm/data/analysis/graph/index.js +170 -0
- package/esm/data/analysis/graph/types.js +1 -0
- package/esm/data/analysis/index.js +1 -0
- package/esm/data/analysis/types.js +1 -0
- package/esm/data/dataset/field/baseFrame.js +76 -0
- package/esm/data/dataset/field/dataFrame.js +556 -0
- package/esm/data/dataset/field/index.js +3 -0
- package/esm/data/dataset/field/series.js +149 -0
- package/esm/data/dataset/field/types.js +1 -0
- package/esm/data/dataset/field/utils.js +58 -0
- package/esm/data/dataset/graph/index.js +186 -0
- package/esm/data/dataset/graph/types.js +1 -0
- package/esm/data/dataset/graph/utils.js +15 -0
- package/esm/data/dataset/index.js +1 -0
- package/esm/data/dataset/types.js +1 -0
- package/esm/data/index.js +5 -0
- package/esm/data/statistics/IQR.js +49 -0
- package/esm/data/statistics/base.js +248 -0
- package/esm/data/statistics/bayesian.js +25 -0
- package/esm/data/statistics/buishand-u.js +19 -0
- package/esm/data/statistics/caches.js +28 -0
- package/esm/data/statistics/cdf.js +25 -0
- package/esm/data/statistics/constants.js +12 -0
- package/esm/data/statistics/index.js +7 -0
- package/esm/data/statistics/lowess.js +80 -0
- package/esm/data/statistics/mannkendall-test.js +50 -0
- package/esm/data/statistics/maxabs.js +9 -0
- package/esm/data/statistics/pcorrtest.js +76 -0
- package/esm/data/statistics/pettitt-test.js +33 -0
- package/esm/data/statistics/quantile.js +56 -0
- package/esm/data/statistics/types.js +1 -0
- package/esm/data/statistics/vector.js +67 -0
- package/esm/data/statistics/window.js +55 -0
- package/esm/data/types.js +2 -0
- package/esm/data/utils/common.js +58 -0
- package/esm/data/utils/index.js +5 -0
- package/esm/data/utils/isType/constants.js +24 -0
- package/esm/data/utils/isType/index.js +2 -0
- package/esm/data/utils/isType/isDateString.js +104 -0
- package/esm/data/utils/isType/isType.js +78 -0
- package/esm/index.js +11 -0
- package/esm/insight/algorithms/base/compare.js +40 -0
- package/esm/insight/algorithms/categoryOutlier.js +4 -0
- package/esm/insight/algorithms/changePoint.js +10 -0
- package/esm/insight/algorithms/index.js +3 -0
- package/esm/insight/algorithms/trendDirection.js +4 -0
- package/esm/insight/chart/constants.js +25 -0
- package/esm/insight/chart/generator/homogeneous.js +70 -0
- package/esm/insight/chart/generator/index.js +2 -0
- package/esm/insight/chart/generator/insights.js +16 -0
- package/esm/insight/chart/index.js +4 -0
- package/esm/insight/chart/strategy/augmentedMarks/categoryOutlier.js +30 -0
- package/esm/insight/chart/strategy/augmentedMarks/changePoint.js +42 -0
- package/esm/insight/chart/strategy/augmentedMarks/correlation.js +6 -0
- package/esm/insight/chart/strategy/augmentedMarks/homogeneous.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/index.js +8 -0
- package/esm/insight/chart/strategy/augmentedMarks/lowVariance.js +23 -0
- package/esm/insight/chart/strategy/augmentedMarks/majority.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +82 -0
- package/esm/insight/chart/strategy/augmentedMarks/trend.js +26 -0
- package/esm/insight/chart/strategy/chart.js +45 -0
- package/esm/insight/chart/strategy/commonMarks/areaMark.js +12 -0
- package/esm/insight/chart/strategy/commonMarks/index.js +5 -0
- package/esm/insight/chart/strategy/commonMarks/intervalMark.js +14 -0
- package/esm/insight/chart/strategy/commonMarks/lineMark.js +34 -0
- package/esm/insight/chart/strategy/commonMarks/pointMark.js +17 -0
- package/esm/insight/chart/strategy/commonMarks/textMark.js +28 -0
- package/esm/insight/chart/strategy/index.js +4 -0
- package/esm/insight/chart/strategy/viewSpec.js +16 -0
- package/esm/insight/chart/types.js +1 -0
- package/esm/insight/chart/utils.js +4 -0
- package/esm/insight/constant.js +21 -0
- package/esm/insight/index.js +5 -0
- package/esm/insight/insights/checkers.js +97 -0
- package/esm/insight/insights/extractors/categoryOutlier.js +90 -0
- package/esm/insight/insights/extractors/changePoint.js +55 -0
- package/esm/insight/insights/extractors/correlation.js +38 -0
- package/esm/insight/insights/extractors/homogeneous.js +98 -0
- package/esm/insight/insights/extractors/lowVariance.js +49 -0
- package/esm/insight/insights/extractors/majority.js +66 -0
- package/esm/insight/insights/extractors/timeSeriesOutlier.js +61 -0
- package/esm/insight/insights/extractors/trend.js +49 -0
- package/esm/insight/insights/index.js +28 -0
- package/esm/insight/insights/util.js +77 -0
- package/esm/insight/narrative/factory.js +22 -0
- package/esm/insight/narrative/index.js +14 -0
- package/esm/insight/narrative/strategy/base.js +6 -0
- package/esm/insight/narrative/strategy/categoryOutlier.js +74 -0
- package/esm/insight/narrative/strategy/changePoint.js +52 -0
- package/esm/insight/narrative/strategy/commonness.js +45 -0
- package/esm/insight/narrative/strategy/correlation.js +51 -0
- package/esm/insight/narrative/strategy/exception.js +70 -0
- package/esm/insight/narrative/strategy/helpers.js +25 -0
- package/esm/insight/narrative/strategy/index.js +13 -0
- package/esm/insight/narrative/strategy/lowVariance.js +48 -0
- package/esm/insight/narrative/strategy/majority.js +62 -0
- package/esm/insight/narrative/strategy/timeSeriesOutlier.js +92 -0
- package/esm/insight/narrative/strategy/trend.js +57 -0
- package/esm/insight/pipeline/extract.js +236 -0
- package/esm/insight/pipeline/index.js +11 -0
- package/esm/insight/pipeline/insight.js +81 -0
- package/esm/insight/pipeline/preprocess.js +33 -0
- package/esm/insight/pipeline/specificInsight.js +71 -0
- package/esm/insight/pipeline/util.js +14 -0
- package/esm/insight/pipeline/visualize.js +41 -0
- package/esm/insight/types.js +1 -0
- package/esm/insight/utils/aggregate.js +87 -0
- package/esm/insight/utils/common.js +35 -0
- package/esm/ntv/generate/generateTextSpec.js +157 -0
- package/esm/ntv/generate/index.js +5 -0
- package/esm/ntv/generate/types.js +1 -0
- package/esm/ntv/generate/utils.js +86 -0
- package/esm/ntv/index.js +4 -0
- package/esm/ntv/schema/common.js +1 -0
- package/esm/ntv/schema/index.js +4 -0
- package/esm/ntv/schema/paragraph.js +1 -0
- package/esm/ntv/schema/phrase.js +52 -0
- package/esm/ntv/schema/structure.js +1 -0
- package/esm/ntv/types.js +1 -0
- package/esm/ntv/utils/index.js +1 -0
- package/esm/ntv/utils/isSpecType.js +58 -0
- package/esm/utils/arr2map.js +7 -0
- package/esm/utils/dataFormat.js +32 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/isType.js +14 -0
- package/lib/advisor/advise-pipeline/advicesForChart.d.ts +13 -0
- package/lib/advisor/advise-pipeline/advicesForChart.js +73 -0
- package/lib/advisor/advise-pipeline/data-to-advices.d.ts +22 -0
- package/lib/advisor/advise-pipeline/data-to-advices.js +245 -0
- package/lib/advisor/advise-pipeline/index.d.ts +1 -0
- package/lib/advisor/advise-pipeline/index.js +5 -0
- package/lib/advisor/advise-pipeline/spec-mapping.d.ts +14 -0
- package/lib/advisor/advise-pipeline/spec-mapping.js +504 -0
- package/lib/advisor/advisor.d.ts +18 -0
- package/lib/advisor/advisor.js +38 -0
- package/lib/advisor/constants.d.ts +1 -0
- package/lib/advisor/constants.js +16 -0
- package/lib/advisor/index.d.ts +2 -0
- package/lib/advisor/index.js +7 -0
- package/lib/advisor/lint-pipeline/check-rules.d.ts +4 -0
- package/lib/advisor/lint-pipeline/check-rules.js +47 -0
- package/lib/advisor/lint-pipeline/getChartType.d.ts +7 -0
- package/lib/advisor/lint-pipeline/getChartType.js +113 -0
- package/lib/advisor/lint-pipeline/index.d.ts +0 -0
- package/lib/advisor/lint-pipeline/index.js +0 -0
- package/lib/advisor/lint-pipeline/lintRules.d.ts +5 -0
- package/lib/advisor/lint-pipeline/lintRules.js +36 -0
- package/lib/advisor/ruler/index.d.ts +21 -0
- package/lib/advisor/ruler/index.js +80 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.d.ts +2 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.js +24 -0
- package/lib/advisor/ruler/rules/all-can-be-table.d.ts +2 -0
- package/lib/advisor/ruler/rules/all-can-be-table.js +20 -0
- package/lib/advisor/ruler/rules/bar-series-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-series-qty.js +39 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.js +44 -0
- package/lib/advisor/ruler/rules/constants.d.ts +6 -0
- package/lib/advisor/ruler/rules/constants.js +9 -0
- package/lib/advisor/ruler/rules/data-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-check.js +43 -0
- package/lib/advisor/ruler/rules/data-field-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-field-qty.js +29 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.d.ts +2 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.js +36 -0
- package/lib/advisor/ruler/rules/index.d.ts +19 -0
- package/lib/advisor/ruler/rules/index.js +71 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.d.ts +2 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.js +43 -0
- package/lib/advisor/ruler/rules/limit-series.d.ts +2 -0
- package/lib/advisor/ruler/rules/limit-series.js +50 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.d.ts +2 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.js +28 -0
- package/lib/advisor/ruler/rules/no-redundant-field.d.ts +2 -0
- package/lib/advisor/ruler/rules/no-redundant-field.js +35 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.d.ts +2 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.js +57 -0
- package/lib/advisor/ruler/rules/purpose-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/purpose-check.js +30 -0
- package/lib/advisor/ruler/rules/series-qty-limit.d.ts +2 -0
- package/lib/advisor/ruler/rules/series-qty-limit.js +37 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.d.ts +2 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.js +44 -0
- package/lib/advisor/ruler/types.d.ts +125 -0
- package/lib/advisor/ruler/types.js +2 -0
- package/lib/advisor/ruler/utils.d.ts +10 -0
- package/lib/advisor/ruler/utils.js +61 -0
- package/lib/advisor/types.d.ts +218 -0
- package/lib/advisor/types.js +4 -0
- package/lib/advisor/utils/clone.d.ts +2 -0
- package/lib/advisor/utils/clone.js +34 -0
- package/lib/advisor/utils/compare.d.ts +3 -0
- package/lib/advisor/utils/compare.js +17 -0
- package/lib/advisor/utils/computeScore.d.ts +7 -0
- package/lib/advisor/utils/computeScore.js +27 -0
- package/lib/advisor/utils/deep-mix.d.ts +2 -0
- package/lib/advisor/utils/deep-mix.js +78 -0
- package/lib/advisor/utils/hasSubset.d.ts +1 -0
- package/lib/advisor/utils/hasSubset.js +7 -0
- package/lib/advisor/utils/index.d.ts +5 -0
- package/lib/advisor/utils/index.js +19 -0
- package/lib/advisor/utils/inferDataType.d.ts +6 -0
- package/lib/advisor/utils/inferDataType.js +75 -0
- package/lib/advisor/utils/intersects.d.ts +1 -0
- package/lib/advisor/utils/intersects.js +7 -0
- package/lib/advisor/utils/isNil.d.ts +2 -0
- package/lib/advisor/utils/isNil.js +6 -0
- package/lib/ckb/base.d.ts +2 -0
- package/lib/ckb/base.js +1313 -0
- package/lib/ckb/ckb.d.ts +8 -0
- package/lib/ckb/ckb.js +59 -0
- package/lib/ckb/constants.d.ts +79 -0
- package/lib/ckb/constants.js +200 -0
- package/lib/ckb/i18n/index.d.ts +10 -0
- package/lib/ckb/i18n/index.js +27 -0
- package/lib/ckb/i18n/types.d.ts +52 -0
- package/lib/ckb/i18n/types.js +2 -0
- package/lib/ckb/i18n/zh-CN.d.ts +7 -0
- package/lib/ckb/i18n/zh-CN.js +528 -0
- package/lib/ckb/index.d.ts +4 -0
- package/lib/ckb/index.js +20 -0
- package/lib/ckb/types.d.ts +185 -0
- package/lib/ckb/types.js +2 -0
- package/lib/common/types.d.ts +14 -0
- package/lib/common/types.js +2 -0
- package/lib/data/analysis/field/index.d.ts +79 -0
- package/lib/data/analysis/field/index.js +355 -0
- package/lib/data/analysis/field/types.d.ts +99 -0
- package/lib/data/analysis/field/types.js +2 -0
- package/lib/data/analysis/graph/index.d.ts +28 -0
- package/lib/data/analysis/graph/index.js +178 -0
- package/lib/data/analysis/graph/types.d.ts +62 -0
- package/lib/data/analysis/graph/types.js +2 -0
- package/lib/data/analysis/index.d.ts +1 -0
- package/lib/data/analysis/index.js +5 -0
- package/lib/data/analysis/types.d.ts +1 -0
- package/lib/data/analysis/types.js +2 -0
- package/lib/data/dataset/field/baseFrame.d.ts +30 -0
- package/lib/data/dataset/field/baseFrame.js +78 -0
- package/lib/data/dataset/field/dataFrame.d.ts +35 -0
- package/lib/data/dataset/field/dataFrame.js +558 -0
- package/lib/data/dataset/field/index.d.ts +3 -0
- package/lib/data/dataset/field/index.js +8 -0
- package/lib/data/dataset/field/series.d.ts +18 -0
- package/lib/data/dataset/field/series.js +151 -0
- package/lib/data/dataset/field/types.d.ts +54 -0
- package/lib/data/dataset/field/types.js +2 -0
- package/lib/data/dataset/field/utils.d.ts +13 -0
- package/lib/data/dataset/field/utils.js +68 -0
- package/lib/data/dataset/graph/index.d.ts +18 -0
- package/lib/data/dataset/graph/index.js +188 -0
- package/lib/data/dataset/graph/types.d.ts +35 -0
- package/lib/data/dataset/graph/types.js +2 -0
- package/lib/data/dataset/graph/utils.d.ts +1 -0
- package/lib/data/dataset/graph/utils.js +19 -0
- package/lib/data/dataset/index.d.ts +1 -0
- package/lib/data/dataset/index.js +4 -0
- package/lib/data/dataset/types.d.ts +1 -0
- package/lib/data/dataset/types.js +4 -0
- package/lib/data/index.d.ts +5 -0
- package/lib/data/index.js +8 -0
- package/lib/data/statistics/IQR.d.ts +21 -0
- package/lib/data/statistics/IQR.js +53 -0
- package/lib/data/statistics/base.d.ts +106 -0
- package/lib/data/statistics/base.js +271 -0
- package/lib/data/statistics/bayesian.d.ts +5 -0
- package/lib/data/statistics/bayesian.js +30 -0
- package/lib/data/statistics/buishand-u.d.ts +7 -0
- package/lib/data/statistics/buishand-u.js +23 -0
- package/lib/data/statistics/caches.d.ts +13 -0
- package/lib/data/statistics/caches.js +33 -0
- package/lib/data/statistics/cdf.d.ts +7 -0
- package/lib/data/statistics/cdf.js +29 -0
- package/lib/data/statistics/constants.d.ts +5 -0
- package/lib/data/statistics/constants.js +15 -0
- package/lib/data/statistics/index.d.ts +7 -0
- package/lib/data/statistics/index.js +14 -0
- package/lib/data/statistics/lowess.d.ts +10 -0
- package/lib/data/statistics/lowess.js +87 -0
- package/lib/data/statistics/mannkendall-test.d.ts +15 -0
- package/lib/data/statistics/mannkendall-test.js +54 -0
- package/lib/data/statistics/maxabs.d.ts +5 -0
- package/lib/data/statistics/maxabs.js +13 -0
- package/lib/data/statistics/pcorrtest.d.ts +3 -0
- package/lib/data/statistics/pcorrtest.js +80 -0
- package/lib/data/statistics/pettitt-test.d.ts +9 -0
- package/lib/data/statistics/pettitt-test.js +38 -0
- package/lib/data/statistics/quantile.d.ts +16 -0
- package/lib/data/statistics/quantile.js +61 -0
- package/lib/data/statistics/types.d.ts +70 -0
- package/lib/data/statistics/types.js +2 -0
- package/lib/data/statistics/vector.d.ts +15 -0
- package/lib/data/statistics/vector.js +78 -0
- package/lib/data/statistics/window.d.ts +12 -0
- package/lib/data/statistics/window.js +60 -0
- package/lib/data/types.d.ts +2 -0
- package/lib/data/types.js +5 -0
- package/lib/data/utils/common.d.ts +26 -0
- package/lib/data/utils/common.js +67 -0
- package/lib/data/utils/index.d.ts +2 -0
- package/lib/data/utils/index.js +8 -0
- package/lib/data/utils/isType/constants.d.ts +15 -0
- package/lib/data/utils/isType/constants.js +27 -0
- package/lib/data/utils/isType/index.d.ts +2 -0
- package/lib/data/utils/isType/index.js +5 -0
- package/lib/data/utils/isType/isDateString.d.ts +18 -0
- package/lib/data/utils/isType/isDateString.js +111 -0
- package/lib/data/utils/isType/isType.d.ts +13 -0
- package/lib/data/utils/isType/isType.js +94 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +75 -0
- package/lib/insight/algorithms/base/compare.d.ts +14 -0
- package/lib/insight/algorithms/base/compare.js +45 -0
- package/lib/insight/algorithms/categoryOutlier.d.ts +4 -0
- package/lib/insight/algorithms/categoryOutlier.js +7 -0
- package/lib/insight/algorithms/changePoint.d.ts +10 -0
- package/lib/insight/algorithms/changePoint.js +13 -0
- package/lib/insight/algorithms/index.d.ts +3 -0
- package/lib/insight/algorithms/index.js +6 -0
- package/lib/insight/algorithms/trendDirection.d.ts +4 -0
- package/lib/insight/algorithms/trendDirection.js +7 -0
- package/lib/insight/chart/constants.d.ts +13 -0
- package/lib/insight/chart/constants.js +28 -0
- package/lib/insight/chart/generator/homogeneous.d.ts +3 -0
- package/lib/insight/chart/generator/homogeneous.js +75 -0
- package/lib/insight/chart/generator/index.d.ts +2 -0
- package/lib/insight/chart/generator/index.js +5 -0
- package/lib/insight/chart/generator/insights.d.ts +3 -0
- package/lib/insight/chart/generator/insights.js +20 -0
- package/lib/insight/chart/index.d.ts +4 -0
- package/lib/insight/chart/index.js +7 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.js +35 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.js +47 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.js +10 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.d.ts +8 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.js +24 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.js +28 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +87 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.js +31 -0
- package/lib/insight/chart/strategy/chart.d.ts +7 -0
- package/lib/insight/chart/strategy/chart.js +49 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.js +16 -0
- package/lib/insight/chart/strategy/commonMarks/index.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/index.js +13 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.js +18 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.js +38 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.js +21 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.js +32 -0
- package/lib/insight/chart/strategy/index.d.ts +4 -0
- package/lib/insight/chart/strategy/index.js +10 -0
- package/lib/insight/chart/strategy/viewSpec.d.ts +3 -0
- package/lib/insight/chart/strategy/viewSpec.js +20 -0
- package/lib/insight/chart/types.d.ts +60 -0
- package/lib/insight/chart/types.js +2 -0
- package/lib/insight/chart/utils.d.ts +3 -0
- package/lib/insight/chart/utils.js +8 -0
- package/lib/insight/constant.d.ts +12 -0
- package/lib/insight/constant.js +24 -0
- package/lib/insight/index.d.ts +6 -0
- package/lib/insight/index.js +13 -0
- package/lib/insight/insights/checkers.d.ts +16 -0
- package/lib/insight/insights/checkers.js +107 -0
- package/lib/insight/insights/extractors/categoryOutlier.d.ts +12 -0
- package/lib/insight/insights/extractors/categoryOutlier.js +95 -0
- package/lib/insight/insights/extractors/changePoint.d.ts +8 -0
- package/lib/insight/insights/extractors/changePoint.js +60 -0
- package/lib/insight/insights/extractors/correlation.d.ts +9 -0
- package/lib/insight/insights/extractors/correlation.js +43 -0
- package/lib/insight/insights/extractors/homogeneous.d.ts +4 -0
- package/lib/insight/insights/extractors/homogeneous.js +103 -0
- package/lib/insight/insights/extractors/lowVariance.d.ts +8 -0
- package/lib/insight/insights/extractors/lowVariance.js +54 -0
- package/lib/insight/insights/extractors/majority.d.ts +10 -0
- package/lib/insight/insights/extractors/majority.js +71 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.d.ts +2 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.js +65 -0
- package/lib/insight/insights/extractors/trend.d.ts +9 -0
- package/lib/insight/insights/extractors/trend.js +54 -0
- package/lib/insight/insights/index.d.ts +12 -0
- package/lib/insight/insights/index.js +32 -0
- package/lib/insight/insights/util.d.ts +13 -0
- package/lib/insight/insights/util.js +87 -0
- package/lib/insight/narrative/factory.d.ts +6 -0
- package/lib/insight/narrative/factory.js +25 -0
- package/lib/insight/narrative/index.d.ts +3 -0
- package/lib/insight/narrative/index.js +18 -0
- package/lib/insight/narrative/strategy/base.d.ts +9 -0
- package/lib/insight/narrative/strategy/base.js +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.d.ts +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.js +76 -0
- package/lib/insight/narrative/strategy/changePoint.d.ts +8 -0
- package/lib/insight/narrative/strategy/changePoint.js +54 -0
- package/lib/insight/narrative/strategy/commonness.d.ts +9 -0
- package/lib/insight/narrative/strategy/commonness.js +47 -0
- package/lib/insight/narrative/strategy/correlation.d.ts +8 -0
- package/lib/insight/narrative/strategy/correlation.js +53 -0
- package/lib/insight/narrative/strategy/exception.d.ts +10 -0
- package/lib/insight/narrative/strategy/exception.js +72 -0
- package/lib/insight/narrative/strategy/helpers.d.ts +5 -0
- package/lib/insight/narrative/strategy/helpers.js +31 -0
- package/lib/insight/narrative/strategy/index.d.ts +9 -0
- package/lib/insight/narrative/strategy/index.js +28 -0
- package/lib/insight/narrative/strategy/lowVariance.d.ts +8 -0
- package/lib/insight/narrative/strategy/lowVariance.js +50 -0
- package/lib/insight/narrative/strategy/majority.d.ts +8 -0
- package/lib/insight/narrative/strategy/majority.js +64 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.d.ts +8 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.js +94 -0
- package/lib/insight/narrative/strategy/trend.d.ts +8 -0
- package/lib/insight/narrative/strategy/trend.js +59 -0
- package/lib/insight/pipeline/extract.d.ts +13 -0
- package/lib/insight/pipeline/extract.js +243 -0
- package/lib/insight/pipeline/index.d.ts +2 -0
- package/lib/insight/pipeline/index.js +15 -0
- package/lib/insight/pipeline/insight.d.ts +10 -0
- package/lib/insight/pipeline/insight.js +86 -0
- package/lib/insight/pipeline/preprocess.d.ts +6 -0
- package/lib/insight/pipeline/preprocess.js +39 -0
- package/lib/insight/pipeline/specificInsight.d.ts +11 -0
- package/lib/insight/pipeline/specificInsight.js +79 -0
- package/lib/insight/pipeline/util.d.ts +5 -0
- package/lib/insight/pipeline/util.js +20 -0
- package/lib/insight/pipeline/visualize.d.ts +3 -0
- package/lib/insight/pipeline/visualize.js +46 -0
- package/lib/insight/types.d.ts +238 -0
- package/lib/insight/types.js +2 -0
- package/lib/insight/utils/aggregate.d.ts +7 -0
- package/lib/insight/utils/aggregate.js +93 -0
- package/lib/insight/utils/common.d.ts +3 -0
- package/lib/insight/utils/common.js +41 -0
- package/lib/ntv/generate/generateTextSpec.d.ts +9 -0
- package/lib/ntv/generate/generateTextSpec.js +160 -0
- package/lib/ntv/generate/index.d.ts +2 -0
- package/lib/ntv/generate/index.js +12 -0
- package/lib/ntv/generate/types.d.ts +58 -0
- package/lib/ntv/generate/types.js +2 -0
- package/lib/ntv/generate/utils.d.ts +29 -0
- package/lib/ntv/generate/utils.js +96 -0
- package/lib/ntv/index.d.ts +4 -0
- package/lib/ntv/index.js +10 -0
- package/lib/ntv/schema/common.d.ts +17 -0
- package/lib/ntv/schema/common.js +2 -0
- package/lib/ntv/schema/index.d.ts +4 -0
- package/lib/ntv/schema/index.js +7 -0
- package/lib/ntv/schema/paragraph.d.ts +34 -0
- package/lib/ntv/schema/paragraph.js +2 -0
- package/lib/ntv/schema/phrase.d.ts +70 -0
- package/lib/ntv/schema/phrase.js +55 -0
- package/lib/ntv/schema/structure.d.ts +18 -0
- package/lib/ntv/schema/structure.js +2 -0
- package/lib/ntv/types.d.ts +2 -0
- package/lib/ntv/types.js +2 -0
- package/lib/ntv/utils/index.d.ts +1 -0
- package/lib/ntv/utils/index.js +4 -0
- package/lib/ntv/utils/isSpecType.d.ts +17 -0
- package/lib/ntv/utils/isSpecType.js +76 -0
- package/lib/utils/arr2map.d.ts +1 -0
- package/lib/utils/arr2map.js +11 -0
- package/lib/utils/dataFormat.d.ts +11 -0
- package/lib/utils/dataFormat.js +35 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/isType.d.ts +4 -0
- package/lib/utils/isType.js +21 -0
- package/package.json +88 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
|
+
import { groupBy, uniq, flatten, isString } from 'lodash';
|
|
3
|
+
import { PATTERN_TYPES, INSIGHT_SCORE_BENCHMARK, IMPACT_SCORE_WEIGHT } from '../constant';
|
|
4
|
+
import { insightPatternsExtractor, ExtractorCheckers } from '../insights';
|
|
5
|
+
import { aggregate } from '../utils/aggregate';
|
|
6
|
+
import { extractHomogeneousPatternsForMeasures, extractHomogeneousPatternsForSiblingGroups, } from '../insights/extractors/homogeneous';
|
|
7
|
+
import { calculateImpactValue } from './preprocess';
|
|
8
|
+
import { addInsightsToHeap } from './util';
|
|
9
|
+
/** calculate the Impact which reflects the importance of the subject of an insight against the entire dataset */
|
|
10
|
+
function computeSubspaceImpact(data, subspace, impactMeasureReferences, measures) {
|
|
11
|
+
if (!(measures === null || measures === void 0 ? void 0 : measures.length) || !subspace)
|
|
12
|
+
return 1;
|
|
13
|
+
var impactValues = measures.map(function (measure) {
|
|
14
|
+
var measureValue = calculateImpactValue(data, measure);
|
|
15
|
+
var referenceKey = "".concat(measure.fieldName, "@").concat(measure.method);
|
|
16
|
+
var referenceValue = impactMeasureReferences[referenceKey];
|
|
17
|
+
return measureValue / referenceValue;
|
|
18
|
+
});
|
|
19
|
+
return Math.max.apply(Math, __spreadArray([], __read(impactValues), false));
|
|
20
|
+
}
|
|
21
|
+
/** extract patterns from a specific subject */
|
|
22
|
+
function extractPatternsFromSubject(data, subjectInfo, fieldPropsMap, options) {
|
|
23
|
+
var measures = subjectInfo.measures, dimensions = subjectInfo.dimensions;
|
|
24
|
+
var enumInsightTypes = (options === null || options === void 0 ? void 0 : options.insightTypes) || PATTERN_TYPES;
|
|
25
|
+
var patterns = {};
|
|
26
|
+
enumInsightTypes.forEach(function (insightType) {
|
|
27
|
+
var insightExtractorChecker = ExtractorCheckers[insightType];
|
|
28
|
+
var isValid = true;
|
|
29
|
+
// Check whether the data requirements of the extractor are met
|
|
30
|
+
if (insightExtractorChecker) {
|
|
31
|
+
if (isString(insightExtractorChecker({ data: data, subjectInfo: subjectInfo, fieldPropsMap: fieldPropsMap })))
|
|
32
|
+
isValid = false;
|
|
33
|
+
}
|
|
34
|
+
if (isValid && insightPatternsExtractor) {
|
|
35
|
+
var _a = options || {}, algorithmParameter = _a.algorithmParameter, dataProcessInfo = _a.dataProcessInfo;
|
|
36
|
+
var extractorOptions = {
|
|
37
|
+
algorithmParameter: algorithmParameter,
|
|
38
|
+
dataProcessInfo: dataProcessInfo,
|
|
39
|
+
// Validation has been done in method extractInsights
|
|
40
|
+
dataValidation: false,
|
|
41
|
+
// Select only significant insights
|
|
42
|
+
filterInsight: true,
|
|
43
|
+
};
|
|
44
|
+
var extractedPatterns = insightPatternsExtractor({
|
|
45
|
+
data: data,
|
|
46
|
+
dimensions: dimensions.map(function (dim) { return ({ fieldName: dim }); }),
|
|
47
|
+
measures: measures,
|
|
48
|
+
insightType: insightType,
|
|
49
|
+
options: extractorOptions,
|
|
50
|
+
});
|
|
51
|
+
patterns[insightType] = extractedPatterns;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
patterns[insightType] = undefined;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return patterns;
|
|
58
|
+
}
|
|
59
|
+
export function extractInsightsFor1M1DCombination(data, dimensions, measures, subspace, referenceInfo, options) {
|
|
60
|
+
var fieldPropsMap = referenceInfo.fieldPropsMap;
|
|
61
|
+
var insights = [];
|
|
62
|
+
dimensions.forEach(function (dimension) {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
var insightsPerDim = [];
|
|
65
|
+
var isTimeField = (_b = (_a = fieldPropsMap[dimension]) === null || _a === void 0 ? void 0 : _a.levelOfMeasurements) === null || _b === void 0 ? void 0 : _b.includes('Time');
|
|
66
|
+
measures.forEach(function (measure) {
|
|
67
|
+
var childSubjectInfo = { dimensions: [dimension], subspace: subspace, measures: [measure] };
|
|
68
|
+
var aggregatedData = aggregate(data, dimension, [measure], isTimeField);
|
|
69
|
+
var patterns = extractPatternsFromSubject(aggregatedData, childSubjectInfo, fieldPropsMap, options);
|
|
70
|
+
var patternsArray = flatten(Object.values(patterns).filter(function (item) { return (item === null || item === void 0 ? void 0 : item.length) > 0; })).sort(function (a, b) { return b.significance - a.significance; });
|
|
71
|
+
if (patternsArray.length) {
|
|
72
|
+
var insight = {
|
|
73
|
+
subspace: subspace,
|
|
74
|
+
dimensions: [
|
|
75
|
+
{
|
|
76
|
+
fieldName: dimension,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
measures: [measure],
|
|
80
|
+
patterns: patternsArray,
|
|
81
|
+
data: aggregatedData,
|
|
82
|
+
score: patternsArray[0].significance,
|
|
83
|
+
};
|
|
84
|
+
insightsPerDim.push(insight);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
insightsPerDim.push(null);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
insights.push(insightsPerDim);
|
|
91
|
+
});
|
|
92
|
+
return insights;
|
|
93
|
+
}
|
|
94
|
+
export function extractInsightsForCorrelation(data, dimensions, measures, subspace, referenceInfo, options) {
|
|
95
|
+
var _a;
|
|
96
|
+
var fieldPropsMap = referenceInfo.fieldPropsMap;
|
|
97
|
+
var insights = [];
|
|
98
|
+
var measureNum = measures.length;
|
|
99
|
+
if (measureNum >= 2) {
|
|
100
|
+
for (var i = 0; i < measureNum - 1; i += 1) {
|
|
101
|
+
for (var j = i + 1; j < measureNum; j += 1) {
|
|
102
|
+
var childSubjectInfo = { dimensions: dimensions, subspace: subspace, measures: [measures[i], measures[j]] };
|
|
103
|
+
var patterns = extractPatternsFromSubject(data, childSubjectInfo, fieldPropsMap, __assign(__assign({}, options), { insightTypes: ['correlation'] }));
|
|
104
|
+
var patternsArray = (_a = patterns === null || patterns === void 0 ? void 0 : patterns.correlation) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return b.significance - a.significance; });
|
|
105
|
+
if (patternsArray === null || patternsArray === void 0 ? void 0 : patternsArray.length) {
|
|
106
|
+
var insight = {
|
|
107
|
+
subspace: subspace,
|
|
108
|
+
dimensions: dimensions.map(function (d) { return ({ fieldName: d }); }),
|
|
109
|
+
measures: [measures[i], measures[j]],
|
|
110
|
+
patterns: patternsArray,
|
|
111
|
+
data: data,
|
|
112
|
+
score: patternsArray[0].significance,
|
|
113
|
+
};
|
|
114
|
+
insights.push(insight);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return insights;
|
|
120
|
+
}
|
|
121
|
+
/** recursive extraction in data subspace */
|
|
122
|
+
export function extractInsightsFromSubspace(data, dimensions, measures, subspace, referenceInfo, insightsHeap, homogeneousInsightsHeap, options) {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
/** subspace pruning */
|
|
125
|
+
if (!(data === null || data === void 0 ? void 0 : data.length)) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
// calculate impact score
|
|
129
|
+
var impactMeasureReferences = referenceInfo.impactMeasureReferences, fieldPropsMap = referenceInfo.fieldPropsMap;
|
|
130
|
+
var subspaceImpact = computeSubspaceImpact(data, subspace, impactMeasureReferences, options === null || options === void 0 ? void 0 : options.impactMeasures);
|
|
131
|
+
// pruning1: check the subpace impact limit
|
|
132
|
+
if (subspaceImpact < INSIGHT_SCORE_BENCHMARK) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
// pruning2: check if the impact score is greater than the minimum score in heap
|
|
136
|
+
var impactScoreWeight = !!(options === null || options === void 0 ? void 0 : options.impactWeight) && options.impactWeight >= 0 && options.impactWeight < 1
|
|
137
|
+
? options.impactWeight
|
|
138
|
+
: IMPACT_SCORE_WEIGHT;
|
|
139
|
+
var optimalScore = subspaceImpact * impactScoreWeight + 1 * (1 - impactScoreWeight);
|
|
140
|
+
if (insightsHeap.length >= insightsHeap.limit) {
|
|
141
|
+
var minScoreInHeap = (_a = insightsHeap.peek()) === null || _a === void 0 ? void 0 : _a.score;
|
|
142
|
+
if (optimalScore <= minScoreInHeap) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** insight extraction */
|
|
147
|
+
var insights = [];
|
|
148
|
+
/** Combination: 1M * 1D */
|
|
149
|
+
var insightsFor1M1DCombination = extractInsightsFor1M1DCombination(data, dimensions, measures, subspace, referenceInfo, options);
|
|
150
|
+
insightsFor1M1DCombination.forEach(function (insightsPerDim) {
|
|
151
|
+
var insightsForMeasures = insightsPerDim
|
|
152
|
+
.filter(function (item) { return !!item; })
|
|
153
|
+
.map(function (item) { return (__assign(__assign({}, item), { score: item.score * (1 - impactScoreWeight) + subspaceImpact * impactScoreWeight })); });
|
|
154
|
+
insights.push.apply(insights, __spreadArray([], __read(insightsPerDim), false));
|
|
155
|
+
addInsightsToHeap(insightsForMeasures, insightsHeap);
|
|
156
|
+
});
|
|
157
|
+
// Combination 3: 1M * 1M */
|
|
158
|
+
if ((options.insightTypes || PATTERN_TYPES).includes('correlation')) {
|
|
159
|
+
var extracted = extractInsightsForCorrelation(data, dimensions, measures, subspace, referenceInfo, options);
|
|
160
|
+
var insightsForCorrelation = extracted === null || extracted === void 0 ? void 0 : extracted.map(function (item) { return (__assign(__assign({}, item), { score: item.score * (1 - impactScoreWeight) + subspaceImpact * impactScoreWeight })); });
|
|
161
|
+
addInsightsToHeap(insightsForCorrelation, insightsHeap);
|
|
162
|
+
}
|
|
163
|
+
/** extract homogeneous insight in measures */
|
|
164
|
+
if (options === null || options === void 0 ? void 0 : options.homogeneous) {
|
|
165
|
+
insightsFor1M1DCombination.forEach(function (insightsPerDim, dimIndex) {
|
|
166
|
+
var homogeneousPatternsForMeasures = extractHomogeneousPatternsForMeasures(measures, insightsPerDim);
|
|
167
|
+
if (homogeneousPatternsForMeasures.length > 0) {
|
|
168
|
+
var homogeneousInsights = homogeneousPatternsForMeasures.map(function (pattern) { return ({
|
|
169
|
+
subspace: subspace,
|
|
170
|
+
dimensions: [{ fieldName: dimensions[dimIndex] }],
|
|
171
|
+
measures: measures,
|
|
172
|
+
patterns: [pattern],
|
|
173
|
+
data: data,
|
|
174
|
+
score: pattern.significance * (1 - impactScoreWeight) + subspaceImpact * impactScoreWeight,
|
|
175
|
+
}); });
|
|
176
|
+
homogeneousInsightsHeap.addAll(homogeneousInsights);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/** subspace search */
|
|
181
|
+
if (!(options === null || options === void 0 ? void 0 : options.ignoreSubspace)) {
|
|
182
|
+
var searchedDimensions_1 = subspace.map(function (item) { return item.dimension; });
|
|
183
|
+
var remainDimensionFields_1 = (((_b = options === null || options === void 0 ? void 0 : options.dimensions) === null || _b === void 0 ? void 0 : _b.map(function (dimension) { return dimension.fieldName; })) ||
|
|
184
|
+
Object.values(fieldPropsMap)
|
|
185
|
+
.filter(function (item) { return item.domainType === 'dimension'; })
|
|
186
|
+
.map(function (item) { return item.name; })).filter(function (field) { return !searchedDimensions_1.includes(field); });
|
|
187
|
+
if (remainDimensionFields_1.length > 0) {
|
|
188
|
+
remainDimensionFields_1.forEach(function (dimension) {
|
|
189
|
+
var siblingGroupInsights = [];
|
|
190
|
+
var groupedData = groupBy(data, dimension);
|
|
191
|
+
var breakdownValues = uniq(fieldPropsMap[dimension].rawData);
|
|
192
|
+
var dimensionsInSubspace = remainDimensionFields_1.filter(function (item) { return item !== dimension; });
|
|
193
|
+
if (breakdownValues.length > 1) {
|
|
194
|
+
breakdownValues.forEach(function (value) {
|
|
195
|
+
var childSubspace = __spreadArray(__spreadArray([], __read(subspace), false), [{ dimension: dimension, value: value }], false);
|
|
196
|
+
var subspaceInsights = extractInsightsFromSubspace(groupedData[value], dimensionsInSubspace, measures, childSubspace, referenceInfo, insightsHeap, homogeneousInsightsHeap, options);
|
|
197
|
+
siblingGroupInsights.push(subspaceInsights);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/** extract homegenehous insight in sibling group */
|
|
201
|
+
if (options === null || options === void 0 ? void 0 : options.homogeneous) {
|
|
202
|
+
dimensionsInSubspace.forEach(function (dim) {
|
|
203
|
+
measures.forEach(function (measure) {
|
|
204
|
+
var siblingGroupInsightsArr = siblingGroupInsights.map(function (siblingItem) {
|
|
205
|
+
return (siblingItem.find(function (insight) {
|
|
206
|
+
return (!!insight &&
|
|
207
|
+
insight.dimensions.length === 1 &&
|
|
208
|
+
insight.dimensions[0].fieldName === dim &&
|
|
209
|
+
insight.measures.length === 1 &&
|
|
210
|
+
insight.measures[0].fieldName === measure.fieldName);
|
|
211
|
+
}) || null);
|
|
212
|
+
});
|
|
213
|
+
var homogeneousPatternsForSiblingGroups = extractHomogeneousPatternsForSiblingGroups(breakdownValues, siblingGroupInsightsArr);
|
|
214
|
+
var insightsForSiblingGroup = homogeneousPatternsForSiblingGroups.map(function (pattern) { return ({
|
|
215
|
+
subspace: subspace,
|
|
216
|
+
dimensions: [{ fieldName: dimension }, { fieldName: dim }],
|
|
217
|
+
measures: [measure],
|
|
218
|
+
patterns: [pattern],
|
|
219
|
+
data: data,
|
|
220
|
+
score: pattern.significance * (1 - impactScoreWeight) + subspaceImpact * impactScoreWeight,
|
|
221
|
+
}); });
|
|
222
|
+
homogeneousInsightsHeap.addAll(insightsForSiblingGroup);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return insights;
|
|
230
|
+
}
|
|
231
|
+
/** insight subject enumeration in the data */
|
|
232
|
+
export function enumerateInsights(data, dimensions, measures, referenceInfo, insightsHeap, metaInsightsHeap, options) {
|
|
233
|
+
if (options === void 0) { options = {}; }
|
|
234
|
+
var initSubspace = [];
|
|
235
|
+
extractInsightsFromSubspace(data, dimensions, measures, initSubspace, referenceInfo, insightsHeap, metaInsightsHeap, options);
|
|
236
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { extractInsights, generateInsightsWithVisualizationSpec } from './insight';
|
|
3
|
+
export function getInsights(sourceData, options) {
|
|
4
|
+
var extractResult = extractInsights(sourceData, options);
|
|
5
|
+
if (options === null || options === void 0 ? void 0 : options.visualization) {
|
|
6
|
+
// Provide all vis options
|
|
7
|
+
var visOption = __assign({ lang: 'en-US' }, ((options === null || options === void 0 ? void 0 : options.visualization) === true ? {} : options === null || options === void 0 ? void 0 : options.visualization));
|
|
8
|
+
return generateInsightsWithVisualizationSpec(extractResult, __assign(__assign({}, options), { visualization: visOption }));
|
|
9
|
+
}
|
|
10
|
+
return extractResult;
|
|
11
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import Heap from 'heap-js';
|
|
3
|
+
import { INSIGHT_DEFAULT_LIMIT } from '../constant';
|
|
4
|
+
import { aggregateWithSeries, aggregateWithMeasures } from '../utils/aggregate';
|
|
5
|
+
import { enumerateInsights } from './extract';
|
|
6
|
+
import { dataToDataProps, calculateImpactMeasureReferenceValues } from './preprocess';
|
|
7
|
+
import { generateHomogeneousInsightVisualizationSpec, generateInsightVisualizationSpec } from './visualize';
|
|
8
|
+
import { insightPriorityComparator, homogeneousInsightPriorityComparator } from './util';
|
|
9
|
+
export function extractInsights(sourceData, options) {
|
|
10
|
+
var _a;
|
|
11
|
+
// get data columns infomations (column type, statistics, etc.)
|
|
12
|
+
var data = sourceData.filter(function (item) { return !Object.values(item).some(function (v) { return v === null || v === undefined; }); });
|
|
13
|
+
var dataProps = dataToDataProps(data, options === null || options === void 0 ? void 0 : options.dataProcessInfo);
|
|
14
|
+
var fieldPropsMap = dataProps.reduce(function (acc, item) {
|
|
15
|
+
acc[item.name] = item;
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
var impactMeasureReferences = calculateImpactMeasureReferenceValues(data, options === null || options === void 0 ? void 0 : options.impactMeasures);
|
|
19
|
+
var referenceInfo = {
|
|
20
|
+
fieldPropsMap: fieldPropsMap,
|
|
21
|
+
impactMeasureReferences: impactMeasureReferences,
|
|
22
|
+
};
|
|
23
|
+
var measures = (options === null || options === void 0 ? void 0 : options.measures) ||
|
|
24
|
+
dataProps
|
|
25
|
+
.filter(function (item) { return item.domainType === 'measure'; })
|
|
26
|
+
.map(function (item) { return ({
|
|
27
|
+
fieldName: item.name,
|
|
28
|
+
method: 'SUM',
|
|
29
|
+
}); });
|
|
30
|
+
var dimensions = ((_a = options === null || options === void 0 ? void 0 : options.dimensions) === null || _a === void 0 ? void 0 : _a.map(function (dimension) { return dimension.fieldName; })) ||
|
|
31
|
+
dataProps.filter(function (item) { return item.domainType === 'dimension'; }).map(function (item) { return item.name; });
|
|
32
|
+
// init insights storage
|
|
33
|
+
var insightsHeap = new Heap(insightPriorityComparator);
|
|
34
|
+
var homogeneousInsightsHeap = new Heap(homogeneousInsightPriorityComparator);
|
|
35
|
+
var insightsLimit = (options === null || options === void 0 ? void 0 : options.limit) || INSIGHT_DEFAULT_LIMIT;
|
|
36
|
+
insightsHeap.limit = insightsLimit;
|
|
37
|
+
insightsHeap.init([]);
|
|
38
|
+
homogeneousInsightsHeap.init([]);
|
|
39
|
+
enumerateInsights(data, dimensions, measures, referenceInfo, insightsHeap, homogeneousInsightsHeap, options);
|
|
40
|
+
// get top N results
|
|
41
|
+
var insights = [];
|
|
42
|
+
var heapSize = insightsHeap.size();
|
|
43
|
+
var insightsSize = heapSize > insightsLimit ? insightsLimit : heapSize;
|
|
44
|
+
for (var i = 0; i < insightsSize; i += 1) {
|
|
45
|
+
var top_1 = insightsHeap.pop();
|
|
46
|
+
insights.push(top_1);
|
|
47
|
+
}
|
|
48
|
+
var result = { insights: insights.reverse() };
|
|
49
|
+
if (options === null || options === void 0 ? void 0 : options.homogeneous) {
|
|
50
|
+
var homogeneousInsightsResult = [];
|
|
51
|
+
var homogeneousHeapSize = homogeneousInsightsHeap.size();
|
|
52
|
+
var homogeneousInsightsSize = homogeneousHeapSize > insightsLimit ? insightsLimit : homogeneousHeapSize;
|
|
53
|
+
for (var i = 0; i < homogeneousInsightsSize; i += 1) {
|
|
54
|
+
var top_2 = homogeneousInsightsHeap.pop();
|
|
55
|
+
homogeneousInsightsResult.push(top_2);
|
|
56
|
+
}
|
|
57
|
+
result.homogeneousInsights = homogeneousInsightsResult.reverse();
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
export function generateInsightsWithVisualizationSpec(extraction, options) {
|
|
62
|
+
var insights = extraction.insights, homogeneousInsights = extraction.homogeneousInsights;
|
|
63
|
+
var insightsWithVis = insights.map(function (item) { return (__assign(__assign({}, item), { visualizationSpecs: generateInsightVisualizationSpec(item, options === null || options === void 0 ? void 0 : options.visualization) })); });
|
|
64
|
+
var result = { insights: insightsWithVis };
|
|
65
|
+
if (homogeneousInsights && (options === null || options === void 0 ? void 0 : options.homogeneous)) {
|
|
66
|
+
var homogeneousInsightsWithVis = homogeneousInsights.map(function (item) {
|
|
67
|
+
var visualizationSpecs = generateHomogeneousInsightVisualizationSpec(item, options.visualization);
|
|
68
|
+
var data = item.data, measures = item.measures, dimensions = item.dimensions;
|
|
69
|
+
var insight = __assign(__assign({}, item), { visualizationSpecs: visualizationSpecs });
|
|
70
|
+
if (measures.length > 1) {
|
|
71
|
+
insight.data = aggregateWithMeasures(data, dimensions[0].fieldName, measures);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
insight.data = aggregateWithSeries(data, dimensions[0].fieldName, measures[0], dimensions[1].fieldName);
|
|
75
|
+
}
|
|
76
|
+
return insight;
|
|
77
|
+
});
|
|
78
|
+
result.homogeneousInsights = homogeneousInsightsWithVis;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { intersection } from 'lodash';
|
|
3
|
+
import { DataFrame } from '../../data';
|
|
4
|
+
import { AggregatorMap } from '../utils/aggregate';
|
|
5
|
+
export function dataToDataProps(data, extra) {
|
|
6
|
+
if (!data) {
|
|
7
|
+
throw new Error('Argument `data` is missing.');
|
|
8
|
+
}
|
|
9
|
+
var df = new DataFrame(data, extra);
|
|
10
|
+
var dataTypeInfos = df.info();
|
|
11
|
+
var dataProps = [];
|
|
12
|
+
dataTypeInfos.forEach(function (info) {
|
|
13
|
+
var _a;
|
|
14
|
+
var newInfo = __assign(__assign({}, info), { domainType: ((_a = intersection(['Interval', 'Continuous'], info.levelOfMeasurements)) === null || _a === void 0 ? void 0 : _a.length) ? 'measure' : 'dimension' });
|
|
15
|
+
dataProps.push(newInfo);
|
|
16
|
+
});
|
|
17
|
+
return dataProps;
|
|
18
|
+
}
|
|
19
|
+
export function calculateImpactValue(data, measure) {
|
|
20
|
+
var measureAggregator = AggregatorMap[measure.method];
|
|
21
|
+
var value = measureAggregator(data, measure.fieldName);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
/** calculate the reference values for impact measures */
|
|
25
|
+
export function calculateImpactMeasureReferenceValues(data, measures) {
|
|
26
|
+
var referenceMap = {};
|
|
27
|
+
measures === null || measures === void 0 ? void 0 : measures.forEach(function (measure) {
|
|
28
|
+
var measureKey = "".concat(measure.fieldName, "@").concat(measure.method);
|
|
29
|
+
var value = calculateImpactValue(data, measure);
|
|
30
|
+
referenceMap[measureKey] = value;
|
|
31
|
+
});
|
|
32
|
+
return referenceMap;
|
|
33
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { size } from 'lodash';
|
|
3
|
+
import { generateInsightChartSpec, changePointAugmentedMarksStrategy, trendAugmentedMarksStrategy, timeSeriesOutlierStrategyAugmentedMarksStrategy, lowVarianceAugmentedMarkStrategy, categoryOutlierAugmentedMarksStrategy, } from '../chart';
|
|
4
|
+
import { insightPatternsExtractor } from '../insights';
|
|
5
|
+
import generateInsightNarrative from '../narrative';
|
|
6
|
+
import { pickValidPattern, pickValidTimeSeriesOutlierPatterns } from '../insights/util';
|
|
7
|
+
import { insight2ChartStrategy, viewSpecStrategy } from '../chart/strategy';
|
|
8
|
+
export var patternInfo2InsightInfo = function (props) {
|
|
9
|
+
var dimensions = props.dimensions, measures = props.measures, data = props.data, patternInfos = props.patternInfos;
|
|
10
|
+
return {
|
|
11
|
+
subspace: [],
|
|
12
|
+
dimensions: dimensions,
|
|
13
|
+
measures: measures,
|
|
14
|
+
patterns: patternInfos,
|
|
15
|
+
data: data,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export var getAnnotationSpec = function (insightInfo) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var insightType = ((_a = insightInfo.patterns[0]) !== null && _a !== void 0 ? _a : {}).type;
|
|
21
|
+
var insightType2AugmentedMarks = {
|
|
22
|
+
trend: trendAugmentedMarksStrategy,
|
|
23
|
+
change_point: changePointAugmentedMarksStrategy,
|
|
24
|
+
time_series_outlier: timeSeriesOutlierStrategyAugmentedMarksStrategy,
|
|
25
|
+
low_variance: lowVarianceAugmentedMarkStrategy,
|
|
26
|
+
category_outlier: categoryOutlierAugmentedMarksStrategy,
|
|
27
|
+
};
|
|
28
|
+
return (_b = insightType2AugmentedMarks[insightType]) === null || _b === void 0 ? void 0 : _b.call(insightType2AugmentedMarks, insightInfo);
|
|
29
|
+
};
|
|
30
|
+
export var getChartSpecWithoutAugmentedMarks = function (insightInfo, insightType) {
|
|
31
|
+
var chartMark = insight2ChartStrategy(__assign(__assign({}, insightInfo), (size(insightInfo.patterns) === 0
|
|
32
|
+
? {
|
|
33
|
+
patterns: [{ type: insightType }],
|
|
34
|
+
}
|
|
35
|
+
: {})));
|
|
36
|
+
return viewSpecStrategy([chartMark], insightInfo);
|
|
37
|
+
};
|
|
38
|
+
export var filterValidInsightInfoForAnnotationSpec = function (_a) {
|
|
39
|
+
var _b = _a.patternInfos, patternInfos = _b === void 0 ? [] : _b, insightType = _a.insightType;
|
|
40
|
+
if (insightType === 'time_series_outlier')
|
|
41
|
+
return pickValidTimeSeriesOutlierPatterns(patternInfos);
|
|
42
|
+
return pickValidPattern(patternInfos);
|
|
43
|
+
};
|
|
44
|
+
export var getSpecificInsight = function (props) {
|
|
45
|
+
var _a = props.options, options = _a === void 0 ? {} : _a, insightType = props.insightType;
|
|
46
|
+
var _b = options.visualizationOptions, visualizationOptions = _b === void 0 ? { lang: 'zh-CN' } : _b;
|
|
47
|
+
var patternInfos = insightPatternsExtractor(props);
|
|
48
|
+
var validPatternInfos = filterValidInsightInfoForAnnotationSpec({ patternInfos: patternInfos, insightType: insightType });
|
|
49
|
+
var totalInsightInfo = patternInfo2InsightInfo(__assign(__assign({}, props), { patternInfos: patternInfos }));
|
|
50
|
+
if (size(validPatternInfos)) {
|
|
51
|
+
var validInsightInfo = patternInfo2InsightInfo(__assign(__assign({}, props), { patternInfos: validPatternInfos }));
|
|
52
|
+
var annotationSpec = getAnnotationSpec(validInsightInfo);
|
|
53
|
+
var chartSpec_1 = generateInsightChartSpec(validInsightInfo);
|
|
54
|
+
var narrativeSpec = generateInsightNarrative(validInsightInfo, visualizationOptions);
|
|
55
|
+
return __assign(__assign({}, totalInsightInfo), { visualizationSpecs: [
|
|
56
|
+
{
|
|
57
|
+
annotationSpec: annotationSpec,
|
|
58
|
+
chartSpec: chartSpec_1,
|
|
59
|
+
patternType: insightType,
|
|
60
|
+
narrativeSpec: narrativeSpec,
|
|
61
|
+
},
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
var chartSpec = getChartSpecWithoutAugmentedMarks(totalInsightInfo, insightType);
|
|
65
|
+
return __assign(__assign({}, totalInsightInfo), { visualizationSpecs: [
|
|
66
|
+
{
|
|
67
|
+
chartSpec: chartSpec,
|
|
68
|
+
patternType: insightType,
|
|
69
|
+
},
|
|
70
|
+
] });
|
|
71
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var insightPriorityComparator = function (a, b) {
|
|
2
|
+
return a.score - b.score;
|
|
3
|
+
};
|
|
4
|
+
export var homogeneousInsightPriorityComparator = function (a, b) { return a.score - b.score; };
|
|
5
|
+
export function addInsightsToHeap(insights, heap) {
|
|
6
|
+
insights === null || insights === void 0 ? void 0 : insights.forEach(function (item) {
|
|
7
|
+
if (heap.length >= heap.limit) {
|
|
8
|
+
heap.pushpop(item);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
heap.add(item);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __assign, __read } from "tslib";
|
|
2
|
+
import { groupBy, omit } from 'lodash';
|
|
3
|
+
import generateInsightNarrative from '../narrative';
|
|
4
|
+
import { generateInsightChartSpec } from '../chart';
|
|
5
|
+
export var generateInsightVisualizationSpec = function (insight, visualizationOptions) {
|
|
6
|
+
if (visualizationOptions === void 0) { visualizationOptions = {
|
|
7
|
+
lang: 'en-US',
|
|
8
|
+
}; }
|
|
9
|
+
var patterns = insight.patterns;
|
|
10
|
+
var specs = [];
|
|
11
|
+
if (!patterns.length)
|
|
12
|
+
return [];
|
|
13
|
+
var patternGroups = groupBy(patterns, function (pattern) { return pattern.type; });
|
|
14
|
+
Object.entries(patternGroups).forEach(function (_a) {
|
|
15
|
+
var _b = __read(_a, 2), patternType = _b[0], patternGroup = _b[1];
|
|
16
|
+
var chartSpec = generateInsightChartSpec(__assign(__assign({}, insight), { patterns: patternGroup }));
|
|
17
|
+
specs.push({
|
|
18
|
+
patternType: patternType,
|
|
19
|
+
chartSpec: chartSpec,
|
|
20
|
+
narrativeSpec: generateInsightNarrative(__assign(__assign({}, insight), { patterns: patternGroup }), visualizationOptions),
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return specs;
|
|
24
|
+
};
|
|
25
|
+
export var generateHomogeneousInsightVisualizationSpec = function (insight, visualizationOptions) {
|
|
26
|
+
if (visualizationOptions === void 0) { visualizationOptions = {
|
|
27
|
+
lang: 'en-US',
|
|
28
|
+
}; }
|
|
29
|
+
var patterns = insight.patterns;
|
|
30
|
+
var schemas = [];
|
|
31
|
+
patterns.forEach(function (pattern) {
|
|
32
|
+
var insightType = pattern.insightType;
|
|
33
|
+
var chartSpec = {};
|
|
34
|
+
schemas.push({
|
|
35
|
+
patternType: insightType,
|
|
36
|
+
chartSpec: chartSpec,
|
|
37
|
+
narrativeSpec: generateInsightNarrative(__assign(__assign({}, omit(insight, ['patterns'])), pattern), visualizationOptions),
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return schemas;
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { __assign, __read } from "tslib";
|
|
2
|
+
import { groupBy, sumBy, minBy, maxBy, meanBy, sortBy, flatten, uniq } from 'lodash';
|
|
3
|
+
var sum = function (data, measure) {
|
|
4
|
+
return sumBy(data, measure);
|
|
5
|
+
};
|
|
6
|
+
var count = function (data, measure) {
|
|
7
|
+
return data.filter(function (item) { return measure in item; }).length;
|
|
8
|
+
};
|
|
9
|
+
var countDistinct = function (data, measure) {
|
|
10
|
+
return uniq(data.filter(function (item) { return measure in item; }).map(function (item) { return item[measure]; })).length;
|
|
11
|
+
};
|
|
12
|
+
var max = function (data, measure) {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = maxBy(data, measure)) === null || _a === void 0 ? void 0 : _a[measure];
|
|
15
|
+
};
|
|
16
|
+
var min = function (data, measure) {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = minBy(data, measure)) === null || _a === void 0 ? void 0 : _a[measure];
|
|
19
|
+
};
|
|
20
|
+
var mean = function (data, measure) {
|
|
21
|
+
return meanBy(data, measure);
|
|
22
|
+
};
|
|
23
|
+
export var AggregatorMap = {
|
|
24
|
+
SUM: sum,
|
|
25
|
+
COUNT: count,
|
|
26
|
+
MAX: max,
|
|
27
|
+
MIN: min,
|
|
28
|
+
MEAN: mean,
|
|
29
|
+
COUNT_DISTINCT: countDistinct,
|
|
30
|
+
};
|
|
31
|
+
export function aggregate(data, groupByField, measures, sort) {
|
|
32
|
+
var grouped = groupBy(data, groupByField);
|
|
33
|
+
var entries = sort ? sortBy(Object.entries(grouped), '0') : Object.entries(grouped);
|
|
34
|
+
return entries.map(function (_a) {
|
|
35
|
+
var _b;
|
|
36
|
+
var _c = __read(_a, 2), value = _c[0], dataGroup = _c[1];
|
|
37
|
+
var datum = (_b = {}, _b[groupByField] = value, _b);
|
|
38
|
+
measures.forEach(function (measure) {
|
|
39
|
+
var measureField = measure.fieldName, method = measure.method;
|
|
40
|
+
var aggregator = AggregatorMap[method];
|
|
41
|
+
datum[measureField] = aggregator(dataGroup, measureField);
|
|
42
|
+
});
|
|
43
|
+
return datum;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function aggregateWithMeasures(data, groupByField, measures) {
|
|
47
|
+
var grouped = groupBy(data, groupByField);
|
|
48
|
+
var result = [];
|
|
49
|
+
Object.entries(grouped).forEach(function (_a) {
|
|
50
|
+
var _b = __read(_a, 2), value = _b[0], dataGroup = _b[1];
|
|
51
|
+
measures.forEach(function (measure) {
|
|
52
|
+
var _a;
|
|
53
|
+
var measureField = measure.fieldName, method = measure.method;
|
|
54
|
+
if (measureField in dataGroup[0]) {
|
|
55
|
+
var aggregator = AggregatorMap[method];
|
|
56
|
+
var measureValue = aggregator(dataGroup, measureField);
|
|
57
|
+
result.push((_a = {},
|
|
58
|
+
_a[groupByField] = value,
|
|
59
|
+
_a.value = measureValue,
|
|
60
|
+
_a.measureName = measureField,
|
|
61
|
+
_a));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
export function aggregateWithSeries(data, groupByField, measure, expandingField) {
|
|
68
|
+
var grouped = groupBy(data, groupByField);
|
|
69
|
+
var measureField = measure.fieldName, method = measure.method;
|
|
70
|
+
var aggregator = AggregatorMap[method];
|
|
71
|
+
return flatten(Object.entries(grouped).map(function (_a) {
|
|
72
|
+
var _b = __read(_a, 2), value = _b[0], dataGroup = _b[1];
|
|
73
|
+
var childGrouped = groupBy(dataGroup, expandingField);
|
|
74
|
+
var part = Object.entries(childGrouped).map(function (_a) {
|
|
75
|
+
var _b;
|
|
76
|
+
var _c = __read(_a, 2), childValue = _c[0], childDataGroup = _c[1];
|
|
77
|
+
return _b = {},
|
|
78
|
+
_b[expandingField] = childValue,
|
|
79
|
+
_b[measureField] = aggregator(childDataGroup, measureField),
|
|
80
|
+
_b;
|
|
81
|
+
});
|
|
82
|
+
return part.map(function (item) {
|
|
83
|
+
var _a;
|
|
84
|
+
return __assign(__assign({}, item), (_a = {}, _a[groupByField] = value, _a));
|
|
85
|
+
});
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { lastIndexOf } from 'lodash';
|
|
2
|
+
// sign
|
|
3
|
+
export function sign(value) {
|
|
4
|
+
if (value > 0)
|
|
5
|
+
return 1;
|
|
6
|
+
return value < 0 ? -1 : 0;
|
|
7
|
+
}
|
|
8
|
+
// unique
|
|
9
|
+
export function unique(arr) {
|
|
10
|
+
var sorted = arr.slice().sort();
|
|
11
|
+
var uniqArr = [sorted[0]];
|
|
12
|
+
var countArr = [1];
|
|
13
|
+
for (var i = 1; i < sorted.length; i += 1) {
|
|
14
|
+
if (sorted[i] !== uniqArr[uniqArr.length - 1]) {
|
|
15
|
+
uniqArr.push(sorted[i]);
|
|
16
|
+
countArr.push(1);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
countArr[countArr.length - 1] += 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [uniqArr, countArr];
|
|
23
|
+
}
|
|
24
|
+
// rank
|
|
25
|
+
export function rank(arr) {
|
|
26
|
+
var sorted = arr.slice().sort();
|
|
27
|
+
var rank = [];
|
|
28
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
29
|
+
var value = arr[i];
|
|
30
|
+
var firstRank = sorted.indexOf(value) + 1;
|
|
31
|
+
var lastRank = lastIndexOf(sorted, value) + 1;
|
|
32
|
+
rank.push(firstRank === lastRank ? firstRank : (firstRank + lastRank) / 2);
|
|
33
|
+
}
|
|
34
|
+
return rank;
|
|
35
|
+
}
|