@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,218 @@
|
|
|
1
|
+
import { IntervalMark, RectMark, LineMark, PointMark, TextMark, CellMark, AreaMark } from '@antv/g2';
|
|
2
|
+
import type { ColorSchemeType } from '@antv/color-schema';
|
|
3
|
+
import type { SimulationType } from '@antv/smart-color';
|
|
4
|
+
/** AVA 包内跨模块引用 */
|
|
5
|
+
import type { Purpose, CkbConfig } from '../ckb';
|
|
6
|
+
import type { Specification, Data } from '../common/types';
|
|
7
|
+
/** Advisor 模块内引用 */
|
|
8
|
+
import type { RuleConfig, BasicDataPropertyForAdvice, Preferences, RuleType } from './ruler/types';
|
|
9
|
+
/**
|
|
10
|
+
* Advisor config type
|
|
11
|
+
*/
|
|
12
|
+
export type AdvisorConfig = {
|
|
13
|
+
ckbCfg?: CkbConfig;
|
|
14
|
+
ruleCfg?: RuleConfig;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Single chart-recommendation from advisor.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export type Advice = {
|
|
22
|
+
/**
|
|
23
|
+
* Chart Type: should be standard CKB ChartID or any string id for customized chart.
|
|
24
|
+
*/
|
|
25
|
+
type: string;
|
|
26
|
+
/**
|
|
27
|
+
* for the recommended chart, the specification information needs to be declared,
|
|
28
|
+
* which may be antv-spec or custom spec (for indicator cards and cross tabs)
|
|
29
|
+
*/
|
|
30
|
+
spec: Specification | null;
|
|
31
|
+
/**
|
|
32
|
+
* A score summarized by rule scoring, which measures how well an individual chart
|
|
33
|
+
* is recommended in a recommendation scenario.
|
|
34
|
+
* The higher the score, the more recommended it is
|
|
35
|
+
*/
|
|
36
|
+
score: number;
|
|
37
|
+
/**
|
|
38
|
+
* lint array: problems that remain after the recommendation, with possible solutions accordingly.
|
|
39
|
+
*/
|
|
40
|
+
lint?: Lint[];
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Describe a chart recommendation problem.
|
|
44
|
+
*/
|
|
45
|
+
export type Lint = {
|
|
46
|
+
/** rule type: 'HARD' | 'SOFT' | 'DESIGN' */
|
|
47
|
+
type: RuleType;
|
|
48
|
+
/** rule id: standard ruleId or any string for custom rule */
|
|
49
|
+
id: string;
|
|
50
|
+
/** rule score */
|
|
51
|
+
score: number;
|
|
52
|
+
/** fix solution */
|
|
53
|
+
fix?: any;
|
|
54
|
+
/** docs: explanation */
|
|
55
|
+
docs?: any;
|
|
56
|
+
};
|
|
57
|
+
export type AdviseParams = ChartAdviseParams;
|
|
58
|
+
export type ChartAdviseParams = {
|
|
59
|
+
/** input data to advise */
|
|
60
|
+
data: Data;
|
|
61
|
+
/** customized data props to advise */
|
|
62
|
+
dataProps?: Partial<BasicDataPropertyForAdvice>[];
|
|
63
|
+
/** data fields to focus, apply in `data` and `dataProps` */
|
|
64
|
+
fields?: string[];
|
|
65
|
+
/** SmartColor mode on/off */
|
|
66
|
+
smartColor?: boolean;
|
|
67
|
+
/** advising options such as purpose, layout preferences */
|
|
68
|
+
options?: AdvisorOptions;
|
|
69
|
+
/** smart color options */
|
|
70
|
+
colorOptions?: SmartColorOptions;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export type AdvisorOptions = {
|
|
76
|
+
/**
|
|
77
|
+
* analysis purpose, correspond to purpose of CKB, including
|
|
78
|
+
* Comparison
|
|
79
|
+
* Trend
|
|
80
|
+
* Distribution
|
|
81
|
+
* Rank
|
|
82
|
+
* Proportion
|
|
83
|
+
* Composition
|
|
84
|
+
*/
|
|
85
|
+
purpose?: Purpose;
|
|
86
|
+
/**
|
|
87
|
+
* preference settings for landscape or portrait
|
|
88
|
+
*/
|
|
89
|
+
preferences?: Preferences;
|
|
90
|
+
/**
|
|
91
|
+
* whether to apply design rules
|
|
92
|
+
*/
|
|
93
|
+
refine?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* specify fields in the dataset
|
|
96
|
+
*/
|
|
97
|
+
fields?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* whether to show scoring process in console
|
|
100
|
+
* @deprecated since 3.0.0, use `exportLog` instead
|
|
101
|
+
*/
|
|
102
|
+
showLog?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* custom theme
|
|
105
|
+
*/
|
|
106
|
+
theme?: Theme;
|
|
107
|
+
/**
|
|
108
|
+
* only consider chart types with spec
|
|
109
|
+
*/
|
|
110
|
+
requireSpec?: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type Theme = {
|
|
113
|
+
/** hex string */
|
|
114
|
+
primaryColor?: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* return type of color options for smart color
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export type SmartColorOptions = {
|
|
121
|
+
/**
|
|
122
|
+
* hex string
|
|
123
|
+
*/
|
|
124
|
+
themeColor?: string;
|
|
125
|
+
/**
|
|
126
|
+
* mode employed for color generation
|
|
127
|
+
*/
|
|
128
|
+
colorSchemeType?: ColorSchemeType;
|
|
129
|
+
/**
|
|
130
|
+
* mode employed for color simulation
|
|
131
|
+
*/
|
|
132
|
+
simulationType?: SimulationType;
|
|
133
|
+
};
|
|
134
|
+
export type AdviseResult = {
|
|
135
|
+
advices: Advice[];
|
|
136
|
+
log: ScoringResultForChartType[];
|
|
137
|
+
};
|
|
138
|
+
export type LintResult = {
|
|
139
|
+
lints: Lint[];
|
|
140
|
+
log: ScoringResultForRule[];
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Log for scoring a single rule.
|
|
144
|
+
*/
|
|
145
|
+
export interface ScoringResultForRule {
|
|
146
|
+
phase: 'ADVISE' | 'LINT';
|
|
147
|
+
/**
|
|
148
|
+
* standard ChartRuleId or any string id for custom rule
|
|
149
|
+
*/
|
|
150
|
+
ruleId: string;
|
|
151
|
+
/**
|
|
152
|
+
* scoring result for this rule, score = base * weight
|
|
153
|
+
*/
|
|
154
|
+
score: number;
|
|
155
|
+
/**
|
|
156
|
+
* scoring from validator
|
|
157
|
+
*/
|
|
158
|
+
base: number;
|
|
159
|
+
/**
|
|
160
|
+
* weight of this rule
|
|
161
|
+
*/
|
|
162
|
+
weight: number;
|
|
163
|
+
/**
|
|
164
|
+
* type of this rule
|
|
165
|
+
*/
|
|
166
|
+
ruleType: RuleType;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Summary log of checking all rules for a single chart type.
|
|
170
|
+
*/
|
|
171
|
+
export interface ScoringResultForChartType {
|
|
172
|
+
/**
|
|
173
|
+
* scoring for this chart type: standard ChartId or any string for custom chart
|
|
174
|
+
*/
|
|
175
|
+
chartType: string;
|
|
176
|
+
/**
|
|
177
|
+
* final score
|
|
178
|
+
*/
|
|
179
|
+
score: number;
|
|
180
|
+
/**
|
|
181
|
+
* whole records of scoring
|
|
182
|
+
*/
|
|
183
|
+
log?: ScoringResultForRule[];
|
|
184
|
+
}
|
|
185
|
+
export * from './ruler/types';
|
|
186
|
+
export interface LinterOptions {
|
|
187
|
+
purpose?: Purpose;
|
|
188
|
+
preferences?: Preferences;
|
|
189
|
+
}
|
|
190
|
+
export interface LintParams {
|
|
191
|
+
spec: Specification;
|
|
192
|
+
dataProps?: BasicDataPropertyForAdvice[];
|
|
193
|
+
options?: LinterOptions;
|
|
194
|
+
}
|
|
195
|
+
/** g2-spec 相关types */
|
|
196
|
+
export type Mark = IntervalMark | RectMark | LineMark | PointMark | TextMark | CellMark | AreaMark;
|
|
197
|
+
export type Primitive = number | string | boolean | Date;
|
|
198
|
+
export type TabularData = Record<string, Primitive>[];
|
|
199
|
+
export type Callback = (datum: Record<string, Primitive>, index: number, data: TabularData) => Primitive;
|
|
200
|
+
export type DataType = 'quantitative' | 'categorical' | 'temporal';
|
|
201
|
+
/** Encode 的值 */
|
|
202
|
+
export type Encode = Primitive | Callback;
|
|
203
|
+
/** Encode 的对象 */
|
|
204
|
+
export type MarkEncode = Record<string, Encode>;
|
|
205
|
+
/** 带有字段类型的 Encode 对象 */
|
|
206
|
+
export type MarkEncodeWithType = Record<string, {
|
|
207
|
+
field: Encode;
|
|
208
|
+
type: DataType;
|
|
209
|
+
}>;
|
|
210
|
+
/** 原 G2 spec 去掉复杂 Encode 类型并添加简易版 Encode 类型 */
|
|
211
|
+
export type G2ChartSpec = Omit<Mark, 'encode'> & {
|
|
212
|
+
encode: MarkEncode;
|
|
213
|
+
};
|
|
214
|
+
/** 原 G2 spec 去掉复杂 Encode 类型并添加简易版(带字段类型的) Encode 类型 */
|
|
215
|
+
export type ChartSpecWithEncodeType = Omit<Mark, 'encode'> & {
|
|
216
|
+
encode: MarkEncodeWithType;
|
|
217
|
+
};
|
|
218
|
+
export type { Specification };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var cloneDeep = function (obj) {
|
|
4
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
5
|
+
return obj;
|
|
6
|
+
}
|
|
7
|
+
var result;
|
|
8
|
+
if (Array.isArray(obj)) {
|
|
9
|
+
result = [];
|
|
10
|
+
for (var i = 0, l = obj.length; i < l; i += 1) {
|
|
11
|
+
if (typeof obj[i] === 'object' && obj[i] != null) {
|
|
12
|
+
result[i] = cloneDeep(obj[i]);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
result[i] = obj[i];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
result = {};
|
|
21
|
+
var objKeys = Object.keys(obj);
|
|
22
|
+
for (var i = 0; i < objKeys.length; i += 1) {
|
|
23
|
+
var key = objKeys[i];
|
|
24
|
+
if (typeof obj[key] === 'object' && obj[key] != null) {
|
|
25
|
+
result[key] = cloneDeep(obj[key]);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
result[key] = obj[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
exports.default = cloneDeep;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var isNil_1 = tslib_1.__importDefault(require("./isNil"));
|
|
5
|
+
var compare = function (f1, f2) {
|
|
6
|
+
if ((0, isNil_1.default)(f1.distinct) || (0, isNil_1.default)(f2.distinct)) {
|
|
7
|
+
if (f1.distinct < f2.distinct) {
|
|
8
|
+
return 1;
|
|
9
|
+
}
|
|
10
|
+
if (f1.distinct > f2.distinct) {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
};
|
|
17
|
+
exports.default = compare;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Info, RuleModule } from '../ruler';
|
|
2
|
+
import { CHART_IDS } from '../../ckb';
|
|
3
|
+
import type { ScoringResultForRule } from '../types';
|
|
4
|
+
import type { ChartKnowledgeBase } from '../../ckb';
|
|
5
|
+
declare type ChartID = (typeof CHART_IDS)[number];
|
|
6
|
+
declare const computeScore: (chartType: ChartID | string, chartWIKI: ChartKnowledgeBase, ruleBase: Record<string, RuleModule>, ruleType: 'HARD' | 'SOFT', info: Info, log: ScoringResultForRule[]) => number;
|
|
7
|
+
export default computeScore;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var constants_1 = require("../constants");
|
|
5
|
+
var defaultWeights = constants_1.DEFAULT_RULE_WEIGHTS;
|
|
6
|
+
var computeScore = function (chartType, chartWIKI, ruleBase, ruleType, info, log) {
|
|
7
|
+
// initial score is 1 for HARD rules and 0 for SOFT rules
|
|
8
|
+
var computedScore = 1;
|
|
9
|
+
Object.values(ruleBase)
|
|
10
|
+
.filter(function (r) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
var weight = ((_a = r.option) === null || _a === void 0 ? void 0 : _a.weight) || defaultWeights[r.id] || 1;
|
|
13
|
+
var extra = (_b = r.option) === null || _b === void 0 ? void 0 : _b.extra;
|
|
14
|
+
return r.type === ruleType && r.trigger(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, info), { weight: weight }), extra), { chartType: chartType, chartWIKI: chartWIKI })) && !((_c = r.option) === null || _c === void 0 ? void 0 : _c.off);
|
|
15
|
+
})
|
|
16
|
+
.forEach(function (r) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
var weight = ((_a = r.option) === null || _a === void 0 ? void 0 : _a.weight) || defaultWeights[r.id] || 1;
|
|
19
|
+
var extra = (_b = r.option) === null || _b === void 0 ? void 0 : _b.extra;
|
|
20
|
+
var base = r.validator(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, info), { weight: weight }), extra), { chartType: chartType, chartWIKI: chartWIKI }));
|
|
21
|
+
var score = weight * base;
|
|
22
|
+
computedScore *= score;
|
|
23
|
+
log.push({ phase: 'ADVISE', ruleId: r.id, score: score, base: base, weight: weight, ruleType: ruleType });
|
|
24
|
+
});
|
|
25
|
+
return computedScore;
|
|
26
|
+
};
|
|
27
|
+
exports.default = computeScore;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* implementation of deepMix in antv/utils
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var MAX_MIX_LEVEL = 5;
|
|
7
|
+
var isObjectLike = function (value) {
|
|
8
|
+
/*
|
|
9
|
+
* isObjectLike({}) => true
|
|
10
|
+
* isObjectLike([1, 2, 3]) => true
|
|
11
|
+
* isObjectLike(Function) => false
|
|
12
|
+
* isObjectLike(null) => false
|
|
13
|
+
*/
|
|
14
|
+
return typeof value === 'object' && value !== null;
|
|
15
|
+
};
|
|
16
|
+
var toString = {}.toString;
|
|
17
|
+
var isType = function (value, type) { return toString.call(value) === "[object ".concat(type, "]"); };
|
|
18
|
+
var isPlainObject = function (value) {
|
|
19
|
+
/*
|
|
20
|
+
* isObjectLike(new Foo) => false
|
|
21
|
+
* isObjectLike([1, 2, 3]) => false
|
|
22
|
+
* isObjectLike({ x: 0, y: 0 }) => true
|
|
23
|
+
* isObjectLike(Object.create(null)) => true
|
|
24
|
+
*/
|
|
25
|
+
if (!isObjectLike(value) || !isType(value, 'Object')) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (Object.getPrototypeOf(value) === null) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
var proto = value;
|
|
32
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
33
|
+
proto = Object.getPrototypeOf(proto);
|
|
34
|
+
}
|
|
35
|
+
return Object.getPrototypeOf(value) === proto;
|
|
36
|
+
};
|
|
37
|
+
var isArray = function (value) {
|
|
38
|
+
return Array.isArray ? Array.isArray(value) : isType(value, 'Array');
|
|
39
|
+
};
|
|
40
|
+
function pDeepMix(inputDist, src, inputLevel, inputMaxLevel) {
|
|
41
|
+
var level = inputLevel || 0;
|
|
42
|
+
var maxLevel = inputMaxLevel || MAX_MIX_LEVEL;
|
|
43
|
+
var dist = inputDist;
|
|
44
|
+
Object.keys(src).forEach(function (key) {
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(src, key)) {
|
|
46
|
+
var value = src[key];
|
|
47
|
+
if (value !== null && isPlainObject(value)) {
|
|
48
|
+
if (!isPlainObject(dist[key])) {
|
|
49
|
+
dist[key] = {};
|
|
50
|
+
}
|
|
51
|
+
if (level < maxLevel) {
|
|
52
|
+
pDeepMix(dist[key], value, level + 1, maxLevel);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
dist[key] = src[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (isArray(value)) {
|
|
59
|
+
dist[key] = [];
|
|
60
|
+
dist[key] = dist[key].concat(value);
|
|
61
|
+
}
|
|
62
|
+
else if (value !== undefined) {
|
|
63
|
+
dist[key] = value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var deepMix = function (rst) {
|
|
69
|
+
var args = [];
|
|
70
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
71
|
+
args[_i - 1] = arguments[_i];
|
|
72
|
+
}
|
|
73
|
+
for (var i = 0; i < args.length; i += 1) {
|
|
74
|
+
pDeepMix(rst, args[i]);
|
|
75
|
+
}
|
|
76
|
+
return rst;
|
|
77
|
+
};
|
|
78
|
+
exports.default = deepMix;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasSubset(array1: any[], array2: any[]): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* TODO @GuangMingYouBei: migrate utils into one unified folder of in ava.
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.intersects = exports.hasSubset = exports.cloneDeep = exports.compare = exports.deepMix = void 0;
|
|
10
|
+
var deep_mix_1 = require("./deep-mix");
|
|
11
|
+
Object.defineProperty(exports, "deepMix", { enumerable: true, get: function () { return __importDefault(deep_mix_1).default; } });
|
|
12
|
+
var compare_1 = require("./compare");
|
|
13
|
+
Object.defineProperty(exports, "compare", { enumerable: true, get: function () { return __importDefault(compare_1).default; } });
|
|
14
|
+
var clone_1 = require("./clone");
|
|
15
|
+
Object.defineProperty(exports, "cloneDeep", { enumerable: true, get: function () { return __importDefault(clone_1).default; } });
|
|
16
|
+
var hasSubset_1 = require("./hasSubset");
|
|
17
|
+
Object.defineProperty(exports, "hasSubset", { enumerable: true, get: function () { return hasSubset_1.hasSubset; } });
|
|
18
|
+
var intersects_1 = require("./intersects");
|
|
19
|
+
Object.defineProperty(exports, "intersects", { enumerable: true, get: function () { return intersects_1.intersects; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ScaleTypes } from '@antv/g2';
|
|
2
|
+
import { ChartSpecWithEncodeType, DataType, Encode, G2ChartSpec, TabularData } from '../types';
|
|
3
|
+
/** 推断数据类型 */
|
|
4
|
+
export declare function inferDataType(data: TabularData, encode: Encode, scale: ScaleTypes | undefined): DataType;
|
|
5
|
+
/** 获取带有字段类型的 chartSpec */
|
|
6
|
+
export declare function getSpecWithEncodeType(chartSpec: G2ChartSpec): ChartSpecWithEncodeType;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSpecWithEncodeType = exports.inferDataType = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
function isQuantitative(d) {
|
|
7
|
+
return typeof d === 'number';
|
|
8
|
+
}
|
|
9
|
+
function isCategorical(d) {
|
|
10
|
+
return typeof d === 'string' || typeof d === 'boolean';
|
|
11
|
+
}
|
|
12
|
+
function isTemporal(d) {
|
|
13
|
+
return d instanceof Date;
|
|
14
|
+
}
|
|
15
|
+
function isField(data, encode) {
|
|
16
|
+
return typeof encode === 'string' && data.some(function (d) { return d[encode] !== undefined; });
|
|
17
|
+
}
|
|
18
|
+
function isTransform(encode) {
|
|
19
|
+
return typeof encode === 'function';
|
|
20
|
+
}
|
|
21
|
+
// @ts-ignore: constant - 常数比例尺 / identity - 恒等比例尺 对用户不透出,所以此处ts-ignore
|
|
22
|
+
function scaleType2dataType(scaleType) {
|
|
23
|
+
switch (scaleType) {
|
|
24
|
+
case 'linear':
|
|
25
|
+
case 'log':
|
|
26
|
+
case 'pow':
|
|
27
|
+
case 'sqrt':
|
|
28
|
+
case 'qunatile':
|
|
29
|
+
case 'threshold':
|
|
30
|
+
case 'quantize':
|
|
31
|
+
case 'sequential':
|
|
32
|
+
return 'quantitative';
|
|
33
|
+
case 'time':
|
|
34
|
+
return 'temporal';
|
|
35
|
+
case 'ordinal':
|
|
36
|
+
case 'point':
|
|
37
|
+
case 'band':
|
|
38
|
+
return 'categorical';
|
|
39
|
+
default:
|
|
40
|
+
throw new Error("Unkonwn scale type: ".concat(scaleType, "."));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function values2dataType(values) {
|
|
44
|
+
if (values.some(isQuantitative))
|
|
45
|
+
return 'quantitative';
|
|
46
|
+
if (values.some(isCategorical))
|
|
47
|
+
return 'categorical';
|
|
48
|
+
if (values.some(isTemporal))
|
|
49
|
+
return 'temporal';
|
|
50
|
+
throw new Error("Unknown type: ".concat(typeof values[0]));
|
|
51
|
+
}
|
|
52
|
+
function columnOf(data, encode) {
|
|
53
|
+
if (isTransform(encode))
|
|
54
|
+
return data.map(encode);
|
|
55
|
+
if (isField(data, encode))
|
|
56
|
+
return data.map(function (d) { return d[encode]; });
|
|
57
|
+
return data.map(function () { return encode; });
|
|
58
|
+
}
|
|
59
|
+
/** 推断数据类型 */
|
|
60
|
+
function inferDataType(data, encode, scale) {
|
|
61
|
+
if (scale !== undefined)
|
|
62
|
+
return scaleType2dataType(scale);
|
|
63
|
+
var values = columnOf(data, encode);
|
|
64
|
+
return values2dataType(values);
|
|
65
|
+
}
|
|
66
|
+
exports.inferDataType = inferDataType;
|
|
67
|
+
/** 获取带有字段类型的 chartSpec */
|
|
68
|
+
function getSpecWithEncodeType(chartSpec) {
|
|
69
|
+
var encode = chartSpec.encode, data = chartSpec.data, scale = chartSpec.scale;
|
|
70
|
+
var newEncode = (0, lodash_1.mapValues)(encode, function (value, key) {
|
|
71
|
+
return { field: value, type: inferDataType(data, value, scale === null || scale === void 0 ? void 0 : scale[key].type) };
|
|
72
|
+
});
|
|
73
|
+
return tslib_1.__assign(tslib_1.__assign({}, chartSpec), { encode: newEncode });
|
|
74
|
+
}
|
|
75
|
+
exports.getSpecWithEncodeType = getSpecWithEncodeType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function intersects(array1: any[], array2: any[]): boolean;
|