@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,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var utils_1 = require("../../utils");
|
|
5
|
+
var utils_2 = require("./utils");
|
|
6
|
+
var baseFrame_1 = tslib_1.__importDefault(require("./baseFrame"));
|
|
7
|
+
/** 1D data structure */
|
|
8
|
+
var Series = /** @class */ (function (_super) {
|
|
9
|
+
tslib_1.__extends(Series, _super);
|
|
10
|
+
function Series(data, extra) {
|
|
11
|
+
var _this = this;
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
|
+
_this = _super.call(this, data, extra) || this;
|
|
14
|
+
(0, utils_1.assert)((0, utils_1.isObject)(data) || (0, utils_1.isBasicType)(data) || (0, utils_1.isArray)(data), 'Data type is illegal');
|
|
15
|
+
/* 1D: object */
|
|
16
|
+
if ((0, utils_1.isObject)(data)) {
|
|
17
|
+
// generate indexes
|
|
18
|
+
var indexes = Object.keys(data);
|
|
19
|
+
if (extra === null || extra === void 0 ? void 0 : extra.indexes) {
|
|
20
|
+
(0, utils_1.assert)(((_a = extra === null || extra === void 0 ? void 0 : extra.indexes) === null || _a === void 0 ? void 0 : _a.length) <= indexes.length, "Index length ".concat((_b = extra === null || extra === void 0 ? void 0 : extra.indexes) === null || _b === void 0 ? void 0 : _b.length, " is greater than data size ").concat(indexes.length));
|
|
21
|
+
for (var i = 0; i < (extra === null || extra === void 0 ? void 0 : extra.indexes.length); i += 1) {
|
|
22
|
+
var idx = extra === null || extra === void 0 ? void 0 : extra.indexes[i];
|
|
23
|
+
if (indexes.includes(idx)) {
|
|
24
|
+
_this.data.push((0, utils_2.convertDataType)((0, utils_2.fillMissingValue)(data[idx], extra === null || extra === void 0 ? void 0 : extra.fillValue), (_c = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _c === void 0 ? void 0 : _c[0]));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
_this.setAxis(0, extra === null || extra === void 0 ? void 0 : extra.indexes);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
_this.data = Object.values(data).map(function (datum) { var _a; return (0, utils_2.convertDataType)((0, utils_2.fillMissingValue)(datum, extra === null || extra === void 0 ? void 0 : extra.fillValue), (_a = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _a === void 0 ? void 0 : _a[0]); });
|
|
31
|
+
_this.setAxis(0, indexes);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if ((0, utils_1.isArray)(data)) {
|
|
35
|
+
/* 1D: array */
|
|
36
|
+
var _e = tslib_1.__read(data, 1), data0 = _e[0];
|
|
37
|
+
if (!(0, utils_1.isBasicType)(data0)) {
|
|
38
|
+
if (extra === null || extra === void 0 ? void 0 : extra.indexes) {
|
|
39
|
+
(0, utils_1.assert)(((_d = extra === null || extra === void 0 ? void 0 : extra.indexes) === null || _d === void 0 ? void 0 : _d.length) === data.length, "Index length is ".concat(extra === null || extra === void 0 ? void 0 : extra.indexes.length, ", but data size ").concat(data.length));
|
|
40
|
+
_this.setAxis(0, extra === null || extra === void 0 ? void 0 : extra.indexes);
|
|
41
|
+
}
|
|
42
|
+
_this.data = data;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
Object.defineProperty(Series.prototype, "shape", {
|
|
48
|
+
get: function () {
|
|
49
|
+
return [this.axes[0].length];
|
|
50
|
+
},
|
|
51
|
+
enumerable: false,
|
|
52
|
+
configurable: true
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Get data by row location and column location.
|
|
56
|
+
* @param rowLoc
|
|
57
|
+
*/
|
|
58
|
+
Series.prototype.get = function (rowLoc) {
|
|
59
|
+
(0, utils_1.assert)((0, utils_1.isNumber)(rowLoc) ||
|
|
60
|
+
((0, utils_1.isString)(rowLoc) && !rowLoc.includes(':')) ||
|
|
61
|
+
(0, utils_1.isArray)(rowLoc) ||
|
|
62
|
+
((0, utils_1.isString)(rowLoc) && rowLoc.includes(':')), 'The rowLoc is illegal');
|
|
63
|
+
// input is like 0 || 'a'
|
|
64
|
+
if ((0, utils_1.isNumber)(rowLoc) || ((0, utils_1.isString)(rowLoc) && !rowLoc.includes(':'))) {
|
|
65
|
+
(0, utils_1.assert)(this.indexes.includes(rowLoc), 'The rowLoc is not found in the indexes.');
|
|
66
|
+
if ((0, utils_1.isNumber)(rowLoc)) {
|
|
67
|
+
return this.data[rowLoc];
|
|
68
|
+
}
|
|
69
|
+
if ((0, utils_1.isString)(rowLoc)) {
|
|
70
|
+
var rowIdx = this.indexes.indexOf(rowLoc);
|
|
71
|
+
return this.data[rowIdx];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if ((0, utils_1.isArray)(rowLoc)) {
|
|
75
|
+
// input is like [0, 1, 2] || ['a', 'b', 'c']
|
|
76
|
+
var newData = [];
|
|
77
|
+
var newIndex = [];
|
|
78
|
+
for (var i = 0; i < rowLoc.length; i += 1) {
|
|
79
|
+
var loc = rowLoc[i];
|
|
80
|
+
(0, utils_1.assert)(this.indexes.includes(loc), 'The rowLoc is not found in the indexes.');
|
|
81
|
+
var idxInIndex = this.indexes.indexOf(loc);
|
|
82
|
+
newData.push(this.data[idxInIndex]);
|
|
83
|
+
newIndex.push(this.indexes[idxInIndex]);
|
|
84
|
+
}
|
|
85
|
+
return new Series(newData, { indexes: newIndex });
|
|
86
|
+
}
|
|
87
|
+
if ((0, utils_1.isString)(rowLoc) && rowLoc.includes(':')) {
|
|
88
|
+
// input is like '0:2' || 'a:c'
|
|
89
|
+
var rowLocArr = rowLoc.split(':');
|
|
90
|
+
(0, utils_1.assert)(rowLocArr.length === 2, 'The rowLoc is not found in the indexes.');
|
|
91
|
+
var startLoc = rowLocArr[0];
|
|
92
|
+
var endLoc = rowLocArr[1];
|
|
93
|
+
if ((0, utils_1.isInteger)(Number(startLoc)) && (0, utils_1.isInteger)(Number(endLoc))) {
|
|
94
|
+
var startIdx = Number(startLoc);
|
|
95
|
+
var endIdx = Number(endLoc);
|
|
96
|
+
var newData = this.data.slice(startIdx, endIdx);
|
|
97
|
+
var newIndex = this.indexes.slice(startIdx, endIdx);
|
|
98
|
+
return new Series(newData, { indexes: newIndex });
|
|
99
|
+
}
|
|
100
|
+
if ((0, utils_1.isString)(startLoc) && (0, utils_1.isString)(endLoc)) {
|
|
101
|
+
var startIdx = this.indexes.indexOf(startLoc);
|
|
102
|
+
var endIdx = this.indexes.indexOf(endLoc);
|
|
103
|
+
var newData = this.data.slice(startIdx, endIdx);
|
|
104
|
+
var newIndex = this.indexes.slice(startIdx, endIdx);
|
|
105
|
+
return new Series(newData, { indexes: newIndex });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
throw new Error('The rowLoc is illegal');
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Get data by row location and column location using integer index.
|
|
112
|
+
* @param rowLoc
|
|
113
|
+
*/
|
|
114
|
+
Series.prototype.getByIndex = function (rowLoc) {
|
|
115
|
+
(0, utils_1.assert)((0, utils_1.isInteger)(rowLoc) || (0, utils_1.isArray)(rowLoc) || ((0, utils_1.isString)(rowLoc) && rowLoc.includes(':')), 'The rowLoc is illegal');
|
|
116
|
+
// input is like 1
|
|
117
|
+
if ((0, utils_1.isInteger)(rowLoc)) {
|
|
118
|
+
(0, utils_1.assert)((0, utils_1.range)(this.indexes.length).includes(rowLoc), 'The rowLoc is not found in the indexes.');
|
|
119
|
+
if ((0, utils_1.range)(this.indexes.length).includes(rowLoc)) {
|
|
120
|
+
return this.data[rowLoc];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if ((0, utils_1.isArray)(rowLoc)) {
|
|
124
|
+
// input is like [0, 1, 2]
|
|
125
|
+
var newData = [];
|
|
126
|
+
var newIndex = [];
|
|
127
|
+
for (var i = 0; i < rowLoc.length; i += 1) {
|
|
128
|
+
var idx = rowLoc[i];
|
|
129
|
+
(0, utils_1.assert)((0, utils_1.range)(this.indexes.length).includes(idx), 'The rowLoc is not found in the indexes.');
|
|
130
|
+
newData.push(this.data[idx]);
|
|
131
|
+
newIndex.push(this.indexes[idx]);
|
|
132
|
+
}
|
|
133
|
+
return new Series(newData, { indexes: newIndex });
|
|
134
|
+
}
|
|
135
|
+
if ((0, utils_1.isString)(rowLoc) && rowLoc.includes(':')) {
|
|
136
|
+
// input is like '0:2'
|
|
137
|
+
var rowLocArr = rowLoc.split(':');
|
|
138
|
+
if (rowLocArr.length === 2) {
|
|
139
|
+
var startIdx = Number(rowLocArr[0]);
|
|
140
|
+
var endIdx = Number(rowLocArr[1]);
|
|
141
|
+
(0, utils_1.assert)((0, utils_1.isInteger)(startIdx) && (0, utils_1.isInteger)(endIdx), 'The rowLoc is not found in the indexes.');
|
|
142
|
+
var newData = this.data.slice(startIdx, endIdx);
|
|
143
|
+
var newIndex = this.indexes.slice(startIdx, endIdx);
|
|
144
|
+
return new Series(newData, { indexes: newIndex });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
throw new Error('The rowLoc is illegal');
|
|
148
|
+
};
|
|
149
|
+
return Series;
|
|
150
|
+
}(baseFrame_1.default));
|
|
151
|
+
exports.default = Series;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { StringFieldInfo, NumberFieldInfo, DateFieldInfo, FieldType } from '../../analysis/types';
|
|
2
|
+
/**
|
|
3
|
+
* Array Type. One dimension or two dimension
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type NDArray = unknown[] | unknown[][];
|
|
7
|
+
/**
|
|
8
|
+
* One dimension series data.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type SeriesData = number | string | boolean | undefined | null | unknown[] | {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* One or two dimension frame data.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export type FrameData = number | string | boolean | undefined | null | unknown[] | {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
} | unknown[][] | {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}[] | {
|
|
23
|
+
[key: string]: unknown[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Axis
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export type Axis = string | number;
|
|
30
|
+
/**
|
|
31
|
+
* extra data configs
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export type Extra = {
|
|
35
|
+
indexes?: Axis[];
|
|
36
|
+
columns?: Axis[];
|
|
37
|
+
fillValue?: unknown;
|
|
38
|
+
/** When the columnType is empty, no data type is specified */
|
|
39
|
+
columnTypes?: (FieldType | '')[];
|
|
40
|
+
/**
|
|
41
|
+
* Whether only the main standard symbols recommended in ISO 8601 can be recognized as date fields, default is true.
|
|
42
|
+
* - Reference: https://www.cl.cam.ac.uk/~mgk25/iso-time.html
|
|
43
|
+
* - For example, '202301' is recognized as a date string only when strictDatePattern is false.
|
|
44
|
+
* */
|
|
45
|
+
strictDatePattern?: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Fields Type
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export type FieldsInfo = Array<(StringFieldInfo | NumberFieldInfo | DateFieldInfo) & {
|
|
52
|
+
/** Field name */
|
|
53
|
+
name: string;
|
|
54
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Axis, Extra } from './types';
|
|
2
|
+
export declare function isAxis(value: unknown): value is Axis;
|
|
3
|
+
export declare function generateArrayIndex(data: unknown[], extraIndex?: Axis[]): Axis[];
|
|
4
|
+
export declare function fillMissingValue(datum: unknown, fillValue: any): unknown;
|
|
5
|
+
export declare function generateSplit(length: number): string;
|
|
6
|
+
export declare function stringify(value: unknown): string;
|
|
7
|
+
export declare function getStringifyLength(value: unknown): number;
|
|
8
|
+
/**
|
|
9
|
+
* Convert data to specified data type.
|
|
10
|
+
* @param data
|
|
11
|
+
* @param type
|
|
12
|
+
*/
|
|
13
|
+
export declare function convertDataType(data: unknown, type: Extra['columnTypes'][number]): unknown;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertDataType = exports.getStringifyLength = exports.stringify = exports.generateSplit = exports.fillMissingValue = exports.generateArrayIndex = exports.isAxis = void 0;
|
|
4
|
+
var utils_1 = require("../../utils");
|
|
5
|
+
function isAxis(value) {
|
|
6
|
+
return (0, utils_1.isNumber)(value) || (0, utils_1.isString)(value);
|
|
7
|
+
}
|
|
8
|
+
exports.isAxis = isAxis;
|
|
9
|
+
// generate indexes for 1D and 2D array
|
|
10
|
+
function generateArrayIndex(data, extraIndex) {
|
|
11
|
+
(0, utils_1.assert)((0, utils_1.isArray)(data), 'Data must be an array');
|
|
12
|
+
if (extraIndex) {
|
|
13
|
+
(0, utils_1.assert)((extraIndex === null || extraIndex === void 0 ? void 0 : extraIndex.length) === data.length, "Index length is ".concat(extraIndex === null || extraIndex === void 0 ? void 0 : extraIndex.length, ", but data size is ").concat(data.length));
|
|
14
|
+
return extraIndex;
|
|
15
|
+
}
|
|
16
|
+
return (0, utils_1.range)(data.length);
|
|
17
|
+
}
|
|
18
|
+
exports.generateArrayIndex = generateArrayIndex;
|
|
19
|
+
function fillMissingValue(datum, fillValue) {
|
|
20
|
+
return !datum && JSON.stringify(fillValue) ? fillValue : datum;
|
|
21
|
+
}
|
|
22
|
+
exports.fillMissingValue = fillMissingValue;
|
|
23
|
+
function generateSplit(length) {
|
|
24
|
+
return Array((0, utils_1.isNumber)(length) ? length : 0)
|
|
25
|
+
.fill(' ')
|
|
26
|
+
.concat(' ')
|
|
27
|
+
.join('');
|
|
28
|
+
}
|
|
29
|
+
exports.generateSplit = generateSplit;
|
|
30
|
+
function stringify(value) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
|
+
return (((_f = (_e = (_d = (_c = (_b = (_a = JSON.stringify(value)) === null || _a === void 0 ? void 0 : _a.replace(/\\n/g, '')) === null || _b === void 0 ? void 0 : _b.replace(/\\/g, '')) === null || _c === void 0 ? void 0 : _c.replace(/"\[/g, '[')) === null || _d === void 0 ? void 0 : _d.replace(/\]"/g, ']')) === null || _e === void 0 ? void 0 : _e.replace(/"\{/g, '{')) === null || _f === void 0 ? void 0 : _f.replace(/\}"/g, ' }')) || 'undefined');
|
|
33
|
+
}
|
|
34
|
+
exports.stringify = stringify;
|
|
35
|
+
function getStringifyLength(value) {
|
|
36
|
+
var _a;
|
|
37
|
+
return (_a = stringify(value)) === null || _a === void 0 ? void 0 : _a.length;
|
|
38
|
+
}
|
|
39
|
+
exports.getStringifyLength = getStringifyLength;
|
|
40
|
+
/**
|
|
41
|
+
* Convert data to specified data type.
|
|
42
|
+
* @param data
|
|
43
|
+
* @param type
|
|
44
|
+
*/
|
|
45
|
+
function convertDataType(data, type) {
|
|
46
|
+
try {
|
|
47
|
+
if (type === 'string' && !(0, utils_1.isString)(data)) {
|
|
48
|
+
return "".concat(data);
|
|
49
|
+
}
|
|
50
|
+
if (type === 'boolean' && !(0, utils_1.isBoolean)(data)) {
|
|
51
|
+
return Boolean(data);
|
|
52
|
+
}
|
|
53
|
+
if (type === 'null' && !(0, utils_1.isNil)(data)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if ((type === 'integer' || type === 'float') && !(0, utils_1.isNumber)(data)) {
|
|
57
|
+
return +data;
|
|
58
|
+
}
|
|
59
|
+
if (type === 'date' && !(0, utils_1.isDate)(data) && ((0, utils_1.isNumber)(data) || (0, utils_1.isString)(data))) {
|
|
60
|
+
return new Date(data);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new Error(error);
|
|
65
|
+
}
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
exports.convertDataType = convertDataType;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DataFrame from '../field/dataFrame';
|
|
2
|
+
import type { GraphProps } from '../../analysis/graph/types';
|
|
3
|
+
import type { NodeData, LinkData, GraphInput, GraphExtra } from './types';
|
|
4
|
+
export default class GraphData {
|
|
5
|
+
private extra;
|
|
6
|
+
data: {
|
|
7
|
+
nodes: NodeData[];
|
|
8
|
+
links: LinkData[];
|
|
9
|
+
};
|
|
10
|
+
private autoParse;
|
|
11
|
+
constructor(data: GraphInput, extra?: GraphExtra);
|
|
12
|
+
getNodeFrame(): DataFrame;
|
|
13
|
+
getLinkFrame(): DataFrame;
|
|
14
|
+
/**
|
|
15
|
+
* Get statistics.
|
|
16
|
+
*/
|
|
17
|
+
info(): GraphProps;
|
|
18
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var analysis_1 = require("../../analysis");
|
|
5
|
+
var graph_1 = require("../../analysis/graph");
|
|
6
|
+
var field_1 = require("../../analysis/field");
|
|
7
|
+
var utils_1 = require("../../utils");
|
|
8
|
+
var dataFrame_1 = tslib_1.__importDefault(require("../field/dataFrame"));
|
|
9
|
+
var utils_2 = require("./utils");
|
|
10
|
+
/* eslint-disable no-param-reassign */
|
|
11
|
+
function parseTreeNode(data, extra) {
|
|
12
|
+
var nodes = [];
|
|
13
|
+
var links = [];
|
|
14
|
+
var childrenKey = (extra === null || extra === void 0 ? void 0 : extra.childrenKey) || 'children';
|
|
15
|
+
var parseTree = function (treeNode) {
|
|
16
|
+
var children = treeNode[childrenKey] || [];
|
|
17
|
+
delete treeNode[childrenKey];
|
|
18
|
+
nodes === null || nodes === void 0 ? void 0 : nodes.push(treeNode);
|
|
19
|
+
for (var i = 0; i < children.length; i += 1) {
|
|
20
|
+
var item = children[i];
|
|
21
|
+
links === null || links === void 0 ? void 0 : links.push({
|
|
22
|
+
source: treeNode.id,
|
|
23
|
+
target: item.id,
|
|
24
|
+
});
|
|
25
|
+
parseTree(item);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
parseTree(data);
|
|
29
|
+
return { nodes: nodes, links: links };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param data link array
|
|
33
|
+
*/
|
|
34
|
+
function parseArray(data, extra) {
|
|
35
|
+
var _a = tslib_1.__read(data, 1), data0 = _a[0];
|
|
36
|
+
(0, utils_1.assert)((0, utils_1.isObject)(data0), 'Data is unable transform to graph');
|
|
37
|
+
var sourceKey = (extra === null || extra === void 0 ? void 0 : extra.sourceKey) || ('source' in data0 && 'source') || ('from' in data0 && 'from');
|
|
38
|
+
var targetKey = (extra === null || extra === void 0 ? void 0 : extra.targetKey) || ('target' in data0 && 'target') || ('to' in data0 && 'to');
|
|
39
|
+
var childrenKey = (extra === null || extra === void 0 ? void 0 : extra.childrenKey) || ('children' in data0 && 'children') || ('to' in data0 && 'to');
|
|
40
|
+
(0, utils_1.assert)(sourceKey || targetKey || childrenKey, 'Data is unable transform to graph');
|
|
41
|
+
var nodes = [];
|
|
42
|
+
var links = [];
|
|
43
|
+
var _b = data0, _c = sourceKey, source = _b[_c], _d = targetKey, target = _b[_d], _e = childrenKey, children = _b[_e];
|
|
44
|
+
if ((0, utils_1.isBasicType)(source) && (0, utils_1.isBasicType)(target)) {
|
|
45
|
+
var _loop_1 = function (i) {
|
|
46
|
+
var link = data[i];
|
|
47
|
+
var _g = link, _h = sourceKey, source_1 = _g[_h], _j = targetKey, target_1 = _g[_j];
|
|
48
|
+
if (nodes.findIndex(function (n) { return n.id === source_1; }) === -1) {
|
|
49
|
+
nodes.push({ id: source_1 });
|
|
50
|
+
}
|
|
51
|
+
if (nodes.findIndex(function (n) { return n.id === target_1; }) === -1) {
|
|
52
|
+
nodes.push({ id: target_1 });
|
|
53
|
+
}
|
|
54
|
+
var formatLink = tslib_1.__assign(tslib_1.__assign({}, link), { source: source_1, target: target_1 });
|
|
55
|
+
links.push(formatLink);
|
|
56
|
+
};
|
|
57
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
58
|
+
_loop_1(i);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if ((0, utils_1.isArray)(children)) {
|
|
62
|
+
// try to parse the array as multiple trees
|
|
63
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
64
|
+
var tree = data[i];
|
|
65
|
+
var _f = parseTreeNode(tree, extra), subNodes = _f.nodes, subLinks = _f.links;
|
|
66
|
+
var _loop_2 = function (i_1) {
|
|
67
|
+
var node = subNodes[i_1];
|
|
68
|
+
var repeatNode = nodes.find(function (n) { return n.id === node.id; });
|
|
69
|
+
if (repeatNode) {
|
|
70
|
+
repeatNode = tslib_1.__assign(tslib_1.__assign({}, node), repeatNode);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
nodes.push(node);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
for (var i_1 = 0; i_1 < subNodes.length; i_1 += 1) {
|
|
77
|
+
_loop_2(i_1);
|
|
78
|
+
}
|
|
79
|
+
links.push.apply(links, tslib_1.__spreadArray([], tslib_1.__read(subLinks), false));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { nodes: nodes, links: links };
|
|
83
|
+
}
|
|
84
|
+
function isNodeArray(arr) {
|
|
85
|
+
if (!(0, utils_1.isArray)(arr) || arr.length <= 1)
|
|
86
|
+
return false;
|
|
87
|
+
var nodeIdInfo = (0, analysis_1.analyzeField)(arr.map(function (node) { return node.id; }));
|
|
88
|
+
return (0, field_1.isUnique)(nodeIdInfo);
|
|
89
|
+
}
|
|
90
|
+
function isValidNodeLinks(nodes, links) {
|
|
91
|
+
if (!(0, utils_1.isArray)(links) || !isNodeArray(nodes) || links.length <= 1)
|
|
92
|
+
return false;
|
|
93
|
+
var _loop_3 = function (i) {
|
|
94
|
+
var link = links[i];
|
|
95
|
+
var source = link.source, target = link.target;
|
|
96
|
+
var hasSourceNode = nodes.findIndex(function (item) { return item.id === source; });
|
|
97
|
+
var hasTargetNode = nodes.findIndex(function (item) { return item.id === target; });
|
|
98
|
+
if (!(hasSourceNode > -1 && hasTargetNode > -1)) {
|
|
99
|
+
return { value: false };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
for (var i = 0; i < links.length; i += 1) {
|
|
103
|
+
var state_1 = _loop_3(i);
|
|
104
|
+
if (typeof state_1 === "object")
|
|
105
|
+
return state_1.value;
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
// TODO: The automatic parsing function has not been completed yet, for now, the GraphData constructor only accepts input data in several specified formats (see type GraphInput)
|
|
110
|
+
var GraphData = /** @class */ (function () {
|
|
111
|
+
function GraphData(data, extra) {
|
|
112
|
+
this.data = {
|
|
113
|
+
nodes: [],
|
|
114
|
+
links: [],
|
|
115
|
+
};
|
|
116
|
+
this.extra = extra;
|
|
117
|
+
var _a = this.autoParse(data, extra), nodes = _a.nodes, links = _a.links;
|
|
118
|
+
(0, utils_1.assert)(isValidNodeLinks(nodes, links), 'Data is unable transform to graph');
|
|
119
|
+
this.data = {
|
|
120
|
+
nodes: nodes.map(function (node) { return (0, utils_2.flatObject)(node); }),
|
|
121
|
+
links: links.map(function (link) { return (0, utils_2.flatObject)(link); }),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
GraphData.prototype.autoParse = function (data, extra) {
|
|
125
|
+
var nodes;
|
|
126
|
+
var links;
|
|
127
|
+
(0, utils_1.assert)((0, utils_1.isArray)(data) || (0, utils_1.isObject)(data), 'Data is unable transform to graph');
|
|
128
|
+
// try parse data as link array or multiple trees
|
|
129
|
+
if ((0, utils_1.isArray)(data)) {
|
|
130
|
+
var parsedData = parseArray(data, extra);
|
|
131
|
+
nodes = parsedData.nodes;
|
|
132
|
+
links = parsedData.links;
|
|
133
|
+
}
|
|
134
|
+
// if passed data tyoe is object
|
|
135
|
+
if ((0, utils_1.isObject)(data)) {
|
|
136
|
+
if ((extra === null || extra === void 0 ? void 0 : extra.nodeKey) && (extra === null || extra === void 0 ? void 0 : extra.linkKey)) {
|
|
137
|
+
nodes = data[extra.nodeKey];
|
|
138
|
+
links = data[extra.linkKey];
|
|
139
|
+
}
|
|
140
|
+
else if ((extra === null || extra === void 0 ? void 0 : extra.childrenKey) || 'children' in data) {
|
|
141
|
+
var parsedTree = parseTreeNode(data, extra);
|
|
142
|
+
nodes = parsedTree.nodes;
|
|
143
|
+
links = parsedTree.links;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
var nodeKey = 'nodes' in data && 'nodes';
|
|
147
|
+
var linkKey = ('links' in data && 'links') || ('edges' in data && 'edges');
|
|
148
|
+
nodes = data[nodeKey];
|
|
149
|
+
links = data[linkKey];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return { nodes: nodes, links: links };
|
|
153
|
+
};
|
|
154
|
+
GraphData.prototype.getNodeFrame = function () {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
var extra = {
|
|
157
|
+
indexes: (_a = this.extra) === null || _a === void 0 ? void 0 : _a.nodeIndexes,
|
|
158
|
+
columns: (_b = this.extra) === null || _b === void 0 ? void 0 : _b.nodeColumns,
|
|
159
|
+
};
|
|
160
|
+
return new dataFrame_1.default(this.data.nodes, extra);
|
|
161
|
+
};
|
|
162
|
+
GraphData.prototype.getLinkFrame = function () {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
var extra = {
|
|
165
|
+
indexes: (_a = this.extra) === null || _a === void 0 ? void 0 : _a.linkIndexes,
|
|
166
|
+
columns: (_b = this.extra) === null || _b === void 0 ? void 0 : _b.linkColumns,
|
|
167
|
+
};
|
|
168
|
+
return new dataFrame_1.default(this.data.links, extra);
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Get statistics.
|
|
172
|
+
*/
|
|
173
|
+
GraphData.prototype.info = function () {
|
|
174
|
+
var _a = this.data, nodes = _a.nodes, links = _a.links;
|
|
175
|
+
// calc fields statistics and structural statistics
|
|
176
|
+
var graphStructFeats = (0, graph_1.getAllStructFeats)(nodes, links);
|
|
177
|
+
var _b = (0, graph_1.getNodeFields)(nodes), nodeFields = _b.nodeFields, nodeFieldNames = _b.nodeFieldNames;
|
|
178
|
+
var _c = (0, graph_1.getLinkFields)(links), linkFields = _c.linkFields, linkFieldNames = _c.linkFieldNames;
|
|
179
|
+
var nodeFieldsInfo = (0, graph_1.getAllFieldsInfo)(nodeFields, nodeFieldNames);
|
|
180
|
+
var linkFieldsInfo = (0, graph_1.getAllFieldsInfo)(linkFields, linkFieldNames);
|
|
181
|
+
var getClusterField = (0, graph_1.clusterNodes)(nodes, nodeFieldsInfo, links);
|
|
182
|
+
nodeFieldsInfo.push(getClusterField);
|
|
183
|
+
var graphProps = tslib_1.__assign({ nodeFieldsInfo: nodeFieldsInfo, linkFieldsInfo: linkFieldsInfo }, graphStructFeats);
|
|
184
|
+
return graphProps;
|
|
185
|
+
};
|
|
186
|
+
return GraphData;
|
|
187
|
+
}());
|
|
188
|
+
exports.default = GraphData;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Axis } from '../field/types';
|
|
2
|
+
/**
|
|
3
|
+
* Graph extra info.
|
|
4
|
+
*/
|
|
5
|
+
export type GraphExtra = {
|
|
6
|
+
nodeKey?: string;
|
|
7
|
+
linkKey?: string;
|
|
8
|
+
sourceKey?: string;
|
|
9
|
+
targetKey?: string;
|
|
10
|
+
childrenKey?: string;
|
|
11
|
+
nodeIndexes?: Axis[];
|
|
12
|
+
nodeColumns?: Axis[];
|
|
13
|
+
linkIndexes?: Axis[];
|
|
14
|
+
linkColumns?: Axis[];
|
|
15
|
+
};
|
|
16
|
+
export type NodeData = {
|
|
17
|
+
id: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type LinkData = {
|
|
22
|
+
source: string;
|
|
23
|
+
target: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
export type GraphInput = TreeNode | {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}[] | {
|
|
29
|
+
[key: string]: unknown[];
|
|
30
|
+
};
|
|
31
|
+
export type TreeNode = {
|
|
32
|
+
id: string;
|
|
33
|
+
children: TreeNode[];
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flatObject(obj: any, concatenator?: string): any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flatObject = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
function flatObject(obj, concatenator) {
|
|
6
|
+
if (concatenator === void 0) { concatenator = '.'; }
|
|
7
|
+
return Object.keys(obj).reduce(function (acc, key) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (typeof obj[key] !== 'object' || obj[key] === null) {
|
|
10
|
+
return tslib_1.__assign(tslib_1.__assign({}, acc), (_a = {}, _a[key] = obj[key], _a));
|
|
11
|
+
}
|
|
12
|
+
var flattenedChild = flatObject(obj[key], concatenator);
|
|
13
|
+
return tslib_1.__assign(tslib_1.__assign({}, acc), Object.keys(flattenedChild).reduce(function (childAcc, childKey) {
|
|
14
|
+
var _a;
|
|
15
|
+
return (tslib_1.__assign(tslib_1.__assign({}, childAcc), (_a = {}, _a["".concat(key).concat(concatenator).concat(childKey)] = flattenedChild[childKey], _a)));
|
|
16
|
+
}, {}));
|
|
17
|
+
}, {});
|
|
18
|
+
}
|
|
19
|
+
exports.flatObject = flatObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './field/types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./analysis"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./dataset"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./statistics"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface IQRParams {
|
|
2
|
+
k: number;
|
|
3
|
+
}
|
|
4
|
+
interface IQRResult {
|
|
5
|
+
upper: {
|
|
6
|
+
threshold: number;
|
|
7
|
+
indexes: number[];
|
|
8
|
+
};
|
|
9
|
+
lower: {
|
|
10
|
+
threshold: number;
|
|
11
|
+
indexes: number[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param data
|
|
17
|
+
* @param params
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function IQR(data: number[], params?: IQRParams): IQRResult;
|
|
21
|
+
export {};
|