@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,185 @@
|
|
|
1
|
+
import * as constants from './constants';
|
|
2
|
+
import type { Data, Specification } from '../common/types';
|
|
3
|
+
/**
|
|
4
|
+
* TS type of standard IDs for each chart type.
|
|
5
|
+
*
|
|
6
|
+
* 图表 ID 的 TS 类型
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type ChartId = (typeof constants.CHART_IDS)[number];
|
|
11
|
+
/**
|
|
12
|
+
* TS type of chart families.
|
|
13
|
+
*
|
|
14
|
+
* 所有图表家族的 TS 类型
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export type Family = (typeof constants.FAMILIES)[number];
|
|
19
|
+
/**
|
|
20
|
+
* TS type of analysis purposes.
|
|
21
|
+
*
|
|
22
|
+
* 所有分析目的的 TS 类型
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export type Purpose = (typeof constants.PURPOSES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* TS type of coordinate systems.
|
|
29
|
+
*
|
|
30
|
+
* 所有坐标系的 TS 类型
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export type CoordinateSystem = (typeof constants.COORDINATE_SYSTEMS)[number];
|
|
35
|
+
/**
|
|
36
|
+
* TS type of graphic categories.
|
|
37
|
+
*
|
|
38
|
+
* 所有图形大类的 TS 类型
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export type GraphicCategory = (typeof constants.GRAPHIC_CATEGORIES)[number];
|
|
43
|
+
/**
|
|
44
|
+
* TS type of shapes.
|
|
45
|
+
*
|
|
46
|
+
* 所有形状的 TS 类型
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export type Shape = (typeof constants.SHAPES)[number];
|
|
51
|
+
/**
|
|
52
|
+
* TS type of level of measurements.
|
|
53
|
+
*
|
|
54
|
+
* 所有度量水平的 TS 类型
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export type LevelOfMeasurement = (typeof constants.LEVEL_OF_MEASUREMENTS)[number];
|
|
59
|
+
/**
|
|
60
|
+
* TS type of A prerequisite for being able to plot data for a specific chart type.
|
|
61
|
+
*
|
|
62
|
+
* 能绘制出某图表的数据的先决条件,它的 TS 类型
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export type DataPrerequisite = {
|
|
67
|
+
/**
|
|
68
|
+
* Minimum Quantity:
|
|
69
|
+
* At least this many fields are required to draw a chart of this type.
|
|
70
|
+
*
|
|
71
|
+
* 最小数量:
|
|
72
|
+
* 至少要这么多字段才能绘制出对应图表类型
|
|
73
|
+
*/
|
|
74
|
+
minQty: number;
|
|
75
|
+
/**
|
|
76
|
+
* Maximum Quantity:
|
|
77
|
+
* At most this many fields are required to draw a chart of this type.
|
|
78
|
+
* '*' stands for infinite.
|
|
79
|
+
*
|
|
80
|
+
* 最大数量:
|
|
81
|
+
* 超过这么多字段就不能或不适合绘制出对应图表类型
|
|
82
|
+
*/
|
|
83
|
+
maxQty: number | '*';
|
|
84
|
+
/**
|
|
85
|
+
* Level of Measurements which the above quantities apply.
|
|
86
|
+
*
|
|
87
|
+
* 上述字段数量指的是这里定义的“度量水平”匹配的字段
|
|
88
|
+
*/
|
|
89
|
+
fieldConditions: LevelOfMeasurement[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* TS type of channels.
|
|
93
|
+
*
|
|
94
|
+
* 所有通道的 TS 类型
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export type Channel = (typeof constants.CHANNELS)[number];
|
|
99
|
+
/**
|
|
100
|
+
* TS type of recommend ratings.
|
|
101
|
+
*
|
|
102
|
+
* 所有推荐评级
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
* @see {@link ./constants.ts#RECOMMEND_RATINGS}
|
|
106
|
+
*/
|
|
107
|
+
export type RecommendRating = (typeof constants.RECOMMEND_RATINGS)[number];
|
|
108
|
+
/**
|
|
109
|
+
* TS type of pure knowledge for a chart type.
|
|
110
|
+
* Pure means it is the original English version and not for custom chart types.
|
|
111
|
+
*
|
|
112
|
+
* 原装图表类型的信息结构的 TS 类型,非自定义图标类型。
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export type PureChartKnowledge = {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
alias: string[];
|
|
120
|
+
family: Family[];
|
|
121
|
+
def: string;
|
|
122
|
+
purpose: Purpose[];
|
|
123
|
+
coord: CoordinateSystem[];
|
|
124
|
+
category: GraphicCategory[];
|
|
125
|
+
shape: Shape[];
|
|
126
|
+
dataPres: DataPrerequisite[];
|
|
127
|
+
channel: Channel[];
|
|
128
|
+
recRate: RecommendRating;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* TS type of knowledge for a chart type.
|
|
132
|
+
* Could be in any language or values(string), or for custom chart types(with a `toSpec` function).
|
|
133
|
+
*
|
|
134
|
+
* 图表类型的信息结构的 TS 类型,可能是不同语言版本, 值和图表类型本身可能是自定义的。自定义图标应当包含 toSpec 方法。
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
export type ChartKnowledge = {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
alias: string[];
|
|
142
|
+
family: string[];
|
|
143
|
+
def: string;
|
|
144
|
+
purpose: string[];
|
|
145
|
+
coord: string[];
|
|
146
|
+
category: string[];
|
|
147
|
+
shape: string[];
|
|
148
|
+
dataPres: (Omit<DataPrerequisite, 'fieldConditions'> & {
|
|
149
|
+
fieldConditions: string[];
|
|
150
|
+
})[];
|
|
151
|
+
channel: string[];
|
|
152
|
+
recRate: string;
|
|
153
|
+
toSpec?: (data: Data, dataProps: any) => Specification | null;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* TS type of pure CKB(Chart Knowledge Base).
|
|
157
|
+
* Pure means it is the original English version of CKB and without custom chart types.
|
|
158
|
+
*
|
|
159
|
+
* 整个图表知识库(CKB)的原装英文版本的 TS 类型,不带自定义图表类型。
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
export type PureChartKnowledgeBase = Record<ChartId, PureChartKnowledge>;
|
|
164
|
+
/**
|
|
165
|
+
* TS type of CKB(Chart Knowledge Base).
|
|
166
|
+
* Could be in any language or contain custom chart types.
|
|
167
|
+
*
|
|
168
|
+
* 整个图表知识库(CKB)的 TS 类型,可能是不同语言版本以及可以带自定义图表类型
|
|
169
|
+
*
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
export type ChartKnowledgeBase = Record<string, ChartKnowledge>;
|
|
173
|
+
/**
|
|
174
|
+
* Configuration to pick, omit and customize CKB.
|
|
175
|
+
* Priority: exclude > include, + custom.
|
|
176
|
+
*
|
|
177
|
+
* 用来摘选、剔除和自定义 CKB 的配置。
|
|
178
|
+
* 优先级逻辑是:先从原装 CKB 中剔除`exclude`的部分,然后在剩余的图表类型中摘选出`include`的部分,
|
|
179
|
+
* 最后额外加上自定义的图表类型。
|
|
180
|
+
*/
|
|
181
|
+
export type CkbConfig = {
|
|
182
|
+
exclude?: string[];
|
|
183
|
+
include?: string[];
|
|
184
|
+
custom?: ChartKnowledgeBase;
|
|
185
|
+
};
|
package/lib/ckb/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { G2ChartSpec } from '../advisor/types';
|
|
2
|
+
/**
|
|
3
|
+
* One row(record) of data in JSON.
|
|
4
|
+
*/
|
|
5
|
+
export type Datum = Record<string, any>;
|
|
6
|
+
/**
|
|
7
|
+
* Rows(records) of data.
|
|
8
|
+
*/
|
|
9
|
+
export type Data = Datum[];
|
|
10
|
+
/**
|
|
11
|
+
* Specification: declarative schema to describe a visualization.
|
|
12
|
+
*/
|
|
13
|
+
export type Specification = G2ChartSpec;
|
|
14
|
+
export type ChartSpec = G2ChartSpec;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { DateFieldInfo, FieldInfo, NumberFieldInfo, StringFieldInfo } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Check if it is StringFieldInfo.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isStringFieldInfo(x: FieldInfo): x is StringFieldInfo;
|
|
6
|
+
/**
|
|
7
|
+
* Check if it is NumberFieldInfo.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isNumberFieldInfo(x: FieldInfo): x is NumberFieldInfo;
|
|
10
|
+
/**
|
|
11
|
+
* Check if it is DateFieldInfo.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isDateFieldInfo(x: FieldInfo): x is DateFieldInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if field is constant
|
|
16
|
+
* @param info - The {@link FieldInfo} to process
|
|
17
|
+
*/
|
|
18
|
+
export declare function isConst(info: FieldInfo): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if field is an ordinal.
|
|
21
|
+
* @param info - Field Info
|
|
22
|
+
*/
|
|
23
|
+
export declare function isOrdinal(info: FieldInfo): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if field is an unique.
|
|
26
|
+
* @param info - The {@link FieldInfo} to process
|
|
27
|
+
*/
|
|
28
|
+
export declare function isUnique(info: FieldInfo): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if field is discrete.
|
|
31
|
+
* @remarks
|
|
32
|
+
* @param info - The {@link FieldInfo} to process
|
|
33
|
+
*/
|
|
34
|
+
export declare function isDiscrete(info: FieldInfo): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if field is a continuous.
|
|
37
|
+
* @param info - The {@link FieldInfo} to process
|
|
38
|
+
*/
|
|
39
|
+
export declare function isContinuous(info: FieldInfo): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if field is an interval.
|
|
42
|
+
* @param info - The {@link FieldInfo} to process
|
|
43
|
+
*/
|
|
44
|
+
export declare function isInterval(info: FieldInfo): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if field is a nominal.
|
|
47
|
+
* @param info - The {@link FieldInfo} to process
|
|
48
|
+
*/
|
|
49
|
+
export declare function isNominal(info: FieldInfo): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if field is a time.
|
|
52
|
+
* @param info - Field Info
|
|
53
|
+
*/
|
|
54
|
+
export declare function isTime(info: FieldInfo): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Analyze string field info.
|
|
57
|
+
* @param value - data
|
|
58
|
+
*/
|
|
59
|
+
export declare function analyzeString(value: string[]): Omit<StringFieldInfo, keyof FieldInfo>;
|
|
60
|
+
/**
|
|
61
|
+
* Analyze number field info.
|
|
62
|
+
* @param value - data
|
|
63
|
+
*/
|
|
64
|
+
export declare function analyzeNumber(value: number[]): Omit<NumberFieldInfo, keyof FieldInfo>;
|
|
65
|
+
/**
|
|
66
|
+
* Analyze date field info.
|
|
67
|
+
* @param value - data
|
|
68
|
+
*/
|
|
69
|
+
export declare function analyzeDate(value: (string | Date)[], isInteger?: boolean): Omit<DateFieldInfo, keyof FieldInfo>;
|
|
70
|
+
/**
|
|
71
|
+
* Determine what type a value is, may be one of [integer float date string null].
|
|
72
|
+
*/
|
|
73
|
+
export declare function analyzeType(value: unknown, strictDatePattern?: boolean): 'null' | 'integer' | 'float' | 'date' | 'string';
|
|
74
|
+
/**
|
|
75
|
+
* Analyze field info.
|
|
76
|
+
* @param value - data
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare function analyzeField(value: unknown[], strictDatePattern?: boolean): StringFieldInfo | NumberFieldInfo | DateFieldInfo;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.analyzeField = exports.analyzeType = exports.analyzeDate = exports.analyzeNumber = exports.analyzeString = exports.isTime = exports.isNominal = exports.isInterval = exports.isContinuous = exports.isDiscrete = exports.isUnique = exports.isOrdinal = exports.isConst = exports.isDateFieldInfo = exports.isNumberFieldInfo = exports.isStringFieldInfo = void 0;
|
|
4
|
+
var statistics_1 = require("../../statistics");
|
|
5
|
+
var utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* Check if it is StringFieldInfo.
|
|
8
|
+
*/
|
|
9
|
+
function isStringFieldInfo(x) {
|
|
10
|
+
return x.recommendation === 'string';
|
|
11
|
+
}
|
|
12
|
+
exports.isStringFieldInfo = isStringFieldInfo;
|
|
13
|
+
/**
|
|
14
|
+
* Check if it is NumberFieldInfo.
|
|
15
|
+
*/
|
|
16
|
+
function isNumberFieldInfo(x) {
|
|
17
|
+
return x.recommendation === 'integer' || x.recommendation === 'float';
|
|
18
|
+
}
|
|
19
|
+
exports.isNumberFieldInfo = isNumberFieldInfo;
|
|
20
|
+
/**
|
|
21
|
+
* Check if it is DateFieldInfo.
|
|
22
|
+
*/
|
|
23
|
+
function isDateFieldInfo(x) {
|
|
24
|
+
return x.recommendation === 'date';
|
|
25
|
+
}
|
|
26
|
+
exports.isDateFieldInfo = isDateFieldInfo;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if field is constant
|
|
29
|
+
* @param info - The {@link FieldInfo} to process
|
|
30
|
+
*/
|
|
31
|
+
function isConst(info) {
|
|
32
|
+
return info.distinct === 1;
|
|
33
|
+
}
|
|
34
|
+
exports.isConst = isConst;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if field is an ordinal.
|
|
37
|
+
* @param info - Field Info
|
|
38
|
+
*/
|
|
39
|
+
function isOrdinal(info) {
|
|
40
|
+
var rawData = info.rawData, recommendation = info.recommendation;
|
|
41
|
+
if (recommendation !== 'string')
|
|
42
|
+
return false;
|
|
43
|
+
if (isConst(info))
|
|
44
|
+
return false;
|
|
45
|
+
var list = rawData.filter(function (item) { return !(0, utils_1.isNil)(item) && (0, utils_1.isBasicType)(item); });
|
|
46
|
+
if (list.length === 0)
|
|
47
|
+
return false;
|
|
48
|
+
var start = null;
|
|
49
|
+
var end = null;
|
|
50
|
+
var startIndex = -1;
|
|
51
|
+
var endIndex = -1;
|
|
52
|
+
var through = true;
|
|
53
|
+
while (through) {
|
|
54
|
+
var through_1 = true;
|
|
55
|
+
for (var i = 0; i < list.length; i += 1) {
|
|
56
|
+
var item = list[i];
|
|
57
|
+
var char = item[startIndex + 1];
|
|
58
|
+
if (start === null || i === 0)
|
|
59
|
+
start = char;
|
|
60
|
+
if (char !== start) {
|
|
61
|
+
through_1 = false;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!through_1)
|
|
66
|
+
break;
|
|
67
|
+
startIndex += 1;
|
|
68
|
+
}
|
|
69
|
+
through = true;
|
|
70
|
+
while (through) {
|
|
71
|
+
var through_2 = true;
|
|
72
|
+
for (var i = 0; i < list.length; i += 1) {
|
|
73
|
+
var item = list[i];
|
|
74
|
+
var char = item[item.length - 1 - (endIndex + 1)];
|
|
75
|
+
if (end === null || i === 0)
|
|
76
|
+
end = char;
|
|
77
|
+
if (char !== end) {
|
|
78
|
+
through_2 = false;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!through_2)
|
|
83
|
+
break;
|
|
84
|
+
endIndex += 1;
|
|
85
|
+
}
|
|
86
|
+
var patterns = [/\d+/, /(零|一|二|三|四|五|六|七|八|九|十)+/, /(一|二|三|四|五|六|日)/, /^[a-z]$/, /^[A-Z]$/];
|
|
87
|
+
if (startIndex === -1 && endIndex === -1)
|
|
88
|
+
return false;
|
|
89
|
+
var arr = list.map(function (item) {
|
|
90
|
+
return item.slice(startIndex === -1 ? 0 : startIndex + 1, endIndex === -1 ? undefined : item.length - endIndex - 1);
|
|
91
|
+
});
|
|
92
|
+
var _loop_1 = function (i) {
|
|
93
|
+
var p = patterns[i];
|
|
94
|
+
var notMatch = arr.some(function (item) { return !p.test(item); });
|
|
95
|
+
if (!notMatch)
|
|
96
|
+
return { value: true };
|
|
97
|
+
};
|
|
98
|
+
for (var i = 0; i < patterns.length; i += 1) {
|
|
99
|
+
var state_1 = _loop_1(i);
|
|
100
|
+
if (typeof state_1 === "object")
|
|
101
|
+
return state_1.value;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
exports.isOrdinal = isOrdinal;
|
|
106
|
+
/**
|
|
107
|
+
* Checks if field is an unique.
|
|
108
|
+
* @param info - The {@link FieldInfo} to process
|
|
109
|
+
*/
|
|
110
|
+
function isUnique(info) {
|
|
111
|
+
return info.distinct === info.count;
|
|
112
|
+
}
|
|
113
|
+
exports.isUnique = isUnique;
|
|
114
|
+
/**
|
|
115
|
+
* Checks if field is discrete.
|
|
116
|
+
* @remarks
|
|
117
|
+
* @param info - The {@link FieldInfo} to process
|
|
118
|
+
*/
|
|
119
|
+
function isDiscrete(info) {
|
|
120
|
+
return info.recommendation === 'integer';
|
|
121
|
+
}
|
|
122
|
+
exports.isDiscrete = isDiscrete;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if field is a continuous.
|
|
125
|
+
* @param info - The {@link FieldInfo} to process
|
|
126
|
+
*/
|
|
127
|
+
function isContinuous(info) {
|
|
128
|
+
return info.recommendation === 'float';
|
|
129
|
+
}
|
|
130
|
+
exports.isContinuous = isContinuous;
|
|
131
|
+
/**
|
|
132
|
+
* Checks if field is an interval.
|
|
133
|
+
* @param info - The {@link FieldInfo} to process
|
|
134
|
+
*/
|
|
135
|
+
function isInterval(info) {
|
|
136
|
+
return info.recommendation === 'integer' || info.recommendation === 'float';
|
|
137
|
+
}
|
|
138
|
+
exports.isInterval = isInterval;
|
|
139
|
+
/**
|
|
140
|
+
* Checks if field is a nominal.
|
|
141
|
+
* @param info - The {@link FieldInfo} to process
|
|
142
|
+
*/
|
|
143
|
+
function isNominal(info) {
|
|
144
|
+
if (info.recommendation === 'boolean')
|
|
145
|
+
return true;
|
|
146
|
+
if (info.recommendation === 'string')
|
|
147
|
+
return !isOrdinal(info);
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
exports.isNominal = isNominal;
|
|
151
|
+
/**
|
|
152
|
+
* Checks if field is a time.
|
|
153
|
+
* @param info - Field Info
|
|
154
|
+
*/
|
|
155
|
+
function isTime(info) {
|
|
156
|
+
return info.recommendation === 'date';
|
|
157
|
+
}
|
|
158
|
+
exports.isTime = isTime;
|
|
159
|
+
/**
|
|
160
|
+
* Analyze string field info.
|
|
161
|
+
* @param value - data
|
|
162
|
+
*/
|
|
163
|
+
function analyzeString(value) {
|
|
164
|
+
var lenArray = value.map(function (item) { return item.length; });
|
|
165
|
+
return {
|
|
166
|
+
maxLength: (0, statistics_1.max)(lenArray),
|
|
167
|
+
minLength: (0, statistics_1.min)(lenArray),
|
|
168
|
+
meanLength: (0, statistics_1.mean)(lenArray),
|
|
169
|
+
containsChar: value.some(function (item) { return /[A-z]/.test(item); }),
|
|
170
|
+
containsDigit: value.some(function (item) { return /[0-9]/.test(item); }),
|
|
171
|
+
containsSpace: value.some(function (item) { return /\s/.test(item); }),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
exports.analyzeString = analyzeString;
|
|
175
|
+
/**
|
|
176
|
+
* Analyze number field info.
|
|
177
|
+
* @param value - data
|
|
178
|
+
*/
|
|
179
|
+
function analyzeNumber(value) {
|
|
180
|
+
return {
|
|
181
|
+
minimum: (0, statistics_1.min)(value),
|
|
182
|
+
maximum: (0, statistics_1.max)(value),
|
|
183
|
+
mean: (0, statistics_1.mean)(value),
|
|
184
|
+
percentile5: (0, statistics_1.quantile)(value, 5),
|
|
185
|
+
percentile25: (0, statistics_1.quantile)(value, 25),
|
|
186
|
+
percentile50: (0, statistics_1.quantile)(value, 50),
|
|
187
|
+
percentile75: (0, statistics_1.quantile)(value, 75),
|
|
188
|
+
percentile95: (0, statistics_1.quantile)(value, 95),
|
|
189
|
+
sum: (0, statistics_1.sum)(value),
|
|
190
|
+
variance: (0, statistics_1.variance)(value),
|
|
191
|
+
standardDeviation: (0, statistics_1.standardDeviation)(value),
|
|
192
|
+
zeros: value.filter(function (item) { return item === 0; }).length,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
exports.analyzeNumber = analyzeNumber;
|
|
196
|
+
/**
|
|
197
|
+
* Analyze date field info.
|
|
198
|
+
* @param value - data
|
|
199
|
+
*/
|
|
200
|
+
function analyzeDate(value, isInteger) {
|
|
201
|
+
if (isInteger === void 0) { isInteger = false; }
|
|
202
|
+
var list = value.map(function (item) {
|
|
203
|
+
if (isInteger) {
|
|
204
|
+
var str = "".concat(item);
|
|
205
|
+
if (str.length === 8)
|
|
206
|
+
return new Date("".concat(str.substring(0, 4), "/").concat(str.substring(4, 2), "/").concat(str.substring(6, 2))).getTime();
|
|
207
|
+
}
|
|
208
|
+
return new Date(item).getTime();
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
minimum: value[(0, statistics_1.minIndex)(list)],
|
|
212
|
+
maximum: value[(0, statistics_1.maxIndex)(list)],
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
exports.analyzeDate = analyzeDate;
|
|
216
|
+
/**
|
|
217
|
+
* Determine what type a value is, may be one of [integer float date string null].
|
|
218
|
+
*/
|
|
219
|
+
function analyzeType(value, strictDatePattern) {
|
|
220
|
+
if ((0, utils_1.isNil)(value))
|
|
221
|
+
return 'null';
|
|
222
|
+
if ((0, utils_1.isNumber)(value)) {
|
|
223
|
+
if ((0, utils_1.isInteger)(value))
|
|
224
|
+
return 'integer';
|
|
225
|
+
return 'float';
|
|
226
|
+
}
|
|
227
|
+
// 优先识别日期类型,避免字符型日期被判断成字符
|
|
228
|
+
if ((0, utils_1.isDate)(value) || (0, utils_1.isDateString)(value, strictDatePattern))
|
|
229
|
+
return 'date';
|
|
230
|
+
if ((0, utils_1.isString)(value)) {
|
|
231
|
+
if ((0, utils_1.isNumberString)(value)) {
|
|
232
|
+
if (value.includes('.'))
|
|
233
|
+
return 'float';
|
|
234
|
+
return 'integer';
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return 'string';
|
|
238
|
+
}
|
|
239
|
+
exports.analyzeType = analyzeType;
|
|
240
|
+
/**
|
|
241
|
+
* Analyze field info.
|
|
242
|
+
* @param value - data
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
245
|
+
function analyzeField(value, strictDatePattern) {
|
|
246
|
+
var list = value.map(function (item) { return ((0, utils_1.isNil)(item) ? null : item); });
|
|
247
|
+
var valueMap = (0, statistics_1.valueMap)(list);
|
|
248
|
+
var recommendation;
|
|
249
|
+
var nonNullArray = valueMap.null ? list.filter(function (item) { return item !== null; }) : list;
|
|
250
|
+
var typeArray = list.map(function (item) { return analyzeType(item, strictDatePattern); });
|
|
251
|
+
var types = Object.keys((0, statistics_1.valueMap)(typeArray)).filter(function (item) { return item !== 'null'; });
|
|
252
|
+
// generate recommendation
|
|
253
|
+
switch (types.length) {
|
|
254
|
+
case 0:
|
|
255
|
+
recommendation = 'null';
|
|
256
|
+
break;
|
|
257
|
+
case 1:
|
|
258
|
+
recommendation = types[0];
|
|
259
|
+
// an integer field may be a date field
|
|
260
|
+
if (recommendation === 'integer') {
|
|
261
|
+
var data = list.filter(function (item) { return item !== null; });
|
|
262
|
+
if (data.map(function (num) { return "".concat(num); }).every(function (str) { return (0, utils_1.isDateString)(str); })) {
|
|
263
|
+
recommendation = 'date';
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
case 2:
|
|
268
|
+
if ((types.includes('integer') || types.includes('date')) && types.includes('float')) {
|
|
269
|
+
recommendation = 'float';
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
if (types.includes('integer') && types.includes('date')) {
|
|
273
|
+
// an integer field may be a date field
|
|
274
|
+
var data = list.filter(function (item) { return item !== null; });
|
|
275
|
+
if (data.map(function (num) { return "".concat(num); }).every(function (str) { return (0, utils_1.isDateString)(str); })) {
|
|
276
|
+
recommendation = 'date';
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
recommendation = 'integer';
|
|
280
|
+
}
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
recommendation = 'string';
|
|
284
|
+
break;
|
|
285
|
+
default:
|
|
286
|
+
recommendation = 'string';
|
|
287
|
+
}
|
|
288
|
+
var uniqueArray = (0, utils_1.unique)(nonNullArray);
|
|
289
|
+
var fieldInfo = {
|
|
290
|
+
count: value.length,
|
|
291
|
+
distinct: uniqueArray.length,
|
|
292
|
+
type: types.length <= 1 ? types[0] || 'null' : 'mixed',
|
|
293
|
+
recommendation: recommendation,
|
|
294
|
+
missing: valueMap.null || 0,
|
|
295
|
+
rawData: value,
|
|
296
|
+
valueMap: valueMap,
|
|
297
|
+
};
|
|
298
|
+
if (types.length > 1) {
|
|
299
|
+
var meta_1 = {};
|
|
300
|
+
var restNotNullArray_1 = nonNullArray;
|
|
301
|
+
types.forEach(function (item) {
|
|
302
|
+
if (item === 'date') {
|
|
303
|
+
meta_1.date = analyzeField(restNotNullArray_1.filter(function (item) { return (0, utils_1.isDateString)(item); }), strictDatePattern);
|
|
304
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return !(0, utils_1.isDateString)(item); });
|
|
305
|
+
}
|
|
306
|
+
else if (item === 'integer') {
|
|
307
|
+
meta_1.integer = analyzeField(restNotNullArray_1.filter(function (item) { return (0, utils_1.isIntegerString)(item) && !(0, utils_1.isDateString)(item); }), strictDatePattern);
|
|
308
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return !(0, utils_1.isIntegerString)(item); });
|
|
309
|
+
}
|
|
310
|
+
else if (item === 'float') {
|
|
311
|
+
meta_1.float = analyzeField(restNotNullArray_1.filter(function (item) { return (0, utils_1.isFloatString)(item) && !(0, utils_1.isDateString)(item); }), strictDatePattern);
|
|
312
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return !(0, utils_1.isFloatString)(item); });
|
|
313
|
+
}
|
|
314
|
+
else if (item === 'string') {
|
|
315
|
+
meta_1.string = analyzeField(restNotNullArray_1.filter(function (item) { return analyzeType(item, strictDatePattern) === 'string'; }));
|
|
316
|
+
restNotNullArray_1 = restNotNullArray_1.filter(function (item) { return analyzeType(item, strictDatePattern) !== 'string'; });
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
fieldInfo.meta = meta_1;
|
|
320
|
+
}
|
|
321
|
+
if (fieldInfo.distinct === 2 && fieldInfo.recommendation !== 'date') {
|
|
322
|
+
// temporarily threshold
|
|
323
|
+
if (list.length >= 100) {
|
|
324
|
+
fieldInfo.recommendation = 'boolean';
|
|
325
|
+
}
|
|
326
|
+
else if ((0, utils_1.isBoolean)(uniqueArray, true)) {
|
|
327
|
+
fieldInfo.recommendation = 'boolean';
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (recommendation === 'string') {
|
|
331
|
+
Object.assign(fieldInfo, analyzeString(nonNullArray.map(function (item) { return "".concat(item); })));
|
|
332
|
+
}
|
|
333
|
+
if (recommendation === 'integer' || recommendation === 'float') {
|
|
334
|
+
Object.assign(fieldInfo, analyzeNumber(nonNullArray.map(function (item) { return item * 1; })));
|
|
335
|
+
}
|
|
336
|
+
if (recommendation === 'date') {
|
|
337
|
+
Object.assign(fieldInfo, analyzeDate(nonNullArray, fieldInfo.type === 'integer'));
|
|
338
|
+
}
|
|
339
|
+
var levelOfMeasurements = [];
|
|
340
|
+
if (isNominal(fieldInfo))
|
|
341
|
+
levelOfMeasurements.push('Nominal');
|
|
342
|
+
if (isOrdinal(fieldInfo))
|
|
343
|
+
levelOfMeasurements.push('Ordinal');
|
|
344
|
+
if (isInterval(fieldInfo))
|
|
345
|
+
levelOfMeasurements.push('Interval');
|
|
346
|
+
if (isDiscrete(fieldInfo))
|
|
347
|
+
levelOfMeasurements.push('Discrete');
|
|
348
|
+
if (isContinuous(fieldInfo))
|
|
349
|
+
levelOfMeasurements.push('Continuous');
|
|
350
|
+
if (isTime(fieldInfo))
|
|
351
|
+
levelOfMeasurements.push('Time');
|
|
352
|
+
fieldInfo.levelOfMeasurements = levelOfMeasurements;
|
|
353
|
+
return fieldInfo;
|
|
354
|
+
}
|
|
355
|
+
exports.analyzeField = analyzeField;
|