@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,42 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { size } from 'lodash';
|
|
3
|
+
import { INSIGHT_COLOR_PLATTE } from '../../constants';
|
|
4
|
+
import { dataFormat } from '../../../../utils';
|
|
5
|
+
import { pointMarkStrategy } from '../commonMarks/pointMark';
|
|
6
|
+
import { textMarkStrategy } from '../commonMarks/textMark';
|
|
7
|
+
import { insight2ChartStrategy } from '../chart';
|
|
8
|
+
import { augmentedMarks2Marks } from '../../utils';
|
|
9
|
+
export var changePointAugmentedMarksStrategy = function (insight) {
|
|
10
|
+
var patterns = insight.patterns;
|
|
11
|
+
var color = INSIGHT_COLOR_PLATTE.highlight;
|
|
12
|
+
if (!size(patterns))
|
|
13
|
+
return [];
|
|
14
|
+
var measure = patterns[0].measure;
|
|
15
|
+
var changePointMarks = [];
|
|
16
|
+
patterns.forEach(function (pattern) {
|
|
17
|
+
var pointMark = pointMarkStrategy([pattern], { style: { fill: color } });
|
|
18
|
+
var textMark = textMarkStrategy([pattern], {
|
|
19
|
+
formatter: dataFormat,
|
|
20
|
+
label: function (pt) { return "".concat(pt.x, ", ").concat(measure, ": ").concat(pt.y); },
|
|
21
|
+
style: {
|
|
22
|
+
dy: -20,
|
|
23
|
+
background: true,
|
|
24
|
+
backgroundRadius: 2,
|
|
25
|
+
connector: true,
|
|
26
|
+
startMarker: true,
|
|
27
|
+
startMarkerFill: '#2C3542',
|
|
28
|
+
startMarkerFillOpacity: 0.65,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
changePointMarks.push({
|
|
32
|
+
changePoint: [pointMark, textMark],
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
return changePointMarks;
|
|
36
|
+
};
|
|
37
|
+
export var changePointStrategy = function (insight) {
|
|
38
|
+
var chart = insight2ChartStrategy(insight);
|
|
39
|
+
var changePointMarks = changePointAugmentedMarksStrategy(insight);
|
|
40
|
+
var marks = augmentedMarks2Marks(changePointMarks);
|
|
41
|
+
return __spreadArray([chart], __read(marks), false);
|
|
42
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { trendStrategy, trendAugmentedMarksStrategy } from './trend';
|
|
2
|
+
export { lowVarianceStrategy, lowVarianceAugmentedMarkStrategy } from './lowVariance';
|
|
3
|
+
export { categoryOutlierStrategy, categoryOutlierAugmentedMarksStrategy } from './categoryOutlier';
|
|
4
|
+
export { changePointStrategy, changePointAugmentedMarksStrategy } from './changePoint';
|
|
5
|
+
export { majorityStrategy } from './majority';
|
|
6
|
+
export { correlationStrategy } from './correlation';
|
|
7
|
+
export { homogeneousStrategy } from './homogeneous';
|
|
8
|
+
export { timeSeriesOutlierStrategy, timeSeriesOutlierStrategyAugmentedMarksStrategy } from './timeSeriesOutlier';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { lineMarkStrategy } from '../commonMarks';
|
|
3
|
+
import { insight2ChartStrategy } from '../chart';
|
|
4
|
+
import { augmentedMarks2Marks } from '../../utils';
|
|
5
|
+
import { dataFormat } from '../../../../utils';
|
|
6
|
+
export var lowVarianceAugmentedMarkStrategy = function (insight) {
|
|
7
|
+
var patterns = insight.patterns;
|
|
8
|
+
var marks = [];
|
|
9
|
+
patterns.forEach(function (pattern) {
|
|
10
|
+
var mean = pattern.mean;
|
|
11
|
+
var meanLineMark = lineMarkStrategy({ y: mean }, { label: "mean: ".concat(dataFormat(mean)) });
|
|
12
|
+
marks.push({
|
|
13
|
+
meanLine: [meanLineMark],
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return marks;
|
|
17
|
+
};
|
|
18
|
+
export var lowVarianceStrategy = function (insight) {
|
|
19
|
+
var chartMark = insight2ChartStrategy(insight);
|
|
20
|
+
var lowVarianceMarks = lowVarianceAugmentedMarkStrategy(insight);
|
|
21
|
+
var marks = augmentedMarks2Marks(lowVarianceMarks);
|
|
22
|
+
return __spreadArray([chartMark], __read(marks), false);
|
|
23
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { insight2ChartStrategy } from '../chart';
|
|
3
|
+
import { areaMarkStrategy, lineMarkStrategy, pointMarkStrategy } from '../commonMarks';
|
|
4
|
+
var BASELINE = 'baseline';
|
|
5
|
+
var INTERVAL = 'interval';
|
|
6
|
+
var OUTLIER = 'outlier';
|
|
7
|
+
export var timeSeriesOutlierStrategyAugmentedMarksStrategy = function (insight) {
|
|
8
|
+
var chartData = insight.data, _a = __read(insight.dimensions, 1), dimensionName = _a[0].fieldName, patterns = insight.patterns;
|
|
9
|
+
var _b = patterns[0], baselines = _b.baselines, thresholds = _b.thresholds;
|
|
10
|
+
var data = chartData.map(function (datum, index) {
|
|
11
|
+
var baseline = baselines[index];
|
|
12
|
+
var interval = [baseline - Math.abs(thresholds[0]), baseline + thresholds[1]];
|
|
13
|
+
return {
|
|
14
|
+
baseline: {
|
|
15
|
+
x: datum[dimensionName],
|
|
16
|
+
y: baseline,
|
|
17
|
+
},
|
|
18
|
+
interval: {
|
|
19
|
+
x: datum[dimensionName],
|
|
20
|
+
y: interval,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
var intervalData = data.map(function (datum) { return datum[INTERVAL]; });
|
|
25
|
+
var intervalMark = areaMarkStrategy(intervalData, {
|
|
26
|
+
encode: {
|
|
27
|
+
shape: 'smooth',
|
|
28
|
+
},
|
|
29
|
+
style: {
|
|
30
|
+
fillOpacity: 0.3,
|
|
31
|
+
fill: '#ffd8b8',
|
|
32
|
+
},
|
|
33
|
+
tooltip: {
|
|
34
|
+
title: '',
|
|
35
|
+
items: [
|
|
36
|
+
function (_d, i, _data, column) { return ({
|
|
37
|
+
name: INTERVAL,
|
|
38
|
+
value: "".concat(column.y.value[i], "-").concat(column.y1.value[i]),
|
|
39
|
+
color: '#ffd8b8',
|
|
40
|
+
}); },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
var baselineData = data.map(function (datum) { return datum[BASELINE]; });
|
|
45
|
+
var baselineMark = lineMarkStrategy({ points: baselineData }, {
|
|
46
|
+
encode: {
|
|
47
|
+
shape: 'smooth',
|
|
48
|
+
},
|
|
49
|
+
style: {
|
|
50
|
+
lineWidth: 1,
|
|
51
|
+
stroke: '#ffa45c',
|
|
52
|
+
lineDash: undefined,
|
|
53
|
+
},
|
|
54
|
+
tooltip: {
|
|
55
|
+
title: '',
|
|
56
|
+
items: [{ name: BASELINE, channel: 'y' }],
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
var outlierMark = pointMarkStrategy(patterns, {
|
|
60
|
+
style: {
|
|
61
|
+
fill: '#f4664a',
|
|
62
|
+
stroke: '#f4664a',
|
|
63
|
+
},
|
|
64
|
+
tooltip: {
|
|
65
|
+
title: '',
|
|
66
|
+
items: [{ name: OUTLIER, channel: 'y' }],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
trendLine: [baselineMark],
|
|
72
|
+
anomalyArea: [intervalMark],
|
|
73
|
+
outliers: [outlierMark],
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
};
|
|
77
|
+
export var timeSeriesOutlierStrategy = function (insight) {
|
|
78
|
+
// Should to support marks free combination
|
|
79
|
+
var chartMark = insight2ChartStrategy(insight);
|
|
80
|
+
var _a = timeSeriesOutlierStrategyAugmentedMarksStrategy(insight)[0] || {}, _b = _a.trendLine, trendLine = _b === void 0 ? [] : _b, _c = _a.anomalyArea, anomalyArea = _c === void 0 ? [] : _c, _e = _a.outliers, outliers = _e === void 0 ? [] : _e;
|
|
81
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(anomalyArea), false), __read(trendLine), false), [chartMark], false), __read(outliers), false);
|
|
82
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { lineMarkStrategy } from '../commonMarks';
|
|
3
|
+
import { insight2ChartStrategy } from '../chart';
|
|
4
|
+
import { dataFormat } from '../../../../utils';
|
|
5
|
+
export var trendAugmentedMarksStrategy = function (insight) {
|
|
6
|
+
var chartData = insight.data, _a = __read(insight.dimensions, 1), dimensionName = _a[0].fieldName, patterns = insight.patterns;
|
|
7
|
+
var points = chartData.map(function (datum, index) {
|
|
8
|
+
var points = patterns[0].regression.points;
|
|
9
|
+
var point = points[index];
|
|
10
|
+
return [datum[dimensionName], point];
|
|
11
|
+
});
|
|
12
|
+
var _b = __read(patterns[0].regression.equation, 2), m = _b[0], c = _b[1];
|
|
13
|
+
var lineData = points.map(function (point) { return ({ x: point[0], y: point[1] }); });
|
|
14
|
+
var regressionLineMark = lineMarkStrategy({ points: lineData }, { label: "y=".concat(dataFormat(m), "x").concat(c < 0 ? '' : '+').concat(dataFormat(c)) });
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
trendLine: [regressionLineMark],
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
};
|
|
21
|
+
export var trendStrategy = function (insight) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
var chart = insight2ChartStrategy(insight);
|
|
24
|
+
var trendMarks = trendAugmentedMarksStrategy(insight);
|
|
25
|
+
return __spreadArray([chart], __read(((_b = (_a = trendMarks[0]) === null || _a === void 0 ? void 0 : _a.trendLine) !== null && _b !== void 0 ? _b : [])), false);
|
|
26
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { PIE_RADIUS_STYLE } from '../constants';
|
|
3
|
+
export var insight2ChartStrategy = function (insight) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
var data = insight.data, patterns = insight.patterns, dimensions = insight.dimensions, measures = insight.measures;
|
|
6
|
+
var insightType = patterns[0].type;
|
|
7
|
+
var commonSpec = {
|
|
8
|
+
data: data,
|
|
9
|
+
encode: {
|
|
10
|
+
x: dimensions[0].fieldName,
|
|
11
|
+
y: measures[0].fieldName,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
// pie
|
|
15
|
+
if (insightType === 'majority') {
|
|
16
|
+
return __assign(__assign({}, commonSpec), { type: 'interval', encode: {
|
|
17
|
+
color: dimensions[0].fieldName,
|
|
18
|
+
y: measures[0].fieldName,
|
|
19
|
+
}, transform: [{ type: 'stackY' }], coordinate: {
|
|
20
|
+
type: 'theta',
|
|
21
|
+
innerRadius: PIE_RADIUS_STYLE.innerRadius,
|
|
22
|
+
outerRadius: PIE_RADIUS_STYLE.outerRadius,
|
|
23
|
+
}, tooltip: {
|
|
24
|
+
items: [{ field: dimensions[0].fieldName }, { field: measures[0].fieldName }],
|
|
25
|
+
} });
|
|
26
|
+
}
|
|
27
|
+
// line
|
|
28
|
+
if (insightType === 'trend' || insightType === 'time_series_outlier' || insightType === 'change_point') {
|
|
29
|
+
return __assign(__assign({}, commonSpec), { type: 'line', style: {
|
|
30
|
+
lineWidth: 2,
|
|
31
|
+
} });
|
|
32
|
+
}
|
|
33
|
+
// bar
|
|
34
|
+
if (insightType === 'category_outlier' || insightType === 'low_variance') {
|
|
35
|
+
return __assign(__assign({}, commonSpec), { type: 'interval' });
|
|
36
|
+
}
|
|
37
|
+
// scatter
|
|
38
|
+
if (insightType === 'correlation') {
|
|
39
|
+
return __assign(__assign({}, commonSpec), { type: 'point', encode: {
|
|
40
|
+
x: (_a = measures[0]) === null || _a === void 0 ? void 0 : _a.fieldName,
|
|
41
|
+
y: (_b = measures[1]) === null || _b === void 0 ? void 0 : _b.fieldName,
|
|
42
|
+
} });
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
export var areaMarkStrategy = function (data, _a) {
|
|
3
|
+
var encode = _a.encode, style = _a.style, tooltip = _a.tooltip;
|
|
4
|
+
var common = {
|
|
5
|
+
style: style,
|
|
6
|
+
tooltip: tooltip,
|
|
7
|
+
};
|
|
8
|
+
if (data) {
|
|
9
|
+
return __assign(__assign({}, common), { type: 'area', data: data, encode: __assign({ x: 'x', y: 'y' }, encode) });
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { INSIGHT_COLOR_PLATTE } from '../../constants';
|
|
3
|
+
/** get mark for point patterns, the patterns should have same dimension and measure */
|
|
4
|
+
export var intervalMarkStrategy = function (patterns, config) {
|
|
5
|
+
var data = patterns.map(function (_a) {
|
|
6
|
+
var x = _a.x, y = _a.y;
|
|
7
|
+
return ({ x: x, y: y });
|
|
8
|
+
});
|
|
9
|
+
var intervalMark = __assign(__assign({ type: 'interval', data: data, encode: {
|
|
10
|
+
x: 'x',
|
|
11
|
+
y: 'y',
|
|
12
|
+
} }, config), { style: __assign(__assign({}, config === null || config === void 0 ? void 0 : config.style), { fill: INSIGHT_COLOR_PLATTE.outlier }) });
|
|
13
|
+
return intervalMark;
|
|
14
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { INSIGHT_COLOR_PLATTE } from '../../constants';
|
|
3
|
+
export var lineMarkStrategy = function (_a, _b) {
|
|
4
|
+
var points = _a.points, x = _a.x, y = _a.y;
|
|
5
|
+
var encode = _b.encode, style = _b.style, label = _b.label, tooltip = _b.tooltip;
|
|
6
|
+
var common = {
|
|
7
|
+
style: __assign({ lineDash: [2, 2], stroke: INSIGHT_COLOR_PLATTE.highlight }, style),
|
|
8
|
+
labels: label
|
|
9
|
+
? [
|
|
10
|
+
{
|
|
11
|
+
text: label,
|
|
12
|
+
selector: 'last',
|
|
13
|
+
position: 'right',
|
|
14
|
+
style: {
|
|
15
|
+
textBaseline: 'bottom',
|
|
16
|
+
textAlign: 'end',
|
|
17
|
+
dy: -24,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
: undefined,
|
|
22
|
+
tooltip: tooltip,
|
|
23
|
+
};
|
|
24
|
+
if (points) {
|
|
25
|
+
return __assign(__assign({}, common), { type: 'line', data: points, encode: __assign({ x: 'x', y: 'y' }, encode) });
|
|
26
|
+
}
|
|
27
|
+
if (x) {
|
|
28
|
+
return __assign(__assign({}, common), { type: 'lineX', data: [x] });
|
|
29
|
+
}
|
|
30
|
+
if (y) {
|
|
31
|
+
return __assign(__assign({}, common), { type: 'lineY', data: [y] });
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { isNil } from 'lodash';
|
|
3
|
+
/** get mark for point patterns, the patterns should have same dimension and measure */
|
|
4
|
+
export var pointMarkStrategy = function (patterns, config) {
|
|
5
|
+
var data = [];
|
|
6
|
+
patterns.forEach(function (_a) {
|
|
7
|
+
var x = _a.x, y = _a.y;
|
|
8
|
+
if (isNil(x) || isNil(y))
|
|
9
|
+
return;
|
|
10
|
+
data.push({ x: x, y: y });
|
|
11
|
+
});
|
|
12
|
+
var pointMark = __assign({ type: 'point', data: data, encode: {
|
|
13
|
+
x: 'x',
|
|
14
|
+
y: 'y',
|
|
15
|
+
} }, config);
|
|
16
|
+
return pointMark;
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { isFunction } from 'lodash';
|
|
3
|
+
import { TEXT_STYLE } from '../../constants';
|
|
4
|
+
/** get mark for point patterns, the patterns should have same dimension and measure */
|
|
5
|
+
export var textMarkStrategy = function (patterns, textConfig) {
|
|
6
|
+
var _a = textConfig || {}, style = _a.style, label = _a.label, formatter = _a.formatter;
|
|
7
|
+
var _b = patterns[0], measure = _b.measure, dimension = _b.dimension;
|
|
8
|
+
var data = patterns.map(function (pattern) {
|
|
9
|
+
var _a;
|
|
10
|
+
var customLabel = isFunction(label) ? label(pattern) : label;
|
|
11
|
+
var value = isFunction(formatter) ? formatter(pattern.y) : pattern.y;
|
|
12
|
+
return _a = {},
|
|
13
|
+
_a[dimension] = pattern.x,
|
|
14
|
+
_a[measure] = pattern.y,
|
|
15
|
+
_a.label = customLabel !== null && customLabel !== void 0 ? customLabel : "".concat(pattern.x, "\n").concat(value),
|
|
16
|
+
_a;
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
type: 'text',
|
|
20
|
+
data: data,
|
|
21
|
+
encode: {
|
|
22
|
+
x: dimension,
|
|
23
|
+
y: measure,
|
|
24
|
+
text: 'label',
|
|
25
|
+
},
|
|
26
|
+
style: __assign(__assign({}, TEXT_STYLE), style),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
export var viewSpecStrategy = function (marks, insight) {
|
|
3
|
+
// majority insight pattern visualizes as 'pie', should not use y nice (G2 handle it as rescale y, the pie chart will be less than 100%)
|
|
4
|
+
var isMajorityPattern = insight.patterns.map(function (pattern) { return pattern.type; }).includes('majority');
|
|
5
|
+
var viewConfig = isMajorityPattern
|
|
6
|
+
? { scale: { y: { nice: false } } }
|
|
7
|
+
: {
|
|
8
|
+
scale: { y: { nice: true } },
|
|
9
|
+
};
|
|
10
|
+
return __assign({ type: 'view', theme: 'classic', axis: {
|
|
11
|
+
x: { labelAutoHide: true, labelAutoRotate: false, title: false },
|
|
12
|
+
y: { title: false },
|
|
13
|
+
}, interaction: {
|
|
14
|
+
tooltip: { groupName: false },
|
|
15
|
+
}, legend: false, children: marks }, viewConfig);
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Should be confidence level. Is the SIGNIFICANCE_BENCHMARK naming correct? by @pddpd
|
|
2
|
+
export var SIGNIFICANCE_BENCHMARK = 0.95;
|
|
3
|
+
export var SIGNIFICANCE_LEVEL = 0.05;
|
|
4
|
+
export var INSIGHT_SCORE_BENCHMARK = 0.01;
|
|
5
|
+
export var IMPACT_SCORE_WEIGHT = 0.2;
|
|
6
|
+
export var INSIGHT_DEFAULT_LIMIT = 20;
|
|
7
|
+
export var IQR_K = 1.5;
|
|
8
|
+
export var LOWESS_N_STEPS = 2;
|
|
9
|
+
export var PATTERN_TYPES = [
|
|
10
|
+
'category_outlier',
|
|
11
|
+
'trend',
|
|
12
|
+
'change_point',
|
|
13
|
+
'time_series_outlier',
|
|
14
|
+
'majority',
|
|
15
|
+
'low_variance',
|
|
16
|
+
'correlation',
|
|
17
|
+
];
|
|
18
|
+
export var HOMOGENEOUS_PATTERN_TYPES = ['commonness', 'exception'];
|
|
19
|
+
export var VERIFICATION_FAILURE_INFO = 'The input does not meet the requirements.';
|
|
20
|
+
export var NO_PATTERN_INFO = 'No insights were found at the specified significance threshold.';
|
|
21
|
+
export var CHANGE_POINT_SIGNIFICANCE_BENCHMARK = 0.15;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { intersection } from 'lodash';
|
|
2
|
+
var fieldsQuantityChecker = function (subjectInfo, dimensionsQuantity, measuresQuantity) {
|
|
3
|
+
var dimensions = subjectInfo.dimensions, measures = subjectInfo.measures;
|
|
4
|
+
if (dimensions.length === dimensionsQuantity && measures.length === measuresQuantity)
|
|
5
|
+
return true;
|
|
6
|
+
return false;
|
|
7
|
+
};
|
|
8
|
+
var generalCheckerFor1M1D = function (_a) {
|
|
9
|
+
var _b, _c, _d, _e;
|
|
10
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap, lom = _a.lom;
|
|
11
|
+
var dimensions = subjectInfo.dimensions;
|
|
12
|
+
// check data length
|
|
13
|
+
if ((data === null || data === void 0 ? void 0 : data.length) < 3)
|
|
14
|
+
return 'The data length is less than 3. ';
|
|
15
|
+
// check field quantity
|
|
16
|
+
if (!fieldsQuantityChecker(subjectInfo, 1, 1))
|
|
17
|
+
return 'The length of the measure or dimension is not 1. ';
|
|
18
|
+
// check dimension type
|
|
19
|
+
if (Array.isArray(lom)
|
|
20
|
+
? !((_c = intersection((_b = fieldPropsMap[dimensions[0]]) === null || _b === void 0 ? void 0 : _b.levelOfMeasurements, lom)) === null || _c === void 0 ? void 0 : _c.length)
|
|
21
|
+
: !((_e = (_d = fieldPropsMap[dimensions[0]]) === null || _d === void 0 ? void 0 : _d.levelOfMeasurements) === null || _e === void 0 ? void 0 : _e.includes(lom)))
|
|
22
|
+
return "The type of the dimension field is not included in the option ".concat(Array.isArray(lom) ? lom : [lom], ". ");
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
export var trendChecker = function (_a) {
|
|
26
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
27
|
+
return generalCheckerFor1M1D({ data: data, subjectInfo: subjectInfo, fieldPropsMap: fieldPropsMap, lom: 'Time' });
|
|
28
|
+
};
|
|
29
|
+
export var categoryOutlierChecker = function (_a) {
|
|
30
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
31
|
+
return generalCheckerFor1M1D({ data: data, subjectInfo: subjectInfo, fieldPropsMap: fieldPropsMap, lom: ['Nominal', 'Discrete', 'Ordinal'] });
|
|
32
|
+
};
|
|
33
|
+
export var changePointChecker = function (_a) {
|
|
34
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
35
|
+
return generalCheckerFor1M1D({ data: data, subjectInfo: subjectInfo, fieldPropsMap: fieldPropsMap, lom: 'Time' });
|
|
36
|
+
};
|
|
37
|
+
export var timeSeriesChecker = function (_a) {
|
|
38
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
39
|
+
return generalCheckerFor1M1D({ data: data, subjectInfo: subjectInfo, fieldPropsMap: fieldPropsMap, lom: 'Time' });
|
|
40
|
+
};
|
|
41
|
+
export var majorityChecker = function (_a) {
|
|
42
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
43
|
+
var checkerFor1M1D = generalCheckerFor1M1D({
|
|
44
|
+
data: data,
|
|
45
|
+
subjectInfo: subjectInfo,
|
|
46
|
+
fieldPropsMap: fieldPropsMap,
|
|
47
|
+
lom: ['Nominal', 'Discrete', 'Ordinal', 'Time'],
|
|
48
|
+
});
|
|
49
|
+
if (checkerFor1M1D !== true)
|
|
50
|
+
return checkerFor1M1D;
|
|
51
|
+
var measures = subjectInfo.measures;
|
|
52
|
+
if (!['count', 'sum'].includes(measures[0].method))
|
|
53
|
+
return 'Measure is not aggregated in sum or count mode. ';
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
export var lowVarianceChecker = function (_a) {
|
|
57
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
58
|
+
var checkerFor1M1D = generalCheckerFor1M1D({
|
|
59
|
+
data: data,
|
|
60
|
+
subjectInfo: subjectInfo,
|
|
61
|
+
fieldPropsMap: fieldPropsMap,
|
|
62
|
+
lom: ['Nominal', 'Discrete', 'Ordinal'],
|
|
63
|
+
});
|
|
64
|
+
if (checkerFor1M1D !== true)
|
|
65
|
+
return checkerFor1M1D;
|
|
66
|
+
var measures = subjectInfo.measures;
|
|
67
|
+
// 低方差检验使用变异系数 sigma/mean 作为检验统计量,要求均值不能为0
|
|
68
|
+
if (['float', 'integer'].includes(fieldPropsMap[measures[0].fieldName].recommendation)) {
|
|
69
|
+
if (fieldPropsMap[measures[0].fieldName].mean !== 0)
|
|
70
|
+
return true;
|
|
71
|
+
return 'The low variance test uses the coefficient of variation sigma/mean as the test statistic and requires that the mean cannot be 0. ';
|
|
72
|
+
}
|
|
73
|
+
return 'The recommended data type of measure is not float or integer. ';
|
|
74
|
+
};
|
|
75
|
+
export var correlationChecker = function (_a) {
|
|
76
|
+
var _b, _c;
|
|
77
|
+
var data = _a.data, subjectInfo = _a.subjectInfo, fieldPropsMap = _a.fieldPropsMap;
|
|
78
|
+
var measures = subjectInfo.measures;
|
|
79
|
+
// check data length
|
|
80
|
+
if ((data === null || data === void 0 ? void 0 : data.length) < 3)
|
|
81
|
+
return 'The data length is less than 3. ';
|
|
82
|
+
// check field quantity
|
|
83
|
+
if (measures.length !== 2)
|
|
84
|
+
return 'The length of the measure or dimension is not 2. ';
|
|
85
|
+
if (!((_b = fieldPropsMap[measures[0].fieldName].levelOfMeasurements) === null || _b === void 0 ? void 0 : _b.includes('Continuous')) ||
|
|
86
|
+
!((_c = fieldPropsMap[measures[1].fieldName].levelOfMeasurements) === null || _c === void 0 ? void 0 : _c.includes('Continuous')))
|
|
87
|
+
return 'Level of measurement is not continuous. ';
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
export var ExtractorCheckers = {
|
|
91
|
+
category_outlier: categoryOutlierChecker,
|
|
92
|
+
trend: trendChecker,
|
|
93
|
+
change_point: changePointChecker,
|
|
94
|
+
time_series_outlier: timeSeriesChecker,
|
|
95
|
+
low_variance: lowVarianceChecker,
|
|
96
|
+
correlation: correlationChecker,
|
|
97
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { get, isNil, isString, orderBy } from 'lodash';
|
|
3
|
+
import { distinct, mean } from '../../../data';
|
|
4
|
+
import { categoryOutlier } from '../../algorithms';
|
|
5
|
+
import { IQR_K, SIGNIFICANCE_BENCHMARK } from '../../constant';
|
|
6
|
+
import { calculatePValue, calculateOutlierThresholds, preValidation, getAlgorithmCommonInput, getNonSignificantInsight, } from '../util';
|
|
7
|
+
export var findOutliers = function (values, outlierParameter) {
|
|
8
|
+
var _a = outlierParameter || {}, method = _a.method, iqrK = _a.iqrK, _b = _a.confidenceInterval, confidenceInterval = _b === void 0 ? SIGNIFICANCE_BENCHMARK : _b;
|
|
9
|
+
var outliers = [];
|
|
10
|
+
var thresholds = [];
|
|
11
|
+
var candidates = values.map(function (item, index) {
|
|
12
|
+
return { index: index, value: item };
|
|
13
|
+
});
|
|
14
|
+
if (method !== 'p-value') {
|
|
15
|
+
var IQRResult = categoryOutlier.IQR(values, { k: iqrK !== null && iqrK !== void 0 ? iqrK : IQR_K });
|
|
16
|
+
var lowerOutlierIndexes = IQRResult.lower.indexes;
|
|
17
|
+
var upperOutlierIndexes = IQRResult.upper.indexes;
|
|
18
|
+
__spreadArray(__spreadArray([], __read(lowerOutlierIndexes), false), __read(upperOutlierIndexes), false).forEach(function (index) {
|
|
19
|
+
var value = values[index];
|
|
20
|
+
var pValue = (candidates.findIndex(function (item) { return item.value === value; }) + 1) / values.length;
|
|
21
|
+
// two-sided
|
|
22
|
+
var significance = pValue > 0.5 ? pValue : 1 - pValue;
|
|
23
|
+
outliers.push({
|
|
24
|
+
index: index,
|
|
25
|
+
value: value,
|
|
26
|
+
significance: significance,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
thresholds.push(IQRResult.lower.threshold, IQRResult.upper.threshold);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
var sortedCandidates = orderBy(candidates, function (item) { return Math.abs(mean(values) - item.value); }, ['desc']);
|
|
33
|
+
thresholds.push.apply(thresholds, __spreadArray([], __read(calculateOutlierThresholds(values, confidenceInterval, 'two-sided')), false));
|
|
34
|
+
for (var i = 0; i < sortedCandidates.length; i += 1) {
|
|
35
|
+
var candidate = sortedCandidates[i];
|
|
36
|
+
var value = candidate.value, index = candidate.index;
|
|
37
|
+
var pValue = calculatePValue(values, value, 'two-sided');
|
|
38
|
+
var significance = 1 - pValue;
|
|
39
|
+
if (significance < confidenceInterval) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
outliers.push({
|
|
43
|
+
index: index,
|
|
44
|
+
value: value,
|
|
45
|
+
significance: significance,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { outliers: outliers, thresholds: thresholds };
|
|
50
|
+
};
|
|
51
|
+
export var getCategoryOutlierInfo = function (props) {
|
|
52
|
+
var valid = preValidation(props);
|
|
53
|
+
var insightType = 'category_outlier';
|
|
54
|
+
if (isString(valid))
|
|
55
|
+
return getNonSignificantInsight({ detailInfo: valid, insightType: insightType, infoType: 'verificationFailure' });
|
|
56
|
+
var _a = getAlgorithmCommonInput(props), dimension = _a.dimension, values = _a.values, measure = _a.measure;
|
|
57
|
+
if (isNil(dimension) || isNil(measure))
|
|
58
|
+
return getNonSignificantInsight({
|
|
59
|
+
detailInfo: 'Measure or dimension is empty.',
|
|
60
|
+
insightType: insightType,
|
|
61
|
+
infoType: 'verificationFailure',
|
|
62
|
+
});
|
|
63
|
+
if (distinct(values) === 1)
|
|
64
|
+
return getNonSignificantInsight({
|
|
65
|
+
insightType: insightType,
|
|
66
|
+
infoType: 'noInsight',
|
|
67
|
+
customInfo: { info: 'Each value in the data is the same. No outliers were found.' },
|
|
68
|
+
});
|
|
69
|
+
var data = props.data;
|
|
70
|
+
var outlierParameter = get(props, 'options.algorithmParameter.outlier');
|
|
71
|
+
var outliers = findOutliers(values, outlierParameter).outliers;
|
|
72
|
+
if (outliers.length === 0) {
|
|
73
|
+
var info = "No outliers were found using method ".concat((outlierParameter === null || outlierParameter === void 0 ? void 0 : outlierParameter.method) !== 'p-value' ? 'Inter Quartile Range' : 'Normal Distribution test', ".");
|
|
74
|
+
return getNonSignificantInsight({ insightType: insightType, infoType: 'noInsight', customInfo: { info: info } });
|
|
75
|
+
}
|
|
76
|
+
var categoryOutliers = outliers.map(function (item) {
|
|
77
|
+
var index = item.index, significance = item.significance;
|
|
78
|
+
return {
|
|
79
|
+
type: insightType,
|
|
80
|
+
dimension: dimension,
|
|
81
|
+
measure: measure,
|
|
82
|
+
significance: significance,
|
|
83
|
+
index: index,
|
|
84
|
+
x: data[index][dimension],
|
|
85
|
+
y: data[index][measure],
|
|
86
|
+
significantInsight: true,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return categoryOutliers;
|
|
90
|
+
};
|