@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,157 @@
|
|
|
1
|
+
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import { toString } from 'lodash';
|
|
4
|
+
import { isNumberLike } from '../../utils';
|
|
5
|
+
import { isEntityType } from '../utils';
|
|
6
|
+
import { templateStr2Structure, getScopeVariableArray, getFormattedNumberValue, getAssessment, getDisplayValue, getByPath, } from './utils';
|
|
7
|
+
var TextSpecGenerator = /** @class */ (function () {
|
|
8
|
+
function TextSpecGenerator(_a) {
|
|
9
|
+
var variable = _a.variable, structures = _a.structures, structureTemps = _a.structureTemps;
|
|
10
|
+
this.variable = variable;
|
|
11
|
+
this.structures = structures;
|
|
12
|
+
this.structureTemps = structureTemps;
|
|
13
|
+
}
|
|
14
|
+
TextSpecGenerator.prototype.generateTextPhrase = function (text) {
|
|
15
|
+
// TODO 是否需要判断 value 为 string ??是否需要默认的数值格式化?—— 暂时先简单 toString 下
|
|
16
|
+
return { type: 'text', value: toString(text) };
|
|
17
|
+
};
|
|
18
|
+
TextSpecGenerator.prototype.generateVarPhrase = function (scopeVariable, path, value, metadata) {
|
|
19
|
+
// 没有 meta 的一律按普通文本处理
|
|
20
|
+
if (!metadata) {
|
|
21
|
+
return this.generateTextPhrase(value);
|
|
22
|
+
}
|
|
23
|
+
var varType = metadata.varType, formatter = metadata.formatter, extraCustomMeta = metadata.extraCustomMeta;
|
|
24
|
+
var formattedValue = getFormattedNumberValue(varType, value, formatter);
|
|
25
|
+
// 声明 varType 的可能是 entity 也可能是 custom
|
|
26
|
+
if (varType) {
|
|
27
|
+
if (isEntityType(varType)) {
|
|
28
|
+
return {
|
|
29
|
+
type: 'entity',
|
|
30
|
+
value: formattedValue,
|
|
31
|
+
metadata: {
|
|
32
|
+
entityType: varType,
|
|
33
|
+
origin: isNumberLike(value) ? value : undefined,
|
|
34
|
+
assessment: getAssessment(varType, value),
|
|
35
|
+
generateVariableInfo: { scopeVariable: scopeVariable, path: path },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
var extra = extraCustomMeta === null || extraCustomMeta === void 0 ? void 0 : extraCustomMeta(this.variable, scopeVariable);
|
|
40
|
+
return {
|
|
41
|
+
type: 'custom',
|
|
42
|
+
value: formattedValue,
|
|
43
|
+
// TODO 完善自定义短语 metadata
|
|
44
|
+
metadata: __assign({ customType: varType, generateVariableInfo: { scopeVariable: scopeVariable, path: path } }, extra),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return this.generateTextPhrase(toString(value));
|
|
48
|
+
};
|
|
49
|
+
// 只处理行数据拼接逻辑,表格数据
|
|
50
|
+
TextSpecGenerator.prototype.generateSentence = function (template, variable, variableMetaMap) {
|
|
51
|
+
var _this = this;
|
|
52
|
+
var phrases = [];
|
|
53
|
+
var templateStructure = templateStr2Structure(template);
|
|
54
|
+
var _loop_1 = function (i) {
|
|
55
|
+
var _a = templateStructure[i], tempStrType = _a.type, tempStrValue = _a.value;
|
|
56
|
+
if (tempStrType === 'template') {
|
|
57
|
+
var targetTempId_1 = tempStrValue;
|
|
58
|
+
// get template info by template id
|
|
59
|
+
var templateInfo = this_1.structureTemps.find(function (_a) {
|
|
60
|
+
var templateId = _a.templateId;
|
|
61
|
+
return templateId === targetTempId_1;
|
|
62
|
+
});
|
|
63
|
+
if (templateInfo) {
|
|
64
|
+
var template_1 = templateInfo.template, useVariable = templateInfo.useVariable, variableMetaMap_1 = templateInfo.variableMetaMap, limit = templateInfo.limit, _b = templateInfo.separator, separator_1 = _b === void 0 ? ',' : _b;
|
|
65
|
+
var scopeArrayVariable_1 = getScopeVariableArray(this_1.variable, variable, useVariable, limit);
|
|
66
|
+
var subPhrases = scopeArrayVariable_1
|
|
67
|
+
.map(function (v) { return _this.generateSentence(template_1, v, variableMetaMap_1); })
|
|
68
|
+
.reduce(function (prev, curr, index) {
|
|
69
|
+
var result = __spreadArray(__spreadArray([], __read(prev), false), __read(curr), false);
|
|
70
|
+
if (index !== scopeArrayVariable_1.length - 1)
|
|
71
|
+
result.push(_this.generateTextPhrase(separator_1));
|
|
72
|
+
return result;
|
|
73
|
+
}, []);
|
|
74
|
+
phrases = phrases.concat.apply(phrases, __spreadArray([], __read(subPhrases), false));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.warn("".concat(targetTempId_1, " is not exist"));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (tempStrType === 'variable') {
|
|
81
|
+
var key = tempStrValue;
|
|
82
|
+
var metadata = variableMetaMap === null || variableMetaMap === void 0 ? void 0 : variableMetaMap[key];
|
|
83
|
+
var value = (metadata === null || metadata === void 0 ? void 0 : metadata.getDisplayValue)
|
|
84
|
+
? getDisplayValue(metadata === null || metadata === void 0 ? void 0 : metadata.getDisplayValue, this_1.variable, variable)
|
|
85
|
+
: getByPath(this_1.variable, variable, key);
|
|
86
|
+
phrases.push(this_1.generateVarPhrase(variable, key, value, __assign({}, metadata)));
|
|
87
|
+
}
|
|
88
|
+
else if (tempStrType === 'text') {
|
|
89
|
+
phrases.push(this_1.generateTextPhrase(tempStrValue));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var this_1 = this;
|
|
93
|
+
for (var i = 0; i < templateStructure.length; i += 1) {
|
|
94
|
+
_loop_1(i);
|
|
95
|
+
}
|
|
96
|
+
return phrases;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* 生成段落
|
|
100
|
+
* 1. 当前支持段落类型 heading normal bullet
|
|
101
|
+
* 2. 生成段落个数取决于 variable 的类型:
|
|
102
|
+
* 2.1 非自带循环属性的段落(heading normal)遇到数组数据时自动循环多段;
|
|
103
|
+
* 2.2 自身循环段落(bullet)遇到非数组时只生成一个
|
|
104
|
+
* */
|
|
105
|
+
TextSpecGenerator.prototype.generateParagraphs = function (structure, variable) {
|
|
106
|
+
var _this = this;
|
|
107
|
+
if (variable === void 0) { variable = this.variable; }
|
|
108
|
+
var variableMetaMap = structure.variableMetaMap, template = structure.template, _a = structure.displayType, displayType = _a === void 0 ? 'paragraph' : _a, _b = structure.useVariable, useVariable = _b === void 0 ? '' : _b, limit = structure.limit,
|
|
109
|
+
// 段落级别暂时用不到 separator
|
|
110
|
+
// separator,
|
|
111
|
+
bulletOrder = structure.bulletOrder, children = structure.children, className = structure.className;
|
|
112
|
+
var scopeArrayVariable = getScopeVariableArray(this.variable, variable, useVariable, limit);
|
|
113
|
+
// TODO 接入更多类型
|
|
114
|
+
if (displayType === 'paragraph') {
|
|
115
|
+
return scopeArrayVariable.map(function (v) { return ({
|
|
116
|
+
type: 'normal',
|
|
117
|
+
phrases: _this.generateSentence(template, v, variableMetaMap),
|
|
118
|
+
className: className,
|
|
119
|
+
}); });
|
|
120
|
+
}
|
|
121
|
+
if (displayType === 'bullet') {
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
type: 'bullets',
|
|
125
|
+
className: className,
|
|
126
|
+
isOrder: bulletOrder,
|
|
127
|
+
bullets: scopeArrayVariable.map(function (v) { return ({
|
|
128
|
+
type: 'bullet-item',
|
|
129
|
+
phrases: _this.generateSentence(template, v, variableMetaMap),
|
|
130
|
+
subBullet: children
|
|
131
|
+
? _this.generateParagraphs(__assign(__assign({}, children), { displayType: 'bullet' }), v)[0]
|
|
132
|
+
: undefined,
|
|
133
|
+
}); }),
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
};
|
|
139
|
+
TextSpecGenerator.prototype.generateSection = function () {
|
|
140
|
+
var _this = this;
|
|
141
|
+
return {
|
|
142
|
+
paragraphs: this.structures.reduce(function (prev, curr) {
|
|
143
|
+
return __spreadArray(__spreadArray([], __read(prev), false), __read(_this.generateParagraphs(curr)), false);
|
|
144
|
+
}, []),
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
TextSpecGenerator.prototype.generateNarrative = function () {
|
|
148
|
+
return {
|
|
149
|
+
// 当前只可能构建出一个 section
|
|
150
|
+
sections: [this.generateSection()],
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
return TextSpecGenerator;
|
|
154
|
+
}());
|
|
155
|
+
export default function generateTextSpec(params) {
|
|
156
|
+
return new TextSpecGenerator(params).generateNarrative();
|
|
157
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { get, isArray, isUndefined, slice, replace, isString, startsWith } from 'lodash';
|
|
2
|
+
import { dataFormat, isNumberLike } from '../../utils';
|
|
3
|
+
/**
|
|
4
|
+
* simple path system
|
|
5
|
+
* if starts with '.', it's relative path
|
|
6
|
+
* // TODO 支持相对路径找到上级
|
|
7
|
+
* if starts with '..', it's can get prev level variable
|
|
8
|
+
* otherwise, it's absolute path
|
|
9
|
+
*/
|
|
10
|
+
export function getByPath(globalVar, scopeVar, path) {
|
|
11
|
+
if (!path)
|
|
12
|
+
return scopeVar;
|
|
13
|
+
if (startsWith(path, '.'))
|
|
14
|
+
return get(scopeVar, path.slice(1));
|
|
15
|
+
return get(globalVar, path);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* parse template string
|
|
19
|
+
* Use $ for variable
|
|
20
|
+
* Use & for template
|
|
21
|
+
* @example 'aaa ${key} &{temp1}'
|
|
22
|
+
* => [{ type: 'text', value: 'aaa ' }, { type: 'variable', value: 'key' }, { type: 'template', value: 'temp1' }]
|
|
23
|
+
*/
|
|
24
|
+
export function templateStr2Structure(templateStr) {
|
|
25
|
+
// eslint-disable-next-line no-useless-escape
|
|
26
|
+
var splitReg = /([\$|&]{.*?})/;
|
|
27
|
+
var varReg = /\${(.*?)}/;
|
|
28
|
+
var tempReg = /&{(.*?)}/;
|
|
29
|
+
return templateStr
|
|
30
|
+
.split(splitReg)
|
|
31
|
+
.filter(function (str) { return str; })
|
|
32
|
+
.map(function (str) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
var templateId = (_a = tempReg.exec(str)) === null || _a === void 0 ? void 0 : _a[1];
|
|
35
|
+
if (templateId)
|
|
36
|
+
return { value: templateId, type: 'template' };
|
|
37
|
+
var varName = (_b = varReg.exec(str)) === null || _b === void 0 ? void 0 : _b[1];
|
|
38
|
+
if (varName)
|
|
39
|
+
return { value: varName, type: 'variable' };
|
|
40
|
+
return { value: str, type: 'text' };
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** format any to array, and filter nil */
|
|
44
|
+
export function formattedAsArray(variable) {
|
|
45
|
+
if (isUndefined(variable))
|
|
46
|
+
return [];
|
|
47
|
+
return isArray(variable) ? variable : [variable];
|
|
48
|
+
}
|
|
49
|
+
export function getScopeVariableArray(globalVar, scopeVar, path, limit) {
|
|
50
|
+
return slice(formattedAsArray(getByPath(globalVar, scopeVar, path)), 0, limit);
|
|
51
|
+
}
|
|
52
|
+
export function getAssessment(entityType, value) {
|
|
53
|
+
if (!isNumberLike(value))
|
|
54
|
+
return undefined;
|
|
55
|
+
if (entityType === 'delta_value' || entityType === 'ratio_value') {
|
|
56
|
+
if (value > 0)
|
|
57
|
+
return 'positive';
|
|
58
|
+
if (value < 0)
|
|
59
|
+
return 'negative';
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
export function getFormattedNumberValue(varType, value, formatter) {
|
|
64
|
+
if (!isNumberLike(value))
|
|
65
|
+
return value;
|
|
66
|
+
if (varType === 'delta_value' || varType === 'ratio_value') {
|
|
67
|
+
return formatter ? formatter(Math.abs(value)) : dataFormat(Math.abs(value));
|
|
68
|
+
}
|
|
69
|
+
if (varType === 'proportion') {
|
|
70
|
+
return formatter ? formatter(Math.abs(value)) : "".concat(dataFormat(value * 100), "%");
|
|
71
|
+
}
|
|
72
|
+
return formatter ? formatter(value) : dataFormat(value);
|
|
73
|
+
}
|
|
74
|
+
/** get phrase text */
|
|
75
|
+
export function getDisplayValue(getDisplayValuePattern, globalVar, scopeVar) {
|
|
76
|
+
if (isString(getDisplayValuePattern)) {
|
|
77
|
+
// 用字符串表示使用变量拼接短语文字内容,这里进行变量替换,eg '${city} = ${value}' => '北京 = 1000'
|
|
78
|
+
// Use a string to represent the text content of the phrase using variables to splice,eg '${city} = ${value}' => 'Beijing = 1000'
|
|
79
|
+
return replace(getDisplayValuePattern, /\${(.*?)}/g, function (match) {
|
|
80
|
+
var _a;
|
|
81
|
+
var varName = (_a = /\${(.*?)}/.exec(match)) === null || _a === void 0 ? void 0 : _a[1];
|
|
82
|
+
return varName ? getByPath(globalVar, scopeVar, varName) : '';
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return getDisplayValuePattern(globalVar, scopeVar);
|
|
86
|
+
}
|
package/esm/ntv/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export var ENTITY_TYPES = [
|
|
2
|
+
/**
|
|
3
|
+
* @description main indicator value 主指标名
|
|
4
|
+
* @example DAU
|
|
5
|
+
* */
|
|
6
|
+
'metric_name',
|
|
7
|
+
/**
|
|
8
|
+
* @description main indicator name 主指标值
|
|
9
|
+
* @example 1.23 million
|
|
10
|
+
* */
|
|
11
|
+
'metric_value',
|
|
12
|
+
/**
|
|
13
|
+
* @description other indicator value 其他指标值
|
|
14
|
+
* @example
|
|
15
|
+
* */
|
|
16
|
+
'other_metric_value',
|
|
17
|
+
/**
|
|
18
|
+
* @description contribution ratio 贡献度
|
|
19
|
+
* @example 23%
|
|
20
|
+
* */
|
|
21
|
+
'contribute_ratio',
|
|
22
|
+
/**
|
|
23
|
+
* @description delate value 变化值
|
|
24
|
+
* @example -1.2
|
|
25
|
+
* */
|
|
26
|
+
'delta_value',
|
|
27
|
+
/**
|
|
28
|
+
* @description ratio value 变化率
|
|
29
|
+
* @example +23%
|
|
30
|
+
* */
|
|
31
|
+
'ratio_value',
|
|
32
|
+
/**
|
|
33
|
+
* @description trend description 趋势描述
|
|
34
|
+
* @example up/down
|
|
35
|
+
* */
|
|
36
|
+
'trend_desc',
|
|
37
|
+
/**
|
|
38
|
+
* @description dimension value 维值
|
|
39
|
+
* @example sex = man
|
|
40
|
+
* */
|
|
41
|
+
'dim_value',
|
|
42
|
+
/**
|
|
43
|
+
* @description time description 时间描述
|
|
44
|
+
* @example 2021-11-19
|
|
45
|
+
* */
|
|
46
|
+
'time_desc',
|
|
47
|
+
/**
|
|
48
|
+
* @description proportion 占比
|
|
49
|
+
* @example 20%
|
|
50
|
+
* */
|
|
51
|
+
'proportion',
|
|
52
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/ntv/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isSpecType';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isObject, isString } from '../../utils';
|
|
2
|
+
import { ENTITY_TYPES } from '../schema';
|
|
3
|
+
export function isCustomSection(spec) {
|
|
4
|
+
return isObject(spec) && 'customType' in spec;
|
|
5
|
+
}
|
|
6
|
+
export function isCustomParagraph(spec) {
|
|
7
|
+
return isObject(spec) && 'customType' in spec;
|
|
8
|
+
}
|
|
9
|
+
export function isStandardSection(spec) {
|
|
10
|
+
return isObject(spec) && 'paragraphs' in spec && Array.isArray(spec === null || spec === void 0 ? void 0 : spec.paragraphs);
|
|
11
|
+
}
|
|
12
|
+
export function isTextParagraph(spec) {
|
|
13
|
+
return isObject(spec) && (spec === null || spec === void 0 ? void 0 : spec.type) === 'normal' && Array.isArray(spec === null || spec === void 0 ? void 0 : spec.phrases);
|
|
14
|
+
}
|
|
15
|
+
export function isBulletParagraph(spec) {
|
|
16
|
+
return isObject(spec) && (spec === null || spec === void 0 ? void 0 : spec.type) === 'bullets' && Array.isArray(spec === null || spec === void 0 ? void 0 : spec.bullets);
|
|
17
|
+
}
|
|
18
|
+
export function isDividerParagraph(spec) {
|
|
19
|
+
return isObject(spec) && (spec === null || spec === void 0 ? void 0 : spec.type) === 'divider';
|
|
20
|
+
}
|
|
21
|
+
export function getHeadingWeight(pType) {
|
|
22
|
+
if (pType === null || pType === void 0 ? void 0 : pType.startsWith('heading')) {
|
|
23
|
+
var weight = Number(pType === null || pType === void 0 ? void 0 : pType.slice(-1));
|
|
24
|
+
if (weight >= 1 && weight <= 6)
|
|
25
|
+
return weight;
|
|
26
|
+
}
|
|
27
|
+
return NaN;
|
|
28
|
+
}
|
|
29
|
+
export function isHeadingParagraph(spec) {
|
|
30
|
+
if (isObject(spec) && 'type' in spec && isString(spec.type)) {
|
|
31
|
+
var weight = getHeadingWeight(spec === null || spec === void 0 ? void 0 : spec.type);
|
|
32
|
+
return spec.type.startsWith('heading') && !Number.isNaN(weight);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
export function isCustomPhrase(spec) {
|
|
37
|
+
var _a;
|
|
38
|
+
return (spec === null || spec === void 0 ? void 0 : spec.type) === 'custom' && !!((_a = spec === null || spec === void 0 ? void 0 : spec.metadata) === null || _a === void 0 ? void 0 : _a.customType);
|
|
39
|
+
}
|
|
40
|
+
export function isEntityType(type) {
|
|
41
|
+
return ENTITY_TYPES.includes(type);
|
|
42
|
+
}
|
|
43
|
+
export function isEntityPhrase(spec) {
|
|
44
|
+
var _a;
|
|
45
|
+
return (spec === null || spec === void 0 ? void 0 : spec.type) === 'entity' && ENTITY_TYPES.includes((_a = spec === null || spec === void 0 ? void 0 : spec.metadata) === null || _a === void 0 ? void 0 : _a.entityType);
|
|
46
|
+
}
|
|
47
|
+
export function isTextPhrase(spec) {
|
|
48
|
+
return (spec === null || spec === void 0 ? void 0 : spec.type) === 'text';
|
|
49
|
+
}
|
|
50
|
+
export function isEscapePhrase(spec) {
|
|
51
|
+
return (spec === null || spec === void 0 ? void 0 : spec.type) === 'escape';
|
|
52
|
+
}
|
|
53
|
+
export function isFormulaPhrase(spec) {
|
|
54
|
+
return (spec === null || spec === void 0 ? void 0 : spec.type) === 'formula';
|
|
55
|
+
}
|
|
56
|
+
export function isImagePhrase(spec) {
|
|
57
|
+
return (spec === null || spec === void 0 ? void 0 : spec.type) === 'image';
|
|
58
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data format.
|
|
3
|
+
* dataFormat(0.8849) = 0.88
|
|
4
|
+
* dataFormat(12, 1) = 12
|
|
5
|
+
* dataFormat(1234, 1) = 1.2k
|
|
6
|
+
* dataFormat(123.456, 2) = 123.46
|
|
7
|
+
* @param value value to be formatted
|
|
8
|
+
* @param digits the number of digits to keep after the decimal point, 2 by default
|
|
9
|
+
* @returns formatted value string
|
|
10
|
+
*/
|
|
11
|
+
export default function dataFormat(value, digits) {
|
|
12
|
+
if (digits === void 0) { digits = 2; }
|
|
13
|
+
if (typeof value === 'string')
|
|
14
|
+
return value;
|
|
15
|
+
var formatMap = [
|
|
16
|
+
{ value: 1, symbol: '' },
|
|
17
|
+
{ value: 1e3, symbol: 'k' },
|
|
18
|
+
{ value: 1e6, symbol: 'M' },
|
|
19
|
+
{ value: 1e9, symbol: 'G' },
|
|
20
|
+
{ value: 1e12, symbol: 'T' },
|
|
21
|
+
{ value: 1e15, symbol: 'P' },
|
|
22
|
+
{ value: 1e18, symbol: 'E' },
|
|
23
|
+
];
|
|
24
|
+
var rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
|
25
|
+
var item = formatMap
|
|
26
|
+
.slice()
|
|
27
|
+
.reverse()
|
|
28
|
+
.find(function (item) {
|
|
29
|
+
return value >= item.value;
|
|
30
|
+
});
|
|
31
|
+
return item ? (value / item.value).toFixed(digits).replace(rx, '$1') + item.symbol : value.toFixed(digits);
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toNumber, isNaN } from 'lodash';
|
|
2
|
+
export function isString(val) {
|
|
3
|
+
return typeof val === 'string';
|
|
4
|
+
}
|
|
5
|
+
export function isObject(val) {
|
|
6
|
+
return val !== null && typeof val === 'object';
|
|
7
|
+
}
|
|
8
|
+
export function isUndefined(val) {
|
|
9
|
+
return val === undefined;
|
|
10
|
+
}
|
|
11
|
+
export function isNumberLike(val) {
|
|
12
|
+
var numVal = toNumber(val);
|
|
13
|
+
return !isNaN(numVal);
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChartKnowledgeBase } from '../../ckb';
|
|
2
|
+
import type { Data } from '../../common/types';
|
|
3
|
+
import type { AdviseResult, ChartAdviseParams } from '../types';
|
|
4
|
+
import type { BasicDataPropertyForAdvice, RuleModule } from '../ruler';
|
|
5
|
+
/**
|
|
6
|
+
* A utility function that assemble dataProps with user input and DataFrame
|
|
7
|
+
* @param copyData a copy of original data
|
|
8
|
+
* @param fields the fields that user specified to be used in dataset
|
|
9
|
+
* @param inputDataProps user input dataProps which will cover or combine with dataProps from DataFrame
|
|
10
|
+
* @returns assembled data props
|
|
11
|
+
*/
|
|
12
|
+
export declare function assembleDataProps(copyData: Data, fields?: string[], inputDataProps?: Partial<BasicDataPropertyForAdvice>[]): BasicDataPropertyForAdvice[];
|
|
13
|
+
export declare function advicesForChart(params: ChartAdviseParams, ckb: ChartKnowledgeBase, ruleBase: Record<string, RuleModule>): AdviseResult;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.advicesForChart = exports.assembleDataProps = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var data_1 = require("../../data");
|
|
6
|
+
var utils_1 = require("../utils");
|
|
7
|
+
var data_to_advices_1 = require("./data-to-advices");
|
|
8
|
+
/**
|
|
9
|
+
* A utility function that assemble dataProps with user input and DataFrame
|
|
10
|
+
* @param copyData a copy of original data
|
|
11
|
+
* @param fields the fields that user specified to be used in dataset
|
|
12
|
+
* @param inputDataProps user input dataProps which will cover or combine with dataProps from DataFrame
|
|
13
|
+
* @returns assembled data props
|
|
14
|
+
*/
|
|
15
|
+
function assembleDataProps(copyData, fields, inputDataProps) {
|
|
16
|
+
// transform data into DataFrame
|
|
17
|
+
var dataFrame;
|
|
18
|
+
if (fields) {
|
|
19
|
+
dataFrame = new data_1.DataFrame(copyData, { columns: fields });
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
dataFrame = new data_1.DataFrame(copyData);
|
|
23
|
+
}
|
|
24
|
+
var dataPropsForAdvice;
|
|
25
|
+
var defaultDataProps = dataFrame.info();
|
|
26
|
+
if (inputDataProps) {
|
|
27
|
+
dataPropsForAdvice = defaultDataProps.map(function (dwItem) {
|
|
28
|
+
var inputProps = inputDataProps.find(function (item) {
|
|
29
|
+
return item.name === dwItem.name;
|
|
30
|
+
});
|
|
31
|
+
return tslib_1.__assign(tslib_1.__assign({}, dwItem), inputProps);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
dataPropsForAdvice = defaultDataProps;
|
|
36
|
+
}
|
|
37
|
+
return dataPropsForAdvice;
|
|
38
|
+
}
|
|
39
|
+
exports.assembleDataProps = assembleDataProps;
|
|
40
|
+
function advicesForChart(params, ckb, ruleBase) {
|
|
41
|
+
var data = params.data, dataProps = params.dataProps, smartColor = params.smartColor, options = params.options, colorOptions = params.colorOptions, fields = params.fields;
|
|
42
|
+
try {
|
|
43
|
+
// otherwise the input data will be mutated
|
|
44
|
+
var copyData = (0, utils_1.cloneDeep)(data);
|
|
45
|
+
// get dataProps from DataFrame
|
|
46
|
+
var dataPropsForAdvice = assembleDataProps(copyData, fields, dataProps);
|
|
47
|
+
// filter out fields that are not included for advising
|
|
48
|
+
var filteredData = [];
|
|
49
|
+
if (fields) {
|
|
50
|
+
filteredData = copyData.map(function (row) {
|
|
51
|
+
var filteredRow = row;
|
|
52
|
+
Object.keys(filteredRow).forEach(function (col) {
|
|
53
|
+
if (!fields.includes(col)) {
|
|
54
|
+
delete filteredRow[col];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return row;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
filteredData = copyData;
|
|
62
|
+
}
|
|
63
|
+
var adviceResult = (0, data_to_advices_1.dataToAdvices)(filteredData, dataPropsForAdvice, ckb, ruleBase, smartColor, options, colorOptions);
|
|
64
|
+
return adviceResult;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
// if the input data cannot be transformed into DataFrame
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.error('error: ', error);
|
|
70
|
+
return { advices: [], log: [] };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.advicesForChart = advicesForChart;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChartKnowledge } from '../../ckb';
|
|
2
|
+
import type { Data } from '../../common/types';
|
|
3
|
+
import type { BasicDataPropertyForAdvice, RuleModule } from '../ruler/types';
|
|
4
|
+
import type { AdvisorOptions, SmartColorOptions, AdviseResult } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* options for advising inner pipeline
|
|
7
|
+
*/
|
|
8
|
+
type PipeAdvisorOptions = AdvisorOptions;
|
|
9
|
+
/**
|
|
10
|
+
* recommending charts given data and dataProps, based on CKB and RuleBase
|
|
11
|
+
*
|
|
12
|
+
* @param data input data [ {a: xxx, b: xxx}, ... ]
|
|
13
|
+
* @param dataProps data props derived from data or customized by users
|
|
14
|
+
* @param chartWIKI ckb
|
|
15
|
+
* @param ruleBase rule base
|
|
16
|
+
* @param smartColor switch smart color on/off, optional props, default is off
|
|
17
|
+
* @param options options for advising such as log, preferences
|
|
18
|
+
* @param colorOptions color options, optional props, @see {@link SmartColorOptions}
|
|
19
|
+
* @returns chart list [ { type: chartTypes, spec: antv-spec, score: >0 }, ... ]
|
|
20
|
+
*/
|
|
21
|
+
export declare function dataToAdvices(data: Data, dataProps: BasicDataPropertyForAdvice[], chartWIKI: Record<string, ChartKnowledge>, ruleBase: Record<string, RuleModule>, smartColor?: boolean, options?: PipeAdvisorOptions, colorOptions?: SmartColorOptions): AdviseResult;
|
|
22
|
+
export {};
|