@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,67 @@
|
|
|
1
|
+
/** operation of vector or matrix */
|
|
2
|
+
export var vectorAdd = function (x, y) {
|
|
3
|
+
if (x.length !== y.length)
|
|
4
|
+
return null;
|
|
5
|
+
return x.map(function (xi, i) { return xi + y[i]; });
|
|
6
|
+
};
|
|
7
|
+
export var vectorSubtract = function (x, y) {
|
|
8
|
+
if (x.length !== y.length)
|
|
9
|
+
return null;
|
|
10
|
+
return x.map(function (xi, i) { return xi - y[i]; });
|
|
11
|
+
};
|
|
12
|
+
export var vectorInnerProduct = function (x, y) {
|
|
13
|
+
if (x.length !== y.length)
|
|
14
|
+
return null;
|
|
15
|
+
var result = 0;
|
|
16
|
+
x.forEach(function (xi, i) {
|
|
17
|
+
result += xi * y[i];
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
export var matrixTranspose = function (x) {
|
|
22
|
+
var result = [];
|
|
23
|
+
var _loop_1 = function (j) {
|
|
24
|
+
result.push(x.map(function (xi) { return xi[j]; }));
|
|
25
|
+
};
|
|
26
|
+
for (var j = 0; j < x[0].length; j += 1) {
|
|
27
|
+
_loop_1(j);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
export var matrixMultiply = function (x, y) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (((_a = x[0]) === null || _a === void 0 ? void 0 : _a.length) !== y.length)
|
|
34
|
+
return null;
|
|
35
|
+
var result = [];
|
|
36
|
+
var yT = matrixTranspose(y);
|
|
37
|
+
x.forEach(function (xi) { return result.push(yT.map(function (yj) { return vectorInnerProduct(xi, yj); })); });
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
export var multiMatrixMultiply = function (matrixSet) {
|
|
41
|
+
var result = matrixSet[0];
|
|
42
|
+
for (var i = 1; i < matrixSet.length; i += 1) {
|
|
43
|
+
result = matrixMultiply(result, matrixSet[i]);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Constructs a diagonal matrix where the values of the main diagonal are the values of the given vector
|
|
49
|
+
*/
|
|
50
|
+
export var constructDiagonalMatrix = function (diagonalVector) {
|
|
51
|
+
return diagonalVector.map(function (diagonalValue, i) {
|
|
52
|
+
// ith row
|
|
53
|
+
var row = Array(diagonalVector.length).fill(0);
|
|
54
|
+
row[i] = diagonalValue;
|
|
55
|
+
return row;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Calculate the inverse matrix for second order matrix
|
|
60
|
+
* */
|
|
61
|
+
export var inverseSecondOrderMatrix = function (matrix) {
|
|
62
|
+
var determinant = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
|
|
63
|
+
return [
|
|
64
|
+
[matrix[1][1] / determinant, -matrix[0][1] / determinant],
|
|
65
|
+
[-matrix[1][0] / determinant, matrix[0][0] / determinant],
|
|
66
|
+
];
|
|
67
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mean } from 'lodash';
|
|
2
|
+
import { SIGNIFICANCE_BENCHMARK } from '../../insight/constant';
|
|
3
|
+
import { calculatePValue } from '../../insight/insights/util';
|
|
4
|
+
var DEFAULT_WINDOW_SIZE = 4;
|
|
5
|
+
/**
|
|
6
|
+
* Window-based change point detection
|
|
7
|
+
*/
|
|
8
|
+
export function windowBasedMean(data, params) {
|
|
9
|
+
var len = data === null || data === void 0 ? void 0 : data.length;
|
|
10
|
+
var K = (params === null || params === void 0 ? void 0 : params.windowSize) || DEFAULT_WINDOW_SIZE;
|
|
11
|
+
if (len <= 2 * K + 3)
|
|
12
|
+
return [];
|
|
13
|
+
var significanceLimit = (params === null || params === void 0 ? void 0 : params.significanceLimit) || SIGNIFICANCE_BENCHMARK;
|
|
14
|
+
var diff = Array(len).fill(0);
|
|
15
|
+
for (var i = K; i <= len - K; i += 1) {
|
|
16
|
+
var meanLeft = mean(data.slice(i - K, i));
|
|
17
|
+
var meanRight = mean(data.slice(i, i + K));
|
|
18
|
+
diff[i] = Math.abs(meanLeft - meanRight);
|
|
19
|
+
}
|
|
20
|
+
var differences = diff.slice(K, len - K + 1);
|
|
21
|
+
var sorted = differences.sort(function (a, b) { return b - a; });
|
|
22
|
+
var result = [];
|
|
23
|
+
var _loop_1 = function (i) {
|
|
24
|
+
var difference = sorted[i];
|
|
25
|
+
var index = diff.findIndex(function (item) { return item === difference; });
|
|
26
|
+
var significance = 1 - calculatePValue(differences, difference);
|
|
27
|
+
if (significance >= significanceLimit) {
|
|
28
|
+
result.push({
|
|
29
|
+
index: index,
|
|
30
|
+
significance: significance,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
for (var i = 0; i < sorted.length; i += 1) {
|
|
35
|
+
_loop_1(i);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Window-based change point test
|
|
41
|
+
*/
|
|
42
|
+
export function calcPValue(data, index, window) {
|
|
43
|
+
var len = data === null || data === void 0 ? void 0 : data.length;
|
|
44
|
+
var K = window || DEFAULT_WINDOW_SIZE;
|
|
45
|
+
if (len <= 2 * K + 3)
|
|
46
|
+
return 0;
|
|
47
|
+
var diff = Array(len).fill(0);
|
|
48
|
+
for (var i = K; i <= len - K; i += 1) {
|
|
49
|
+
var meanLeft = mean(data.slice(i - K, i));
|
|
50
|
+
var meanRight = mean(data.slice(i, i + K));
|
|
51
|
+
diff[i] = Math.abs(meanLeft - meanRight);
|
|
52
|
+
}
|
|
53
|
+
var p = calculatePValue(diff.slice(K, len - K + 1), diff[index]);
|
|
54
|
+
return p;
|
|
55
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { isArray } from './isType';
|
|
3
|
+
/**
|
|
4
|
+
* Return an array with unique elements
|
|
5
|
+
* @param value
|
|
6
|
+
*/
|
|
7
|
+
export function unique(value) {
|
|
8
|
+
return Array.from(new Set(value));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generate an array from 0 to number.
|
|
12
|
+
* @param number
|
|
13
|
+
*/
|
|
14
|
+
export function range(number) {
|
|
15
|
+
return __spreadArray([], __read(Array(number).keys()), false);
|
|
16
|
+
}
|
|
17
|
+
/** Generate an array with all 1 elements */
|
|
18
|
+
export function nOnes(n) {
|
|
19
|
+
return Array(n).fill(1);
|
|
20
|
+
}
|
|
21
|
+
/** Generate an array with all 0 elements */
|
|
22
|
+
export function nZeros(n) {
|
|
23
|
+
return Array(n).fill(0);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* assert
|
|
27
|
+
* @param condition
|
|
28
|
+
* @param errorMessage
|
|
29
|
+
*/
|
|
30
|
+
export function assert(condition, errorMessage) {
|
|
31
|
+
if (!condition)
|
|
32
|
+
throw new Error(errorMessage);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check parent-child relationship. A child has only one parent, but a parent can have more children.
|
|
36
|
+
* @param parent
|
|
37
|
+
* @param child
|
|
38
|
+
*/
|
|
39
|
+
export function isParentChild(parent, child) {
|
|
40
|
+
if (!isArray(parent) ||
|
|
41
|
+
parent.length === 0 ||
|
|
42
|
+
!isArray(child) ||
|
|
43
|
+
child.length === 0 ||
|
|
44
|
+
parent.length !== child.length)
|
|
45
|
+
return false;
|
|
46
|
+
var record = {};
|
|
47
|
+
for (var i = 0; i < child.length; i += 1) {
|
|
48
|
+
var c = child[i];
|
|
49
|
+
var p = parent[i];
|
|
50
|
+
if (!record[c]) {
|
|
51
|
+
record[c] = p;
|
|
52
|
+
}
|
|
53
|
+
else if (record[c] !== p) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export var SPECIAL_BOOLEANS = [
|
|
2
|
+
[true, false],
|
|
3
|
+
[0, 1],
|
|
4
|
+
['true', 'false'],
|
|
5
|
+
['Yes', 'No'],
|
|
6
|
+
['True', 'False'],
|
|
7
|
+
['0', '1'],
|
|
8
|
+
['是', '否'],
|
|
9
|
+
];
|
|
10
|
+
// For isDateString.ts
|
|
11
|
+
export var DELIMITER = '([-_./\\s])';
|
|
12
|
+
export var YEAR = '(?<year>(18|19|20)\\d{2})';
|
|
13
|
+
export var MONTH = '(?<month>0?[1-9]|1[012])';
|
|
14
|
+
export var DAY = '(?<day>0?[1-9]|[12]\\d|3[01])';
|
|
15
|
+
export var WEEK = '(?<week>[0-4]\\d|5[0-2])';
|
|
16
|
+
export var WEEKDAY = '(?<weekday>[1-7])';
|
|
17
|
+
export var BASE_HOUR = '(0?\\d|1\\d|2[0-4])';
|
|
18
|
+
export var BASE_MINUTE = '(0?\\d|[012345]\\d)';
|
|
19
|
+
export var HOUR = "(?<hour>".concat(BASE_MINUTE, ")");
|
|
20
|
+
export var MINUTE = "(?<minute>".concat(BASE_MINUTE, ")");
|
|
21
|
+
export var SECOND = "(?<second>".concat(BASE_MINUTE, ")");
|
|
22
|
+
export var MILLISECOND = '(?<millisecond>\\d{1,4})';
|
|
23
|
+
export var YEARDAY = '(?<yearDay>(([0-2]\\d|3[0-5])\\d)|36[0-6])';
|
|
24
|
+
export var OFFSET = "(?<offset>Z|[+-]".concat(BASE_HOUR, "(:").concat(BASE_MINUTE, ")?)");
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Check whether the string is a date.
|
|
3
|
+
*/
|
|
4
|
+
import { __read, __spreadArray } from "tslib";
|
|
5
|
+
import { DAY, DELIMITER, HOUR, MILLISECOND, MINUTE, MONTH, OFFSET, SECOND, WEEK, WEEKDAY, YEAR, YEARDAY, } from './constants';
|
|
6
|
+
import { isString } from './isType';
|
|
7
|
+
/**
|
|
8
|
+
* Get ISO 8601 date regular expression string array
|
|
9
|
+
* Reference: https://www.cl.cam.ac.uk/~mgk25/iso-time.html
|
|
10
|
+
* @param strict Require delimiter or not
|
|
11
|
+
*/
|
|
12
|
+
export function getIsoDatePatterns(strict) {
|
|
13
|
+
if (strict === void 0) { strict = true; }
|
|
14
|
+
return [
|
|
15
|
+
// 1991
|
|
16
|
+
"".concat(YEAR),
|
|
17
|
+
// 1999-W12-7
|
|
18
|
+
"".concat(YEAR).concat(DELIMITER).concat(strict ? '' : '?', "W").concat(WEEK, "(").concat(DELIMITER).concat(strict ? '' : '?').concat(WEEKDAY, ")?"),
|
|
19
|
+
// 12-22-1999
|
|
20
|
+
"".concat(MONTH).concat(DELIMITER).concat(strict ? '' : '?').concat(DAY).concat(DELIMITER).concat(strict ? '' : '?').concat(YEAR),
|
|
21
|
+
// 1999-12-22 19991222
|
|
22
|
+
"".concat(YEAR).concat(DELIMITER).concat(strict ? '' : '?').concat(MONTH).concat(DELIMITER).concat(strict ? '' : '?').concat(DAY),
|
|
23
|
+
// 1999-12
|
|
24
|
+
"".concat(YEAR).concat(DELIMITER).concat(strict ? '' : '?').concat(MONTH),
|
|
25
|
+
// 1999-200
|
|
26
|
+
"".concat(YEAR).concat(DELIMITER).concat(strict ? '' : '?').concat(YEARDAY),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get ISO 8601 time regular expression string array
|
|
31
|
+
* Reference: https://www.cl.cam.ac.uk/~mgk25/iso-time.html
|
|
32
|
+
* @param strict Require DELIMITER or not
|
|
33
|
+
*/
|
|
34
|
+
export function getIsoTimePatterns(strict) {
|
|
35
|
+
if (strict === void 0) { strict = true; }
|
|
36
|
+
return [
|
|
37
|
+
// 23:20:20Z 23:20:20+08:00 23:20:20-08:00
|
|
38
|
+
"".concat(HOUR, ":").concat(strict ? '' : '?').concat(MINUTE, ":").concat(strict ? '' : '?').concat(SECOND, "([.,]").concat(MILLISECOND, ")?").concat(OFFSET, "?"),
|
|
39
|
+
// 23:20+08
|
|
40
|
+
"".concat(HOUR, ":").concat(strict ? '' : '?').concat(MINUTE, "?").concat(OFFSET),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
var getIsoDateAndTimeRegs = function (strictDatePattern) {
|
|
44
|
+
var isoDatePatterns = getIsoDatePatterns(strictDatePattern);
|
|
45
|
+
var isoTimePatterns = getIsoTimePatterns(strictDatePattern);
|
|
46
|
+
var isoDateAndTimePatterns = __spreadArray(__spreadArray([], __read(isoDatePatterns), false), __read(isoTimePatterns), false);
|
|
47
|
+
isoDatePatterns.forEach(function (d) {
|
|
48
|
+
isoTimePatterns.forEach(function (t) {
|
|
49
|
+
isoDateAndTimePatterns.push("".concat(d, "[T\\s]").concat(t));
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return isoDateAndTimePatterns.map(function (pattern) {
|
|
53
|
+
return new RegExp("^".concat(pattern, "$"));
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export function isDateString(value, strictDatePattern) {
|
|
57
|
+
if (isString(value)) {
|
|
58
|
+
var isoDateAndTimeRegs = getIsoDateAndTimeRegs(strictDatePattern);
|
|
59
|
+
for (var i = 0; i < isoDateAndTimeRegs.length; i += 1) {
|
|
60
|
+
var reg = isoDateAndTimeRegs[i];
|
|
61
|
+
if (reg.test(value.trim())) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/** parse ISO 8601 date string to standard Date type, if month and date is missing, will use new Date(01-01)
|
|
69
|
+
* Reference: https://www.cl.cam.ac.uk/~mgk25/iso-time.html
|
|
70
|
+
* 将日期字符串转为标准 Date 类型,如果没有月日,只有时间信息,会默认为 01-01
|
|
71
|
+
*/
|
|
72
|
+
export function parseIsoDateString(value, strictDatePattern) {
|
|
73
|
+
if (strictDatePattern === void 0) { strictDatePattern = false; }
|
|
74
|
+
var isoDateAndTimeRegs = getIsoDateAndTimeRegs(strictDatePattern);
|
|
75
|
+
for (var i = 0; i < isoDateAndTimeRegs.length; i += 1) {
|
|
76
|
+
var reg = isoDateAndTimeRegs[i];
|
|
77
|
+
if (reg.test(value.trim())) {
|
|
78
|
+
var matches = value.trim().match(reg);
|
|
79
|
+
if (matches.groups) {
|
|
80
|
+
var _a = matches.groups || {}, year = _a.year, month = _a.month, day = _a.day, week = _a.week, weekday = _a.weekday, hour = _a.hour, minute = _a.minute, second = _a.second, millisecond = _a.millisecond, yearDay = _a.yearDay, offset = _a.offset;
|
|
81
|
+
var yearNum = parseInt(year, 10);
|
|
82
|
+
if (yearDay) {
|
|
83
|
+
return new Date(yearNum, 0, parseInt(yearDay, 10));
|
|
84
|
+
}
|
|
85
|
+
if (week) {
|
|
86
|
+
var weekNum = parseInt(week, 10);
|
|
87
|
+
var weekDayNum = weekday ? parseInt(weekday, 10) : 1;
|
|
88
|
+
var firstDayOfYear = new Date(yearNum, 0, 1);
|
|
89
|
+
// 给定年份的第一天是周几
|
|
90
|
+
var firstDayOfYearDayOfWeek = firstDayOfYear.getDay() === 0 ? 7 : firstDayOfYear.getDay();
|
|
91
|
+
// 计算第一周的第一天相对 firstDayOfYear 的偏移量
|
|
92
|
+
var firstWeekStartDayOffset = firstDayOfYearDayOfWeek === 1 ? 1 : 1 - firstDayOfYearDayOfWeek;
|
|
93
|
+
// 目标日期偏移量
|
|
94
|
+
var targetDateOffset = (weekNum - 1) * 7 + (weekDayNum + firstWeekStartDayOffset);
|
|
95
|
+
return new Date(yearNum, 0, targetDateOffset);
|
|
96
|
+
}
|
|
97
|
+
var formattedDateString = [year, month !== null && month !== void 0 ? month : '01', day !== null && day !== void 0 ? day : '01'].join('-');
|
|
98
|
+
var formattedTimeString = "".concat([hour !== null && hour !== void 0 ? hour : '00', minute !== null && minute !== void 0 ? minute : '00', second !== null && second !== void 0 ? second : '00'].join(':'), ".").concat(millisecond !== null && millisecond !== void 0 ? millisecond : '000').concat(offset !== null && offset !== void 0 ? offset : '');
|
|
99
|
+
return new Date("".concat(formattedDateString, " ").concat(formattedTimeString));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { SPECIAL_BOOLEANS } from './constants';
|
|
2
|
+
export function isNil(value) {
|
|
3
|
+
return value === null || value === undefined || value === '' || Number.isNaN(value) || value === 'null';
|
|
4
|
+
}
|
|
5
|
+
export function isString(value) {
|
|
6
|
+
return typeof value === 'string';
|
|
7
|
+
}
|
|
8
|
+
export function isNumber(value) {
|
|
9
|
+
if (typeof value === 'number')
|
|
10
|
+
return true;
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
export function isNumberString(value) {
|
|
14
|
+
if (isString(value)) {
|
|
15
|
+
var hasDot = false;
|
|
16
|
+
var tempValue = value;
|
|
17
|
+
if (/^[+-]/.test(tempValue)) {
|
|
18
|
+
tempValue = tempValue.slice(1);
|
|
19
|
+
}
|
|
20
|
+
for (var i = 0; i < tempValue.length; i += 1) {
|
|
21
|
+
var char = tempValue[i];
|
|
22
|
+
if (char === '.') {
|
|
23
|
+
if (hasDot === false) {
|
|
24
|
+
hasDot = true;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (char !== '.' && !/[0-9]/.test(char)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return tempValue.trim() !== '';
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
export function isInteger(value) {
|
|
39
|
+
if (typeof value === 'number')
|
|
40
|
+
return Number.isInteger(value);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
export function isIntegerString(value) {
|
|
44
|
+
if (isString(value) && isNumberString(value))
|
|
45
|
+
return !value.includes('.');
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
export function isFloat(value) {
|
|
49
|
+
if (typeof value === 'number')
|
|
50
|
+
return !Number.isNaN(value) && !Number.isInteger(value);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
export function isFloatString(value) {
|
|
54
|
+
if (isString(value) && isNumberString(value))
|
|
55
|
+
return value.includes('.');
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
export function isDate(value) {
|
|
59
|
+
if (value && Object.getPrototypeOf(value) === Date.prototype)
|
|
60
|
+
return true;
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
export function isBoolean(value, checkSpecialBoolean) {
|
|
64
|
+
return checkSpecialBoolean
|
|
65
|
+
? SPECIAL_BOOLEANS.some(function (list) {
|
|
66
|
+
return value.every(function (item) { return list.includes(item); });
|
|
67
|
+
})
|
|
68
|
+
: typeof value === 'boolean';
|
|
69
|
+
}
|
|
70
|
+
export function isObject(value) {
|
|
71
|
+
return value && Object.getPrototypeOf(value) === Object.prototype;
|
|
72
|
+
}
|
|
73
|
+
export function isArray(value) {
|
|
74
|
+
return Array.isArray(value);
|
|
75
|
+
}
|
|
76
|
+
export function isBasicType(value) {
|
|
77
|
+
return !isArray(value) && !isObject(value);
|
|
78
|
+
}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* advisor */
|
|
2
|
+
export { Advisor } from './advisor';
|
|
3
|
+
/* CKB */
|
|
4
|
+
export { ckb, ckbDict, CHANNELS, CHART_IDS, COORDINATE_SYSTEMS, FAMILIES, GRAPHIC_CATEGORIES, LEVEL_OF_MEASUREMENTS, PURPOSES, RECOMMEND_RATINGS, SHAPES, } from './ckb';
|
|
5
|
+
/* data */
|
|
6
|
+
export { analyzeField, Series, DataFrame, min, max, sum, mean, normalDistributionQuantile, tDistributionQuantile, distinct, valueMap, missing, valid, pearson, covariance, coefficientOfVariance, standardDeviation, variance, quantile, quartile, median, harmonicMean, geometricMean, pcorrtest, cdf, maxabs, } from './data';
|
|
7
|
+
/* insight */
|
|
8
|
+
export { getInsights, generateInsightVisualizationSpec, insightPatternsExtractor, getSpecificInsight } from './insight';
|
|
9
|
+
/* NTV (Narrative Text Vis) */
|
|
10
|
+
export { generateTextSpec, isCustomSection, isStandardSection, isCustomParagraph, isTextParagraph, isBulletParagraph, getHeadingWeight, isHeadingParagraph, isDividerParagraph, isEntityPhrase, isImagePhrase, isCustomPhrase, isTextPhrase, isEntityType, isEscapePhrase, isFormulaPhrase, ENTITY_TYPES, } from './ntv';
|
|
11
|
+
export * from './ntv/types';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lodash sortby asc function
|
|
3
|
+
* @param left unknown
|
|
4
|
+
* @param right unknown
|
|
5
|
+
* @returns number
|
|
6
|
+
*/
|
|
7
|
+
export function ascending(left, right) {
|
|
8
|
+
var leftIsNull = left === null || left === undefined;
|
|
9
|
+
var rightIsNull = right === null || right === undefined;
|
|
10
|
+
if (leftIsNull && rightIsNull) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
if (leftIsNull) {
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
if (rightIsNull) {
|
|
17
|
+
return -1;
|
|
18
|
+
}
|
|
19
|
+
return left - right;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* lodash sortby desc function
|
|
23
|
+
* @param left any
|
|
24
|
+
* @param right any
|
|
25
|
+
* @returns number
|
|
26
|
+
*/
|
|
27
|
+
export function descending(left, right) {
|
|
28
|
+
var leftIsNull = left === null || left === undefined;
|
|
29
|
+
var rightIsNull = right === null || right === undefined;
|
|
30
|
+
if (leftIsNull && rightIsNull) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
if (leftIsNull) {
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
if (rightIsNull) {
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
39
|
+
return right - left;
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { bayesian } from '../../data/statistics/bayesian';
|
|
2
|
+
import { windowBasedMean } from '../../data/statistics/window';
|
|
3
|
+
import { pettittTest } from '../../data/statistics/pettitt-test';
|
|
4
|
+
import { buishandUTest } from '../../data/statistics/buishand-u';
|
|
5
|
+
export var changePoint = {
|
|
6
|
+
Bayesian: bayesian,
|
|
7
|
+
Window: windowBasedMean,
|
|
8
|
+
PettittTest: pettittTest,
|
|
9
|
+
BuishandUTest: buishandUTest,
|
|
10
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var INSIGHT_COLOR_PLATTE = {
|
|
2
|
+
highlight: '#E09322',
|
|
3
|
+
outlier: '#CB5140',
|
|
4
|
+
font: '#2C3542',
|
|
5
|
+
defaultPointColor: '#fff',
|
|
6
|
+
};
|
|
7
|
+
export var BOLD_FONT_WEIGHT = 500;
|
|
8
|
+
export var TEXT_STYLE = {
|
|
9
|
+
textAlign: 'center',
|
|
10
|
+
fill: INSIGHT_COLOR_PLATTE.font,
|
|
11
|
+
opacity: 0.65,
|
|
12
|
+
};
|
|
13
|
+
export var ChartTypeMap = {
|
|
14
|
+
category_outlier: 'column_chart',
|
|
15
|
+
trend: 'line_chart',
|
|
16
|
+
change_point: 'line_chart',
|
|
17
|
+
time_series_outlier: 'line_chart',
|
|
18
|
+
majority: 'pie_chart',
|
|
19
|
+
low_variance: 'column_chart',
|
|
20
|
+
correlation: 'scatter_plot',
|
|
21
|
+
};
|
|
22
|
+
export var PIE_RADIUS_STYLE = {
|
|
23
|
+
innerRadius: 0.25,
|
|
24
|
+
outerRadius: 0.8,
|
|
25
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
|
+
import { INSIGHT_COLOR_PLATTE } from '../constants';
|
|
3
|
+
export function generateHomogeneousInsightAugmentedMarks(pattern) {
|
|
4
|
+
var annotations = [];
|
|
5
|
+
var insightType = pattern.insightType, childPatterns = pattern.childPatterns;
|
|
6
|
+
if (['change_point', 'time_series_outlier'].includes(insightType)) {
|
|
7
|
+
var x_1 = childPatterns[0].x;
|
|
8
|
+
var text = insightType === 'change_point' ? 'Abrupt Change' : 'Outlier';
|
|
9
|
+
var color_1 = insightType === 'change_point' ? INSIGHT_COLOR_PLATTE.highlight : INSIGHT_COLOR_PLATTE.outlier;
|
|
10
|
+
// draw line
|
|
11
|
+
var line = {
|
|
12
|
+
type: 'line',
|
|
13
|
+
start: [x_1, 'min'],
|
|
14
|
+
end: [x_1, 'max'],
|
|
15
|
+
text: {
|
|
16
|
+
content: text,
|
|
17
|
+
position: 'left',
|
|
18
|
+
offsetY: 15,
|
|
19
|
+
offsetX: 5,
|
|
20
|
+
rotate: 0,
|
|
21
|
+
autoRotate: false,
|
|
22
|
+
style: {
|
|
23
|
+
textAlign: 'left',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
annotations.push(line);
|
|
28
|
+
// draw circle
|
|
29
|
+
var circles = childPatterns.map(function (pattern) {
|
|
30
|
+
var y = pattern.y;
|
|
31
|
+
return {
|
|
32
|
+
type: 'dataMarker',
|
|
33
|
+
position: [x_1, y],
|
|
34
|
+
point: {
|
|
35
|
+
style: {
|
|
36
|
+
fill: '#fff',
|
|
37
|
+
stroke: color_1,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
line: {
|
|
41
|
+
length: 20,
|
|
42
|
+
},
|
|
43
|
+
autoAdjust: false,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
annotations.push.apply(annotations, __spreadArray([], __read(circles), false));
|
|
47
|
+
}
|
|
48
|
+
return annotations;
|
|
49
|
+
}
|
|
50
|
+
export function generateHomogeneousInsightChartSpec(insight, pattern) {
|
|
51
|
+
var dimensions = insight.dimensions, measures = insight.measures;
|
|
52
|
+
var plotSchema;
|
|
53
|
+
if (measures.length > 1) {
|
|
54
|
+
plotSchema = {
|
|
55
|
+
xField: dimensions[0],
|
|
56
|
+
yField: 'value',
|
|
57
|
+
seriesField: 'measureName',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
plotSchema = {
|
|
62
|
+
xField: dimensions[1],
|
|
63
|
+
yField: measures[0].fieldName,
|
|
64
|
+
seriesField: dimensions[0],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
var annotationConfig = generateHomogeneousInsightAugmentedMarks(pattern);
|
|
68
|
+
var chartSchema = __assign(__assign({}, plotSchema), { annotations: annotationConfig });
|
|
69
|
+
return chartSchema;
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { categoryOutlierStrategy, changePointStrategy, lowVarianceStrategy, majorityStrategy, correlationStrategy, timeSeriesOutlierStrategy, trendStrategy, viewSpecStrategy, } from '../strategy';
|
|
2
|
+
export function generateInsightChartSpec(insight) {
|
|
3
|
+
var _a;
|
|
4
|
+
var insightType = insight.patterns[0].type;
|
|
5
|
+
var insightType2Strategy = {
|
|
6
|
+
trend: trendStrategy,
|
|
7
|
+
time_series_outlier: timeSeriesOutlierStrategy,
|
|
8
|
+
category_outlier: categoryOutlierStrategy,
|
|
9
|
+
change_point: changePointStrategy,
|
|
10
|
+
low_variance: lowVarianceStrategy,
|
|
11
|
+
majority: majorityStrategy,
|
|
12
|
+
correlation: correlationStrategy,
|
|
13
|
+
};
|
|
14
|
+
var marks = (_a = insightType2Strategy[insightType]) === null || _a === void 0 ? void 0 : _a.call(insightType2Strategy, insight);
|
|
15
|
+
return viewSpecStrategy(marks, insight);
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
import { size } from 'lodash';
|
|
3
|
+
import { dataFormat } from '../../../../utils';
|
|
4
|
+
import { BOLD_FONT_WEIGHT } from '../../constants';
|
|
5
|
+
import { insight2ChartStrategy } from '../chart';
|
|
6
|
+
import { textMarkStrategy, intervalMarkStrategy } from '../commonMarks';
|
|
7
|
+
import { augmentedMarks2Marks } from '../../utils';
|
|
8
|
+
export var categoryOutlierAugmentedMarksStrategy = function (insight) {
|
|
9
|
+
var patterns = insight.patterns;
|
|
10
|
+
if (!size(patterns))
|
|
11
|
+
return [];
|
|
12
|
+
var categoryOutlierMarks = [];
|
|
13
|
+
patterns.forEach(function (pattern) {
|
|
14
|
+
var rectMark = intervalMarkStrategy([pattern]);
|
|
15
|
+
var textMark = textMarkStrategy([pattern], {
|
|
16
|
+
style: { fontWeight: BOLD_FONT_WEIGHT, dy: -8 },
|
|
17
|
+
formatter: dataFormat,
|
|
18
|
+
});
|
|
19
|
+
categoryOutlierMarks.push({
|
|
20
|
+
categoryOutlier: [rectMark, textMark],
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
return categoryOutlierMarks;
|
|
24
|
+
};
|
|
25
|
+
export var categoryOutlierStrategy = function (insight) {
|
|
26
|
+
var chart = insight2ChartStrategy(insight);
|
|
27
|
+
var categoryOutlierMarks = categoryOutlierAugmentedMarksStrategy(insight);
|
|
28
|
+
var marks = augmentedMarks2Marks(categoryOutlierMarks);
|
|
29
|
+
return __spreadArray([chart], __read(marks), false);
|
|
30
|
+
};
|