@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,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSpecificInsight = exports.filterValidInsightInfoForAnnotationSpec = exports.getChartSpecWithoutAugmentedMarks = exports.getAnnotationSpec = exports.patternInfo2InsightInfo = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var chart_1 = require("../chart");
|
|
7
|
+
var insights_1 = require("../insights");
|
|
8
|
+
var narrative_1 = tslib_1.__importDefault(require("../narrative"));
|
|
9
|
+
var util_1 = require("../insights/util");
|
|
10
|
+
var strategy_1 = require("../chart/strategy");
|
|
11
|
+
var patternInfo2InsightInfo = function (props) {
|
|
12
|
+
var dimensions = props.dimensions, measures = props.measures, data = props.data, patternInfos = props.patternInfos;
|
|
13
|
+
return {
|
|
14
|
+
subspace: [],
|
|
15
|
+
dimensions: dimensions,
|
|
16
|
+
measures: measures,
|
|
17
|
+
patterns: patternInfos,
|
|
18
|
+
data: data,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.patternInfo2InsightInfo = patternInfo2InsightInfo;
|
|
22
|
+
var getAnnotationSpec = function (insightInfo) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
var insightType = ((_a = insightInfo.patterns[0]) !== null && _a !== void 0 ? _a : {}).type;
|
|
25
|
+
var insightType2AugmentedMarks = {
|
|
26
|
+
trend: chart_1.trendAugmentedMarksStrategy,
|
|
27
|
+
change_point: chart_1.changePointAugmentedMarksStrategy,
|
|
28
|
+
time_series_outlier: chart_1.timeSeriesOutlierStrategyAugmentedMarksStrategy,
|
|
29
|
+
low_variance: chart_1.lowVarianceAugmentedMarkStrategy,
|
|
30
|
+
category_outlier: chart_1.categoryOutlierAugmentedMarksStrategy,
|
|
31
|
+
};
|
|
32
|
+
return (_b = insightType2AugmentedMarks[insightType]) === null || _b === void 0 ? void 0 : _b.call(insightType2AugmentedMarks, insightInfo);
|
|
33
|
+
};
|
|
34
|
+
exports.getAnnotationSpec = getAnnotationSpec;
|
|
35
|
+
var getChartSpecWithoutAugmentedMarks = function (insightInfo, insightType) {
|
|
36
|
+
var chartMark = (0, strategy_1.insight2ChartStrategy)(tslib_1.__assign(tslib_1.__assign({}, insightInfo), ((0, lodash_1.size)(insightInfo.patterns) === 0
|
|
37
|
+
? {
|
|
38
|
+
patterns: [{ type: insightType }],
|
|
39
|
+
}
|
|
40
|
+
: {})));
|
|
41
|
+
return (0, strategy_1.viewSpecStrategy)([chartMark], insightInfo);
|
|
42
|
+
};
|
|
43
|
+
exports.getChartSpecWithoutAugmentedMarks = getChartSpecWithoutAugmentedMarks;
|
|
44
|
+
var filterValidInsightInfoForAnnotationSpec = function (_a) {
|
|
45
|
+
var _b = _a.patternInfos, patternInfos = _b === void 0 ? [] : _b, insightType = _a.insightType;
|
|
46
|
+
if (insightType === 'time_series_outlier')
|
|
47
|
+
return (0, util_1.pickValidTimeSeriesOutlierPatterns)(patternInfos);
|
|
48
|
+
return (0, util_1.pickValidPattern)(patternInfos);
|
|
49
|
+
};
|
|
50
|
+
exports.filterValidInsightInfoForAnnotationSpec = filterValidInsightInfoForAnnotationSpec;
|
|
51
|
+
var getSpecificInsight = function (props) {
|
|
52
|
+
var _a = props.options, options = _a === void 0 ? {} : _a, insightType = props.insightType;
|
|
53
|
+
var _b = options.visualizationOptions, visualizationOptions = _b === void 0 ? { lang: 'zh-CN' } : _b;
|
|
54
|
+
var patternInfos = (0, insights_1.insightPatternsExtractor)(props);
|
|
55
|
+
var validPatternInfos = (0, exports.filterValidInsightInfoForAnnotationSpec)({ patternInfos: patternInfos, insightType: insightType });
|
|
56
|
+
var totalInsightInfo = (0, exports.patternInfo2InsightInfo)(tslib_1.__assign(tslib_1.__assign({}, props), { patternInfos: patternInfos }));
|
|
57
|
+
if ((0, lodash_1.size)(validPatternInfos)) {
|
|
58
|
+
var validInsightInfo = (0, exports.patternInfo2InsightInfo)(tslib_1.__assign(tslib_1.__assign({}, props), { patternInfos: validPatternInfos }));
|
|
59
|
+
var annotationSpec = (0, exports.getAnnotationSpec)(validInsightInfo);
|
|
60
|
+
var chartSpec_1 = (0, chart_1.generateInsightChartSpec)(validInsightInfo);
|
|
61
|
+
var narrativeSpec = (0, narrative_1.default)(validInsightInfo, visualizationOptions);
|
|
62
|
+
return tslib_1.__assign(tslib_1.__assign({}, totalInsightInfo), { visualizationSpecs: [
|
|
63
|
+
{
|
|
64
|
+
annotationSpec: annotationSpec,
|
|
65
|
+
chartSpec: chartSpec_1,
|
|
66
|
+
patternType: insightType,
|
|
67
|
+
narrativeSpec: narrativeSpec,
|
|
68
|
+
},
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
var chartSpec = (0, exports.getChartSpecWithoutAugmentedMarks)(totalInsightInfo, insightType);
|
|
72
|
+
return tslib_1.__assign(tslib_1.__assign({}, totalInsightInfo), { visualizationSpecs: [
|
|
73
|
+
{
|
|
74
|
+
chartSpec: chartSpec,
|
|
75
|
+
patternType: insightType,
|
|
76
|
+
},
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
exports.getSpecificInsight = getSpecificInsight;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Heap from 'heap-js';
|
|
2
|
+
import type { InsightInfo, PatternInfo, HomogeneousPatternInfo } from '../types';
|
|
3
|
+
export declare const insightPriorityComparator: (a: InsightInfo<PatternInfo>, b: InsightInfo<PatternInfo>) => number;
|
|
4
|
+
export declare const homogeneousInsightPriorityComparator: (a: InsightInfo<HomogeneousPatternInfo>, b: InsightInfo<HomogeneousPatternInfo>) => number;
|
|
5
|
+
export declare function addInsightsToHeap(insights: InsightInfo<PatternInfo>[], heap: Heap<InsightInfo<PatternInfo>>): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addInsightsToHeap = exports.homogeneousInsightPriorityComparator = exports.insightPriorityComparator = void 0;
|
|
4
|
+
var insightPriorityComparator = function (a, b) {
|
|
5
|
+
return a.score - b.score;
|
|
6
|
+
};
|
|
7
|
+
exports.insightPriorityComparator = insightPriorityComparator;
|
|
8
|
+
var homogeneousInsightPriorityComparator = function (a, b) { return a.score - b.score; };
|
|
9
|
+
exports.homogeneousInsightPriorityComparator = homogeneousInsightPriorityComparator;
|
|
10
|
+
function addInsightsToHeap(insights, heap) {
|
|
11
|
+
insights === null || insights === void 0 ? void 0 : insights.forEach(function (item) {
|
|
12
|
+
if (heap.length >= heap.limit) {
|
|
13
|
+
heap.pushpop(item);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
heap.add(item);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.addInsightsToHeap = addInsightsToHeap;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { HomogeneousPatternInfo, InsightInfo, PatternInfo, InsightVisualizationOptions, InsightVisualizationSpec } from '../types';
|
|
2
|
+
export declare const generateInsightVisualizationSpec: (insight: InsightInfo<PatternInfo>, visualizationOptions?: InsightVisualizationOptions) => InsightVisualizationSpec[];
|
|
3
|
+
export declare const generateHomogeneousInsightVisualizationSpec: (insight: InsightInfo<HomogeneousPatternInfo>, visualizationOptions?: InsightVisualizationOptions) => InsightVisualizationSpec[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateHomogeneousInsightVisualizationSpec = exports.generateInsightVisualizationSpec = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var narrative_1 = tslib_1.__importDefault(require("../narrative"));
|
|
7
|
+
var chart_1 = require("../chart");
|
|
8
|
+
var generateInsightVisualizationSpec = function (insight, visualizationOptions) {
|
|
9
|
+
if (visualizationOptions === void 0) { visualizationOptions = {
|
|
10
|
+
lang: 'en-US',
|
|
11
|
+
}; }
|
|
12
|
+
var patterns = insight.patterns;
|
|
13
|
+
var specs = [];
|
|
14
|
+
if (!patterns.length)
|
|
15
|
+
return [];
|
|
16
|
+
var patternGroups = (0, lodash_1.groupBy)(patterns, function (pattern) { return pattern.type; });
|
|
17
|
+
Object.entries(patternGroups).forEach(function (_a) {
|
|
18
|
+
var _b = tslib_1.__read(_a, 2), patternType = _b[0], patternGroup = _b[1];
|
|
19
|
+
var chartSpec = (0, chart_1.generateInsightChartSpec)(tslib_1.__assign(tslib_1.__assign({}, insight), { patterns: patternGroup }));
|
|
20
|
+
specs.push({
|
|
21
|
+
patternType: patternType,
|
|
22
|
+
chartSpec: chartSpec,
|
|
23
|
+
narrativeSpec: (0, narrative_1.default)(tslib_1.__assign(tslib_1.__assign({}, insight), { patterns: patternGroup }), visualizationOptions),
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return specs;
|
|
27
|
+
};
|
|
28
|
+
exports.generateInsightVisualizationSpec = generateInsightVisualizationSpec;
|
|
29
|
+
var generateHomogeneousInsightVisualizationSpec = function (insight, visualizationOptions) {
|
|
30
|
+
if (visualizationOptions === void 0) { visualizationOptions = {
|
|
31
|
+
lang: 'en-US',
|
|
32
|
+
}; }
|
|
33
|
+
var patterns = insight.patterns;
|
|
34
|
+
var schemas = [];
|
|
35
|
+
patterns.forEach(function (pattern) {
|
|
36
|
+
var insightType = pattern.insightType;
|
|
37
|
+
var chartSpec = {};
|
|
38
|
+
schemas.push({
|
|
39
|
+
patternType: insightType,
|
|
40
|
+
chartSpec: chartSpec,
|
|
41
|
+
narrativeSpec: (0, narrative_1.default)(tslib_1.__assign(tslib_1.__assign({}, (0, lodash_1.omit)(insight, ['patterns'])), pattern), visualizationOptions),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return schemas;
|
|
45
|
+
};
|
|
46
|
+
exports.generateHomogeneousInsightVisualizationSpec = generateHomogeneousInsightVisualizationSpec;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { PCorrTestParameter } from '../data/statistics/types';
|
|
2
|
+
import { PATTERN_TYPES, HOMOGENEOUS_PATTERN_TYPES } from './constant';
|
|
3
|
+
import { AugmentedMarks } from './chart/types';
|
|
4
|
+
import type { G2Spec } from '@antv/g2';
|
|
5
|
+
import type { ParagraphSpec } from '../ntv/types';
|
|
6
|
+
import type { NumberFieldInfo, DateFieldInfo, StringFieldInfo, Extra } from '../data/types';
|
|
7
|
+
export type Datum = Record<string, string | number>;
|
|
8
|
+
export type DomainType = 'measure' | 'dimension';
|
|
9
|
+
export type MeasureMethod = 'SUM' | 'COUNT' | 'MAX' | 'MIN' | 'MEAN' | 'COUNT_DISTINCT';
|
|
10
|
+
export type ImpactMeasureMethod = 'SUM' | 'COUNT';
|
|
11
|
+
export type Aggregator = (data: Datum[], measure: string) => number;
|
|
12
|
+
/** output of data module, plus the field name and its domain type */
|
|
13
|
+
export type DataProperty = (NumberFieldInfo | DateFieldInfo | StringFieldInfo) & {
|
|
14
|
+
/** field name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** whether this field is used as a dimension or measure */
|
|
17
|
+
domainType: DomainType;
|
|
18
|
+
};
|
|
19
|
+
export type Measure = {
|
|
20
|
+
/** use the field name as uniq key */
|
|
21
|
+
fieldName: string;
|
|
22
|
+
method: MeasureMethod;
|
|
23
|
+
};
|
|
24
|
+
export type Dimension = {
|
|
25
|
+
/** use the field name as uniq key */
|
|
26
|
+
fieldName: string;
|
|
27
|
+
};
|
|
28
|
+
export type Subspace = {
|
|
29
|
+
dimension: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}[];
|
|
32
|
+
export type ImpactMeasure = {
|
|
33
|
+
fieldName: string;
|
|
34
|
+
method: ImpactMeasureMethod;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* insight data subject information
|
|
38
|
+
*/
|
|
39
|
+
export interface SubjectInfo {
|
|
40
|
+
subspace: Subspace;
|
|
41
|
+
dimensions: string[];
|
|
42
|
+
measures: Measure[];
|
|
43
|
+
}
|
|
44
|
+
export type InsightType = (typeof PATTERN_TYPES)[number];
|
|
45
|
+
export type HomogeneousInsightType = (typeof HOMOGENEOUS_PATTERN_TYPES)[number];
|
|
46
|
+
/** insight chart type recommendation */
|
|
47
|
+
export type ChartType = 'column_chart' | 'line_chart' | 'pie_chart' | 'scatter_plot';
|
|
48
|
+
/** pattern information */
|
|
49
|
+
export type PatternInfo = CategoryOutlierInfo | TimeSeriesOutlierInfo | LowVarianceInfo | TrendInfo | ChangePointInfo | CorrelationInfo | MajorityInfo;
|
|
50
|
+
/** explanation and visualization for insight */
|
|
51
|
+
export interface InsightVisualizationSpec {
|
|
52
|
+
patternType: InsightType;
|
|
53
|
+
chartSpec: G2Spec;
|
|
54
|
+
/** augmented marks */
|
|
55
|
+
annotationSpec?: AugmentedMarks;
|
|
56
|
+
/**
|
|
57
|
+
* @description explain insight by text
|
|
58
|
+
* @default ParagraphSpec[]
|
|
59
|
+
*/
|
|
60
|
+
narrativeSpec?: ParagraphSpec[];
|
|
61
|
+
}
|
|
62
|
+
/** output insight information */
|
|
63
|
+
export interface InsightInfo<T = PatternInfo> {
|
|
64
|
+
subspace: Subspace;
|
|
65
|
+
dimensions: Dimension[];
|
|
66
|
+
measures: Measure[];
|
|
67
|
+
score?: number;
|
|
68
|
+
data: Datum[];
|
|
69
|
+
patterns: T[];
|
|
70
|
+
visualizationSpecs?: InsightVisualizationSpec[];
|
|
71
|
+
}
|
|
72
|
+
export type Language = 'zh-CN' | 'en-US';
|
|
73
|
+
/**
|
|
74
|
+
* config of visualization
|
|
75
|
+
*/
|
|
76
|
+
export type InsightVisualizationOptions = {
|
|
77
|
+
/**
|
|
78
|
+
* @description pure text or text specification to description insight summary
|
|
79
|
+
* @default 'text'
|
|
80
|
+
* */
|
|
81
|
+
/**
|
|
82
|
+
* @description explain insight use which language
|
|
83
|
+
* @default 'en-US'
|
|
84
|
+
* @experimental Using natural language to describe insights is an experimental feature and the output may be subject to change.
|
|
85
|
+
*/
|
|
86
|
+
lang: Language;
|
|
87
|
+
};
|
|
88
|
+
export type LowVarianceParameter = {
|
|
89
|
+
/** Default value is 0.15 */
|
|
90
|
+
cvThreshold?: number;
|
|
91
|
+
};
|
|
92
|
+
export type MajorityParameter = {
|
|
93
|
+
/** Proportion greater than limit is considered as significant. Default value is 0.6 */
|
|
94
|
+
limit?: number;
|
|
95
|
+
};
|
|
96
|
+
export type OutlierParameter = {
|
|
97
|
+
/**
|
|
98
|
+
* - IQR: Inter Quartile Range method which is used by default. A point is considered an outlier when it lies outside of iqrK times the inter quartile range.
|
|
99
|
+
* - p-value: Assuming that the data follows a normal distribution, a point is considered an outlier if the two-sided test p-value is less than 1-confidenceInterval.
|
|
100
|
+
* */
|
|
101
|
+
method?: 'IQR' | 'p-value';
|
|
102
|
+
/** Parameter of Inter Quartile Range method. Default value is 1.5. */
|
|
103
|
+
iqrK?: number;
|
|
104
|
+
/** Parameter of p-value method. Default value is 0.95. */
|
|
105
|
+
confidenceInterval?: number;
|
|
106
|
+
};
|
|
107
|
+
export type CommonParameter = {
|
|
108
|
+
/** Significance level (alpha) in hypothesis testing */
|
|
109
|
+
threshold?: number;
|
|
110
|
+
};
|
|
111
|
+
/** Key parameters in the algorithm for extracting insights */
|
|
112
|
+
export type AlgorithmParameter = {
|
|
113
|
+
/**
|
|
114
|
+
* Contains both category outlier and time series outlier
|
|
115
|
+
* */
|
|
116
|
+
outlier?: OutlierParameter;
|
|
117
|
+
/** time series trend, Default value of significance is 0.05 */
|
|
118
|
+
trend?: CommonParameter;
|
|
119
|
+
/** Significance level (alpha) in Bayesian online change point detection. Default value is 0.15 */
|
|
120
|
+
changePoint?: CommonParameter;
|
|
121
|
+
correlation?: PCorrTestParameter;
|
|
122
|
+
lowVariance?: LowVarianceParameter;
|
|
123
|
+
majority?: MajorityParameter;
|
|
124
|
+
};
|
|
125
|
+
export type InsightExtractorOptions = Pick<InsightOptions, 'algorithmParameter' | 'dataProcessInfo'> & {
|
|
126
|
+
/** Whether to filter non-significant insights. The default is false. */
|
|
127
|
+
filterInsight?: boolean;
|
|
128
|
+
/** Whether data length, type, etc. need to be verified. The default is false. */
|
|
129
|
+
dataValidation?: boolean;
|
|
130
|
+
visualizationOptions?: InsightVisualizationOptions;
|
|
131
|
+
};
|
|
132
|
+
export type InsightExtractorProps = {
|
|
133
|
+
data: Datum[];
|
|
134
|
+
dimensions: Dimension[];
|
|
135
|
+
measures: Measure[];
|
|
136
|
+
insightType: InsightType;
|
|
137
|
+
options?: InsightExtractorOptions;
|
|
138
|
+
};
|
|
139
|
+
export type PreValidationProps = Omit<InsightExtractorProps, 'algorithmParameter'>;
|
|
140
|
+
export type GetPatternInfo<T = PatternInfo> = (props: InsightExtractorProps) => T[] | [NoPatternInfo];
|
|
141
|
+
export type AlgorithmStandardInput = {
|
|
142
|
+
dimension: string;
|
|
143
|
+
measure: string;
|
|
144
|
+
values: number[];
|
|
145
|
+
};
|
|
146
|
+
/** custom options */
|
|
147
|
+
export interface InsightOptions {
|
|
148
|
+
/** dimensions for analysis */
|
|
149
|
+
dimensions?: Dimension[];
|
|
150
|
+
/** measures for analysis */
|
|
151
|
+
measures?: Measure[];
|
|
152
|
+
/** Measures for Impact score */
|
|
153
|
+
impactMeasures?: ImpactMeasure[];
|
|
154
|
+
/** Insight score = Impact score * impactWeight + Significance * (1 - impactWeight) */
|
|
155
|
+
impactWeight?: number;
|
|
156
|
+
/** types of insight */
|
|
157
|
+
insightTypes?: InsightType[];
|
|
158
|
+
/** Limit on the number of insights */
|
|
159
|
+
limit?: number;
|
|
160
|
+
/** on / off the output of visualization scheme */
|
|
161
|
+
visualization?: boolean | Partial<InsightVisualizationOptions>;
|
|
162
|
+
/** on/off extra homogeneous insight extraction */
|
|
163
|
+
homogeneous?: boolean;
|
|
164
|
+
/** Whether to close the search for subspaces */
|
|
165
|
+
ignoreSubspace?: boolean;
|
|
166
|
+
/** Parameter passed through to the data frame during data pre-processing */
|
|
167
|
+
dataProcessInfo?: Extra;
|
|
168
|
+
/** Key parameters in the algorithm for extracting insights */
|
|
169
|
+
algorithmParameter?: AlgorithmParameter;
|
|
170
|
+
}
|
|
171
|
+
export interface BasePatternInfo<T extends InsightType> {
|
|
172
|
+
type: T;
|
|
173
|
+
significance: number;
|
|
174
|
+
/** Significant insight at the specified significance threshold */
|
|
175
|
+
significantInsight?: boolean;
|
|
176
|
+
info?: string;
|
|
177
|
+
}
|
|
178
|
+
export interface HomogeneousPatternInfo {
|
|
179
|
+
type: HomogeneousInsightType;
|
|
180
|
+
significance: number;
|
|
181
|
+
insightType: InsightType;
|
|
182
|
+
childPatterns: PatternInfo[];
|
|
183
|
+
/** dimension values that share same patterns */
|
|
184
|
+
commonSet: string[];
|
|
185
|
+
/** dimension values that do not share same patterns with others */
|
|
186
|
+
exceptions?: string[];
|
|
187
|
+
}
|
|
188
|
+
export type PointPatternInfo = {
|
|
189
|
+
index: number;
|
|
190
|
+
dimension: string;
|
|
191
|
+
measure: string;
|
|
192
|
+
x: string | number;
|
|
193
|
+
y: number;
|
|
194
|
+
};
|
|
195
|
+
export type TimeSeriesInfo = {
|
|
196
|
+
baselines: number[];
|
|
197
|
+
thresholds: [number, number];
|
|
198
|
+
};
|
|
199
|
+
export type CategoryOutlierInfo = BasePatternInfo<'category_outlier'> & PointPatternInfo;
|
|
200
|
+
export type TimeSeriesOutlierInfo = BasePatternInfo<'time_series_outlier'> & PointPatternInfo & TimeSeriesInfo;
|
|
201
|
+
export type ChangePointInfo = BasePatternInfo<'change_point'> & PointPatternInfo;
|
|
202
|
+
export type MajorityInfo = BasePatternInfo<'majority'> & PointPatternInfo & {
|
|
203
|
+
proportion: number;
|
|
204
|
+
};
|
|
205
|
+
export type TrendType = 'decreasing' | 'increasing' | 'no trend';
|
|
206
|
+
export interface LinearRegressionResult {
|
|
207
|
+
r2: number;
|
|
208
|
+
points: number[];
|
|
209
|
+
equation: [m: number, c: number];
|
|
210
|
+
}
|
|
211
|
+
export type TrendInfo = BasePatternInfo<'trend'> & {
|
|
212
|
+
trend: TrendType;
|
|
213
|
+
regression: LinearRegressionResult;
|
|
214
|
+
dimension: string;
|
|
215
|
+
measure: string;
|
|
216
|
+
};
|
|
217
|
+
export type LowVarianceInfo = BasePatternInfo<'low_variance'> & {
|
|
218
|
+
dimension: string;
|
|
219
|
+
measure: string;
|
|
220
|
+
mean: number;
|
|
221
|
+
};
|
|
222
|
+
export type CorrelationInfo = BasePatternInfo<'correlation'> & {
|
|
223
|
+
pcorr: number;
|
|
224
|
+
measures: [string, string];
|
|
225
|
+
};
|
|
226
|
+
export type NoPatternInfo = BasePatternInfo<InsightType> & {
|
|
227
|
+
info: string;
|
|
228
|
+
[key: string]: any;
|
|
229
|
+
};
|
|
230
|
+
export type InsightsResult = {
|
|
231
|
+
insights: InsightInfo<PatternInfo>[];
|
|
232
|
+
homogeneousInsights?: InsightInfo<HomogeneousPatternInfo>[];
|
|
233
|
+
};
|
|
234
|
+
export type SpecificInsightProps = InsightExtractorProps;
|
|
235
|
+
export type SpecificInsightResult = Required<Omit<InsightInfo<PatternInfo>, 'score'>>;
|
|
236
|
+
export type PatternInfo2InsightInfoProps = SpecificInsightProps & {
|
|
237
|
+
patternInfos: PatternInfo[];
|
|
238
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Aggregator, Datum, Measure, MeasureMethod } from '../types';
|
|
2
|
+
export declare const AggregatorMap: Record<MeasureMethod, Aggregator>;
|
|
3
|
+
export declare function aggregate(data: Datum[], groupByField: string, measures: Measure[], sort?: boolean): Datum[];
|
|
4
|
+
export declare function aggregateWithMeasures(data: Datum[], groupByField: string, measures: Measure[]): Datum[];
|
|
5
|
+
export declare function aggregateWithSeries(data: Datum[], groupByField: string, measure: Measure, expandingField: string): {
|
|
6
|
+
[x: string]: string | number;
|
|
7
|
+
}[];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.aggregateWithSeries = exports.aggregateWithMeasures = exports.aggregate = exports.AggregatorMap = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var sum = function (data, measure) {
|
|
7
|
+
return (0, lodash_1.sumBy)(data, measure);
|
|
8
|
+
};
|
|
9
|
+
var count = function (data, measure) {
|
|
10
|
+
return data.filter(function (item) { return measure in item; }).length;
|
|
11
|
+
};
|
|
12
|
+
var countDistinct = function (data, measure) {
|
|
13
|
+
return (0, lodash_1.uniq)(data.filter(function (item) { return measure in item; }).map(function (item) { return item[measure]; })).length;
|
|
14
|
+
};
|
|
15
|
+
var max = function (data, measure) {
|
|
16
|
+
var _a;
|
|
17
|
+
return (_a = (0, lodash_1.maxBy)(data, measure)) === null || _a === void 0 ? void 0 : _a[measure];
|
|
18
|
+
};
|
|
19
|
+
var min = function (data, measure) {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = (0, lodash_1.minBy)(data, measure)) === null || _a === void 0 ? void 0 : _a[measure];
|
|
22
|
+
};
|
|
23
|
+
var mean = function (data, measure) {
|
|
24
|
+
return (0, lodash_1.meanBy)(data, measure);
|
|
25
|
+
};
|
|
26
|
+
exports.AggregatorMap = {
|
|
27
|
+
SUM: sum,
|
|
28
|
+
COUNT: count,
|
|
29
|
+
MAX: max,
|
|
30
|
+
MIN: min,
|
|
31
|
+
MEAN: mean,
|
|
32
|
+
COUNT_DISTINCT: countDistinct,
|
|
33
|
+
};
|
|
34
|
+
function aggregate(data, groupByField, measures, sort) {
|
|
35
|
+
var grouped = (0, lodash_1.groupBy)(data, groupByField);
|
|
36
|
+
var entries = sort ? (0, lodash_1.sortBy)(Object.entries(grouped), '0') : Object.entries(grouped);
|
|
37
|
+
return entries.map(function (_a) {
|
|
38
|
+
var _b;
|
|
39
|
+
var _c = tslib_1.__read(_a, 2), value = _c[0], dataGroup = _c[1];
|
|
40
|
+
var datum = (_b = {}, _b[groupByField] = value, _b);
|
|
41
|
+
measures.forEach(function (measure) {
|
|
42
|
+
var measureField = measure.fieldName, method = measure.method;
|
|
43
|
+
var aggregator = exports.AggregatorMap[method];
|
|
44
|
+
datum[measureField] = aggregator(dataGroup, measureField);
|
|
45
|
+
});
|
|
46
|
+
return datum;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.aggregate = aggregate;
|
|
50
|
+
function aggregateWithMeasures(data, groupByField, measures) {
|
|
51
|
+
var grouped = (0, lodash_1.groupBy)(data, groupByField);
|
|
52
|
+
var result = [];
|
|
53
|
+
Object.entries(grouped).forEach(function (_a) {
|
|
54
|
+
var _b = tslib_1.__read(_a, 2), value = _b[0], dataGroup = _b[1];
|
|
55
|
+
measures.forEach(function (measure) {
|
|
56
|
+
var _a;
|
|
57
|
+
var measureField = measure.fieldName, method = measure.method;
|
|
58
|
+
if (measureField in dataGroup[0]) {
|
|
59
|
+
var aggregator = exports.AggregatorMap[method];
|
|
60
|
+
var measureValue = aggregator(dataGroup, measureField);
|
|
61
|
+
result.push((_a = {},
|
|
62
|
+
_a[groupByField] = value,
|
|
63
|
+
_a.value = measureValue,
|
|
64
|
+
_a.measureName = measureField,
|
|
65
|
+
_a));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
exports.aggregateWithMeasures = aggregateWithMeasures;
|
|
72
|
+
function aggregateWithSeries(data, groupByField, measure, expandingField) {
|
|
73
|
+
var grouped = (0, lodash_1.groupBy)(data, groupByField);
|
|
74
|
+
var measureField = measure.fieldName, method = measure.method;
|
|
75
|
+
var aggregator = exports.AggregatorMap[method];
|
|
76
|
+
return (0, lodash_1.flatten)(Object.entries(grouped).map(function (_a) {
|
|
77
|
+
var _b = tslib_1.__read(_a, 2), value = _b[0], dataGroup = _b[1];
|
|
78
|
+
var childGrouped = (0, lodash_1.groupBy)(dataGroup, expandingField);
|
|
79
|
+
var part = Object.entries(childGrouped).map(function (_a) {
|
|
80
|
+
var _b;
|
|
81
|
+
var _c = tslib_1.__read(_a, 2), childValue = _c[0], childDataGroup = _c[1];
|
|
82
|
+
return _b = {},
|
|
83
|
+
_b[expandingField] = childValue,
|
|
84
|
+
_b[measureField] = aggregator(childDataGroup, measureField),
|
|
85
|
+
_b;
|
|
86
|
+
});
|
|
87
|
+
return part.map(function (item) {
|
|
88
|
+
var _a;
|
|
89
|
+
return tslib_1.__assign(tslib_1.__assign({}, item), (_a = {}, _a[groupByField] = value, _a));
|
|
90
|
+
});
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
exports.aggregateWithSeries = aggregateWithSeries;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rank = exports.unique = exports.sign = void 0;
|
|
4
|
+
var lodash_1 = require("lodash");
|
|
5
|
+
// sign
|
|
6
|
+
function sign(value) {
|
|
7
|
+
if (value > 0)
|
|
8
|
+
return 1;
|
|
9
|
+
return value < 0 ? -1 : 0;
|
|
10
|
+
}
|
|
11
|
+
exports.sign = sign;
|
|
12
|
+
// unique
|
|
13
|
+
function unique(arr) {
|
|
14
|
+
var sorted = arr.slice().sort();
|
|
15
|
+
var uniqArr = [sorted[0]];
|
|
16
|
+
var countArr = [1];
|
|
17
|
+
for (var i = 1; i < sorted.length; i += 1) {
|
|
18
|
+
if (sorted[i] !== uniqArr[uniqArr.length - 1]) {
|
|
19
|
+
uniqArr.push(sorted[i]);
|
|
20
|
+
countArr.push(1);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
countArr[countArr.length - 1] += 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return [uniqArr, countArr];
|
|
27
|
+
}
|
|
28
|
+
exports.unique = unique;
|
|
29
|
+
// rank
|
|
30
|
+
function rank(arr) {
|
|
31
|
+
var sorted = arr.slice().sort();
|
|
32
|
+
var rank = [];
|
|
33
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
34
|
+
var value = arr[i];
|
|
35
|
+
var firstRank = sorted.indexOf(value) + 1;
|
|
36
|
+
var lastRank = (0, lodash_1.lastIndexOf)(sorted, value) + 1;
|
|
37
|
+
rank.push(firstRank === lastRank ? firstRank : (firstRank + lastRank) / 2);
|
|
38
|
+
}
|
|
39
|
+
return rank;
|
|
40
|
+
}
|
|
41
|
+
exports.rank = rank;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NarrativeTextSpec } from '../schema';
|
|
2
|
+
import type { Variable, Structure, StructureTemp } from './types';
|
|
3
|
+
type GenerateParams = {
|
|
4
|
+
variable: Variable;
|
|
5
|
+
structures: Structure[];
|
|
6
|
+
structureTemps?: StructureTemp[];
|
|
7
|
+
};
|
|
8
|
+
export default function generateTextSpec(params: GenerateParams): NarrativeTextSpec;
|
|
9
|
+
export {};
|