@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,109 @@
|
|
|
1
|
+
var getPointChart = function (spec) {
|
|
2
|
+
if (spec.encode.size) {
|
|
3
|
+
return 'bubble_chart';
|
|
4
|
+
}
|
|
5
|
+
return 'scatter_plot';
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 推荐所有 type 为 interval 的 spec 对应的具体图表类型
|
|
9
|
+
* type 为 interval的图表,可能为 column chart、bar chart、pie chart、donut chart
|
|
10
|
+
* @param spec
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
var getIntervalChart = function (spec) {
|
|
14
|
+
var _a;
|
|
15
|
+
/** 饼图类型推断 */
|
|
16
|
+
var coordinate = spec.coordinate;
|
|
17
|
+
if ((coordinate === null || coordinate === void 0 ? void 0 : coordinate.type) === 'theta') {
|
|
18
|
+
if (coordinate === null || coordinate === void 0 ? void 0 : coordinate.innerRadius) {
|
|
19
|
+
return 'donut_chart';
|
|
20
|
+
}
|
|
21
|
+
return 'pie_chart';
|
|
22
|
+
}
|
|
23
|
+
/** 柱状图、条形图类型推断 */
|
|
24
|
+
var transform = spec.transform;
|
|
25
|
+
var isBarChart = (_a = coordinate === null || coordinate === void 0 ? void 0 : coordinate.transform) === null || _a === void 0 ? void 0 : _a.some(function (item) { return item.type === 'transpose'; });
|
|
26
|
+
var isNormalized = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'normalizeY'; });
|
|
27
|
+
var isStacked = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'stackY'; });
|
|
28
|
+
var isGrouped = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'dodgeX'; });
|
|
29
|
+
if (isBarChart) {
|
|
30
|
+
// Bar
|
|
31
|
+
if (isGrouped)
|
|
32
|
+
return 'grouped_bar_chart';
|
|
33
|
+
if (isNormalized)
|
|
34
|
+
return 'stacked_bar_chart';
|
|
35
|
+
if (isStacked)
|
|
36
|
+
return 'percent_stacked_bar_chart';
|
|
37
|
+
return 'bar_chart';
|
|
38
|
+
}
|
|
39
|
+
// Column
|
|
40
|
+
if (isGrouped)
|
|
41
|
+
return 'grouped_column_chart';
|
|
42
|
+
if (isNormalized)
|
|
43
|
+
return 'stacked_column_chart';
|
|
44
|
+
if (isStacked)
|
|
45
|
+
return 'percent_stacked_column_chart';
|
|
46
|
+
return 'column_chart';
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 推荐所有 type 为 area 的 spec 对应的具体图表类型
|
|
50
|
+
* @param spec
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
var getAreaChart = function (spec) {
|
|
54
|
+
var transform = spec.transform;
|
|
55
|
+
var isStacked = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'stackY'; });
|
|
56
|
+
var isNormalized = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'normalizeY'; });
|
|
57
|
+
if (isStacked) {
|
|
58
|
+
if (isNormalized) {
|
|
59
|
+
return 'percent_stacked_area_chart';
|
|
60
|
+
}
|
|
61
|
+
return 'stacked_area_chart';
|
|
62
|
+
}
|
|
63
|
+
return 'area_chart';
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* 推荐所有 type 为 line 的 spec 对应的具体图表类型
|
|
67
|
+
* @param spec
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
var getLineChart = function (spec) {
|
|
71
|
+
var encode = spec.encode;
|
|
72
|
+
if (encode.shape && encode.shape === 'hvh') {
|
|
73
|
+
return 'step_line_chart';
|
|
74
|
+
}
|
|
75
|
+
return 'line_chart';
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* 由于一种类型的 mark 可能对应多种可能的图表,所以需要此处进行转换
|
|
79
|
+
* @param spec
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
export var getChartType = function (spec) {
|
|
83
|
+
var chartType;
|
|
84
|
+
var chartSpec = spec;
|
|
85
|
+
var mark = chartSpec.type;
|
|
86
|
+
switch (mark) {
|
|
87
|
+
case 'area':
|
|
88
|
+
chartType = getAreaChart(chartSpec);
|
|
89
|
+
break;
|
|
90
|
+
case 'interval':
|
|
91
|
+
chartType = getIntervalChart(chartSpec);
|
|
92
|
+
break;
|
|
93
|
+
case 'line':
|
|
94
|
+
chartType = getLineChart(chartSpec);
|
|
95
|
+
break;
|
|
96
|
+
case 'point':
|
|
97
|
+
chartType = getPointChart(chartSpec);
|
|
98
|
+
break;
|
|
99
|
+
case 'rect':
|
|
100
|
+
chartType = 'histogram';
|
|
101
|
+
break;
|
|
102
|
+
case 'cell':
|
|
103
|
+
chartType = 'heatmap';
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
chartType = '';
|
|
107
|
+
}
|
|
108
|
+
return chartType;
|
|
109
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
export function lintRules(ruleBase, ruleTypeToLint, info, log, lints, ckb, spec) {
|
|
3
|
+
var judge = function (type) {
|
|
4
|
+
if (ruleTypeToLint === 'DESIGN') {
|
|
5
|
+
return type === 'DESIGN';
|
|
6
|
+
}
|
|
7
|
+
return type !== 'DESIGN';
|
|
8
|
+
};
|
|
9
|
+
Object.values(ruleBase)
|
|
10
|
+
.filter(function (r) {
|
|
11
|
+
var _a;
|
|
12
|
+
var _b = r.option || {}, weight = _b.weight, extra = _b.extra;
|
|
13
|
+
return judge(r.type) && !((_a = r.option) === null || _a === void 0 ? void 0 : _a.off) && r.trigger(__assign(__assign(__assign(__assign({}, info), { weight: weight }), extra), { chartWIKI: ckb }));
|
|
14
|
+
})
|
|
15
|
+
.forEach(function (r) {
|
|
16
|
+
var type = r.type, id = r.id, docs = r.docs;
|
|
17
|
+
var score;
|
|
18
|
+
if (ruleTypeToLint === 'DESIGN') {
|
|
19
|
+
var fix = r.optimizer(info.dataProps, spec);
|
|
20
|
+
// no fix -> means no violation
|
|
21
|
+
score = Object.keys(fix).length === 0 ? 1 : 0;
|
|
22
|
+
lints.push({ type: type, id: id, score: score, fix: fix, docs: docs });
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
var _a = r.option || {}, weight = _a.weight, extra = _a.extra;
|
|
26
|
+
// no weight for linter's result
|
|
27
|
+
score = r.validator(__assign(__assign(__assign(__assign({}, info), { weight: weight }), extra), { chartWIKI: ckb }));
|
|
28
|
+
lints.push({ type: type, id: id, score: score, docs: docs });
|
|
29
|
+
}
|
|
30
|
+
log.push({ phase: 'LINT', ruleId: id, score: score, base: score, weight: 1, ruleType: type });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { rules } from './rules';
|
|
3
|
+
export var builtInRules = Object.keys(rules);
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param id rule id
|
|
7
|
+
* @returns the rule object or null if `id` not exist in built-in rules
|
|
8
|
+
*/
|
|
9
|
+
export var getChartRule = function (id) {
|
|
10
|
+
if (Object.keys(rules).includes(id)) {
|
|
11
|
+
return rules[id];
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param ids rule list
|
|
18
|
+
* @returns rule object list
|
|
19
|
+
*/
|
|
20
|
+
export var getChartRules = function (ids) {
|
|
21
|
+
var chartRules = {};
|
|
22
|
+
ids.forEach(function (id) {
|
|
23
|
+
if (Object.keys(rules).includes(id)) {
|
|
24
|
+
chartRules[id] = rules[id];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return chartRules;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* processing ckb config and setup ckb used for advising
|
|
31
|
+
* @param ruleCfg rule configuration
|
|
32
|
+
* @returns rule base Record<string, RuleModule>
|
|
33
|
+
*/
|
|
34
|
+
export var processRuleCfg = function (ruleCfg) {
|
|
35
|
+
if (!ruleCfg) {
|
|
36
|
+
// no specific rule configuration -> return default rules
|
|
37
|
+
return getChartRules(builtInRules);
|
|
38
|
+
}
|
|
39
|
+
// step 1: remove excluded rule
|
|
40
|
+
var ruleBase = getChartRules(builtInRules);
|
|
41
|
+
if (ruleCfg.exclude) {
|
|
42
|
+
// have `exclude` definition
|
|
43
|
+
var toExclude = ruleCfg.exclude;
|
|
44
|
+
toExclude.forEach(function (id) {
|
|
45
|
+
if (Object.keys(ruleBase).includes(id)) {
|
|
46
|
+
delete ruleBase[id];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// step 2: remove rules that are not included
|
|
51
|
+
if (ruleCfg.include) {
|
|
52
|
+
var toInclude_1 = ruleCfg.include;
|
|
53
|
+
Object.keys(ruleBase).forEach(function (id) {
|
|
54
|
+
if (!toInclude_1.includes(id)) {
|
|
55
|
+
delete ruleBase[id];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// step 3: combine ruleBase and custom rules
|
|
60
|
+
var finalRuleBase = __assign(__assign({}, ruleBase), ruleCfg.custom);
|
|
61
|
+
// step 4: check options
|
|
62
|
+
var options = ruleCfg.options;
|
|
63
|
+
if (options) {
|
|
64
|
+
var ruleWithOption = Object.keys(options);
|
|
65
|
+
ruleWithOption.forEach(function (rule) {
|
|
66
|
+
if (Object.keys(finalRuleBase).includes(rule)) {
|
|
67
|
+
var ruleOption = options[rule];
|
|
68
|
+
finalRuleBase[rule] = __assign(__assign({}, finalRuleBase[rule]), { option: ruleOption });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return finalRuleBase;
|
|
73
|
+
};
|
|
74
|
+
export * from './types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export var aggregationSingleRow = {
|
|
2
|
+
id: 'aggregation-single-row',
|
|
3
|
+
type: 'HARD',
|
|
4
|
+
docs: {
|
|
5
|
+
lintText: 'Recommend kpi_panel when only one row of aggregated data is available.',
|
|
6
|
+
},
|
|
7
|
+
trigger: function () {
|
|
8
|
+
return true;
|
|
9
|
+
},
|
|
10
|
+
validator: function (args) {
|
|
11
|
+
var result = 0;
|
|
12
|
+
var chartType = args.chartType, dataProps = args.dataProps;
|
|
13
|
+
if (dataProps.every(function (i) { return i.count === 1 && i.levelOfMeasurements.includes('Interval'); })) {
|
|
14
|
+
result = chartType === 'kpi_panel' ? 1 : 0.2;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result = chartType === 'kpi_panel' ? 0 : 1;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isUndefined } from '../utils';
|
|
2
|
+
var applyChartTypes = ['table'];
|
|
3
|
+
export var allCanBeTable = {
|
|
4
|
+
id: 'all-can-be-table',
|
|
5
|
+
type: 'HARD',
|
|
6
|
+
docs: {
|
|
7
|
+
lintText: 'all dataset can be table',
|
|
8
|
+
},
|
|
9
|
+
trigger: function (_a) {
|
|
10
|
+
var chartType = _a.chartType;
|
|
11
|
+
return applyChartTypes.includes(chartType);
|
|
12
|
+
},
|
|
13
|
+
validator: function (_a) {
|
|
14
|
+
var weight = _a.weight;
|
|
15
|
+
return isUndefined(weight) ? 1 : weight;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { hasSubset } from '../../utils';
|
|
2
|
+
import { MAX_SOFT_RULE_COEFFICIENT } from './constants';
|
|
3
|
+
var applyChartTypes = [
|
|
4
|
+
'bar_chart',
|
|
5
|
+
'grouped_bar_chart',
|
|
6
|
+
'stacked_bar_chart',
|
|
7
|
+
'percent_stacked_bar_chart',
|
|
8
|
+
'column_chart',
|
|
9
|
+
'grouped_column_chart',
|
|
10
|
+
'stacked_column_chart',
|
|
11
|
+
'percent_stacked_column_chart',
|
|
12
|
+
];
|
|
13
|
+
export var barSeriesQty = {
|
|
14
|
+
id: 'bar-series-qty',
|
|
15
|
+
type: 'SOFT',
|
|
16
|
+
docs: {
|
|
17
|
+
lintText: 'Bar chart should has proper number of bars or bar groups.',
|
|
18
|
+
},
|
|
19
|
+
trigger: function (_a) {
|
|
20
|
+
var chartType = _a.chartType;
|
|
21
|
+
return applyChartTypes.includes(chartType);
|
|
22
|
+
},
|
|
23
|
+
validator: function (args) {
|
|
24
|
+
var result = 1;
|
|
25
|
+
var dataProps = args.dataProps, chartType = args.chartType;
|
|
26
|
+
if (dataProps && chartType) {
|
|
27
|
+
var field4Series = dataProps.find(function (field) { return hasSubset(field.levelOfMeasurements, ['Nominal']); });
|
|
28
|
+
var seriesQty = field4Series && field4Series.count ? field4Series.count : 0;
|
|
29
|
+
if (seriesQty > 20) {
|
|
30
|
+
result = 20 / seriesQty;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
result = result < 1 / MAX_SOFT_RULE_COEFFICIENT ? 1 / MAX_SOFT_RULE_COEFFICIENT : result;
|
|
34
|
+
return result;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var applyChartTypes = [
|
|
2
|
+
'bar_chart',
|
|
3
|
+
'grouped_bar_chart',
|
|
4
|
+
'stacked_bar_chart',
|
|
5
|
+
'percent_stacked_bar_chart',
|
|
6
|
+
'column_chart',
|
|
7
|
+
'grouped_column_chart',
|
|
8
|
+
'stacked_column_chart',
|
|
9
|
+
'percent_stacked_column_chart',
|
|
10
|
+
];
|
|
11
|
+
export var barWithoutAxisMin = {
|
|
12
|
+
id: 'bar-without-axis-min',
|
|
13
|
+
type: 'DESIGN',
|
|
14
|
+
docs: {
|
|
15
|
+
lintText: 'It is not recommended to set the minimum value of axis for the bar or column chart.',
|
|
16
|
+
fixText: 'Remove the minimum value config of axis.',
|
|
17
|
+
},
|
|
18
|
+
trigger: function (_a) {
|
|
19
|
+
var chartType = _a.chartType;
|
|
20
|
+
return applyChartTypes.includes(chartType);
|
|
21
|
+
},
|
|
22
|
+
optimizer: function (_, chartSpec) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
var scale = chartSpec.scale;
|
|
25
|
+
if (!scale)
|
|
26
|
+
return {};
|
|
27
|
+
// @ts-ignore 待 g2 发版后去掉@ts-ignore
|
|
28
|
+
var xMin = (_a = scale.x) === null || _a === void 0 ? void 0 : _a.domainMin;
|
|
29
|
+
// @ts-ignore 同上
|
|
30
|
+
var yMin = (_b = scale.y) === null || _b === void 0 ? void 0 : _b.domainMin;
|
|
31
|
+
if (xMin || yMin) {
|
|
32
|
+
var newScale = JSON.parse(JSON.stringify(scale));
|
|
33
|
+
if (xMin)
|
|
34
|
+
newScale.x.domainMin = 0;
|
|
35
|
+
if (yMin)
|
|
36
|
+
newScale.y.domainMin = 0;
|
|
37
|
+
return { scale: newScale };
|
|
38
|
+
}
|
|
39
|
+
return {};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { verifyDataProps } from '../utils';
|
|
2
|
+
import { intersects } from '../../utils';
|
|
3
|
+
export var dataCheck = {
|
|
4
|
+
id: 'data-check',
|
|
5
|
+
type: 'HARD',
|
|
6
|
+
docs: {
|
|
7
|
+
lintText: 'Data must satisfy the data prerequisites.',
|
|
8
|
+
},
|
|
9
|
+
trigger: function () {
|
|
10
|
+
return true;
|
|
11
|
+
},
|
|
12
|
+
validator: function (args) {
|
|
13
|
+
var result = 0;
|
|
14
|
+
var dataProps = args.dataProps, chartType = args.chartType, chartWIKI = args.chartWIKI;
|
|
15
|
+
if (dataProps && chartType && chartWIKI[chartType]) {
|
|
16
|
+
result = 1;
|
|
17
|
+
var dataPres_1 = chartWIKI[chartType].dataPres || [];
|
|
18
|
+
dataPres_1.forEach(function (dataPre) {
|
|
19
|
+
if (!verifyDataProps(dataPre, dataProps)) {
|
|
20
|
+
result = 0;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var fieldsLOMs = dataProps.map(function (info) {
|
|
24
|
+
return info.levelOfMeasurements;
|
|
25
|
+
});
|
|
26
|
+
fieldsLOMs.forEach(function (fieldLOM) {
|
|
27
|
+
var flag = false;
|
|
28
|
+
dataPres_1.forEach(function (dataPre) {
|
|
29
|
+
if (fieldLOM && intersects(fieldLOM, dataPre.fieldConditions)) {
|
|
30
|
+
flag = true;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (!flag) {
|
|
34
|
+
result = 0;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var dataFieldQty = {
|
|
2
|
+
id: 'data-field-qty',
|
|
3
|
+
type: 'HARD',
|
|
4
|
+
docs: {
|
|
5
|
+
lintText: 'Data must have at least the min qty of the prerequisite.',
|
|
6
|
+
},
|
|
7
|
+
trigger: function () {
|
|
8
|
+
return true;
|
|
9
|
+
},
|
|
10
|
+
validator: function (args) {
|
|
11
|
+
var result = 0;
|
|
12
|
+
var dataProps = args.dataProps, chartType = args.chartType, chartWIKI = args.chartWIKI;
|
|
13
|
+
if (dataProps && chartType && chartWIKI[chartType]) {
|
|
14
|
+
result = 1;
|
|
15
|
+
var dataPres = chartWIKI[chartType].dataPres || [];
|
|
16
|
+
var minFieldQty = dataPres.map(function (e) { return e.minQty; }).reduce(function (acc, cv) { return acc + cv; });
|
|
17
|
+
if (dataProps.length) {
|
|
18
|
+
var fieldQty = dataProps.length;
|
|
19
|
+
if (fieldQty >= minFieldQty) {
|
|
20
|
+
result = 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { hasSubset } from '../../utils';
|
|
2
|
+
import { MAX_SOFT_RULE_COEFFICIENT } from './constants';
|
|
3
|
+
var applyChartTypes = ['pie_chart', 'donut_chart'];
|
|
4
|
+
export var diffPieSector = {
|
|
5
|
+
id: 'diff-pie-sector',
|
|
6
|
+
type: 'SOFT',
|
|
7
|
+
docs: {
|
|
8
|
+
lintText: 'The difference between sectors of a pie chart should be large enough.',
|
|
9
|
+
},
|
|
10
|
+
trigger: function (_a) {
|
|
11
|
+
var chartType = _a.chartType;
|
|
12
|
+
return applyChartTypes.includes(chartType);
|
|
13
|
+
},
|
|
14
|
+
validator: function (args) {
|
|
15
|
+
var result = 1;
|
|
16
|
+
var dataProps = args.dataProps;
|
|
17
|
+
if (dataProps) {
|
|
18
|
+
var intervalField = dataProps.find(function (field) { return hasSubset(field.levelOfMeasurements, ['Interval']); });
|
|
19
|
+
if (intervalField && intervalField.sum && intervalField.rawData) {
|
|
20
|
+
var sum = intervalField.sum;
|
|
21
|
+
var scale_1 = 1 / sum;
|
|
22
|
+
var scaledSamples = intervalField.rawData.map(function (v) { return v * scale_1; });
|
|
23
|
+
var scaledProduct = scaledSamples.reduce(function (a, c) { return a * c; });
|
|
24
|
+
var count = intervalField.rawData.length;
|
|
25
|
+
var maxProduct = Math.pow((1 / count), count);
|
|
26
|
+
// Math.abs(maxProduct - Math.abs(scaledProduct)) / maxProduct 这个值 小于 0.5 会被认为有点问题
|
|
27
|
+
result = MAX_SOFT_RULE_COEFFICIENT * 0.2 * (Math.abs(maxProduct - Math.abs(scaledProduct)) / maxProduct);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
result = result < 1 / MAX_SOFT_RULE_COEFFICIENT ? 1 / MAX_SOFT_RULE_COEFFICIENT : result;
|
|
31
|
+
return result;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
|
+
// Chart rules (hard and soft)
|
|
3
|
+
// table and kpi_panel not include currently
|
|
4
|
+
// import { aggregationSingleRow } from './aggregation-single-row';
|
|
5
|
+
// import { allCanBeTable } from './all-can-be-table';
|
|
6
|
+
import { barSeriesQty } from './bar-series-qty';
|
|
7
|
+
import { barWithoutAxisMin } from './bar-without-axis-min';
|
|
8
|
+
import { dataCheck } from './data-check';
|
|
9
|
+
import { dataFieldQty } from './data-field-qty';
|
|
10
|
+
import { diffPieSector } from './diff-pie-sector';
|
|
11
|
+
import { landscapeOrPortrait } from './landscape-or-portrait';
|
|
12
|
+
import { limitSeries } from './limit-series';
|
|
13
|
+
import { lineFieldTimeOrdinal } from './line-field-time-ordinal';
|
|
14
|
+
import { noRedundantField } from './no-redundant-field';
|
|
15
|
+
import { nominalEnumCombinatorial } from './nominal-enum-combinatorial';
|
|
16
|
+
import { purposeCheck } from './purpose-check';
|
|
17
|
+
import { seriesQtyLimit } from './series-qty-limit';
|
|
18
|
+
// Design rules
|
|
19
|
+
import { xAxisLineFading } from './x-axis-line-fading';
|
|
20
|
+
/** hard rules for validating chart type */
|
|
21
|
+
var HARD_RULE_ID = [
|
|
22
|
+
// table and kpi_panel not include currently
|
|
23
|
+
// 'aggregation-single-row',
|
|
24
|
+
// 'all-can-be-table',
|
|
25
|
+
'data-check',
|
|
26
|
+
'data-field-qty',
|
|
27
|
+
'no-redundant-field',
|
|
28
|
+
'purpose-check',
|
|
29
|
+
];
|
|
30
|
+
/** soft rules for scoring chart type */
|
|
31
|
+
var SOFT_RULE_ID = [
|
|
32
|
+
'series-qty-limit',
|
|
33
|
+
'bar-series-qty',
|
|
34
|
+
'line-field-time-ordinal',
|
|
35
|
+
'landscape-or-portrait',
|
|
36
|
+
'diff-pie-sector',
|
|
37
|
+
'nominal-enum-combinatorial',
|
|
38
|
+
'limit-series',
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export var CHART_RULE_ID = __spreadArray(__spreadArray([], __read(HARD_RULE_ID), false), __read(SOFT_RULE_ID), false);
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export var CHART_DESIGN_RULE_ID = ['x-axis-line-fading', 'bar-without-axis-min'];
|
|
48
|
+
export var rules = {
|
|
49
|
+
/** -- hard rules -- */
|
|
50
|
+
// table and kpi_panel not include currently
|
|
51
|
+
// 'aggregation-single-row': aggregationSingleRow,
|
|
52
|
+
// 'all-can-be-table': allCanBeTable,
|
|
53
|
+
'data-check': dataCheck,
|
|
54
|
+
'data-field-qty': dataFieldQty,
|
|
55
|
+
'no-redundant-field': noRedundantField,
|
|
56
|
+
'purpose-check': purposeCheck,
|
|
57
|
+
/** -- soft rules -- */
|
|
58
|
+
'bar-series-qty': barSeriesQty,
|
|
59
|
+
'diff-pie-sector': diffPieSector,
|
|
60
|
+
'landscape-or-portrait': landscapeOrPortrait,
|
|
61
|
+
'limit-series': limitSeries,
|
|
62
|
+
'line-field-time-ordinal': lineFieldTimeOrdinal,
|
|
63
|
+
'nominal-enum-combinatorial': nominalEnumCombinatorial,
|
|
64
|
+
'series-qty-limit': seriesQtyLimit,
|
|
65
|
+
/** -- design rules -- */
|
|
66
|
+
'x-axis-line-fading': xAxisLineFading,
|
|
67
|
+
'bar-without-axis-min': barWithoutAxisMin,
|
|
68
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MAX_SOFT_RULE_COEFFICIENT } from './constants';
|
|
2
|
+
var applyChartTypes = [
|
|
3
|
+
'bar_chart',
|
|
4
|
+
'grouped_bar_chart',
|
|
5
|
+
'stacked_bar_chart',
|
|
6
|
+
'percent_stacked_bar_chart',
|
|
7
|
+
'column_chart',
|
|
8
|
+
'grouped_column_chart',
|
|
9
|
+
'stacked_column_chart',
|
|
10
|
+
'percent_stacked_column_chart',
|
|
11
|
+
];
|
|
12
|
+
function hasCanvasLayout(_a) {
|
|
13
|
+
var chartType = _a.chartType, dataProps = _a.dataProps, preferences = _a.preferences;
|
|
14
|
+
return !!(dataProps && chartType && preferences && preferences.canvasLayout);
|
|
15
|
+
}
|
|
16
|
+
export var landscapeOrPortrait = {
|
|
17
|
+
id: 'landscape-or-portrait',
|
|
18
|
+
type: 'SOFT',
|
|
19
|
+
docs: {
|
|
20
|
+
lintText: 'Recommend column charts for landscape layout and bar charts for portrait layout.',
|
|
21
|
+
},
|
|
22
|
+
trigger: function (info) {
|
|
23
|
+
return applyChartTypes.includes(info.chartType) && hasCanvasLayout(info);
|
|
24
|
+
},
|
|
25
|
+
validator: function (args) {
|
|
26
|
+
var result = 1;
|
|
27
|
+
var chartType = args.chartType, preferences = args.preferences;
|
|
28
|
+
if (hasCanvasLayout(args)) {
|
|
29
|
+
if (preferences.canvasLayout === 'portrait' &&
|
|
30
|
+
['bar_chart', 'grouped_bar_chart', 'stacked_bar_chart', 'percent_stacked_bar_chart'].includes(chartType)) {
|
|
31
|
+
result = MAX_SOFT_RULE_COEFFICIENT * 0.5;
|
|
32
|
+
}
|
|
33
|
+
else if (preferences.canvasLayout === 'landscape' &&
|
|
34
|
+
['column_chart', 'grouped_column_chart', 'stacked_column_chart', 'percent_stacked_column_chart'].includes(chartType)) {
|
|
35
|
+
result = MAX_SOFT_RULE_COEFFICIENT * 0.5;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { intersects } from '../../utils';
|
|
2
|
+
import { compare } from '../utils';
|
|
3
|
+
import { MAX_SOFT_RULE_COEFFICIENT } from './constants';
|
|
4
|
+
function hasSeriesField(dataProps) {
|
|
5
|
+
var nominalOrOrdinalFields = dataProps.filter(function (field) {
|
|
6
|
+
return intersects(field.levelOfMeasurements, ['Nominal', 'Ordinal']);
|
|
7
|
+
});
|
|
8
|
+
return nominalOrOrdinalFields.length >= 2;
|
|
9
|
+
}
|
|
10
|
+
/*
|
|
11
|
+
只有 heatmap 能映射两个 维值非常多的 字段,因为对于 其他图表,如柱状图来说,第二个维度字段 就要映射成 颜色了。而颜色不适合映射特别多的维度。
|
|
12
|
+
所以,在有 两个 维度字段的时候,在两个维度的维值都很多的情况下,要给 heatmap 加分,给其他图表减分。
|
|
13
|
+
*/
|
|
14
|
+
export var limitSeries = {
|
|
15
|
+
id: 'limit-series',
|
|
16
|
+
type: 'SOFT',
|
|
17
|
+
docs: {
|
|
18
|
+
lintText: 'Avoid too many values in one series.',
|
|
19
|
+
},
|
|
20
|
+
trigger: function (_a) {
|
|
21
|
+
var dataProps = _a.dataProps;
|
|
22
|
+
return hasSeriesField(dataProps);
|
|
23
|
+
},
|
|
24
|
+
validator: function (args) {
|
|
25
|
+
var result = 1;
|
|
26
|
+
var dataProps = args.dataProps, chartType = args.chartType;
|
|
27
|
+
if (dataProps) {
|
|
28
|
+
var nominalOrOrdinalFields = dataProps.filter(function (field) {
|
|
29
|
+
return intersects(field.levelOfMeasurements, ['Nominal', 'Ordinal']);
|
|
30
|
+
});
|
|
31
|
+
if (nominalOrOrdinalFields.length >= 2) {
|
|
32
|
+
var sortedFields = nominalOrOrdinalFields.sort(compare);
|
|
33
|
+
var f = sortedFields[1];
|
|
34
|
+
if (f.distinct) {
|
|
35
|
+
result = f.distinct > MAX_SOFT_RULE_COEFFICIENT ? 1 / MAX_SOFT_RULE_COEFFICIENT : 1 / f.distinct;
|
|
36
|
+
if (f.distinct > 6 && chartType === 'heatmap') {
|
|
37
|
+
result = MAX_SOFT_RULE_COEFFICIENT * 0.5;
|
|
38
|
+
}
|
|
39
|
+
else if (chartType === 'heatmap') {
|
|
40
|
+
result = 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { intersects } from '../../utils';
|
|
2
|
+
import { MAX_SOFT_RULE_COEFFICIENT } from './constants';
|
|
3
|
+
var applyChartTypes = ['line_chart', 'area_chart', 'stacked_area_chart', 'percent_stacked_area_chart'];
|
|
4
|
+
export var lineFieldTimeOrdinal = {
|
|
5
|
+
id: 'line-field-time-ordinal',
|
|
6
|
+
type: 'SOFT',
|
|
7
|
+
docs: {
|
|
8
|
+
lintText: 'Data containing time or ordinal fields are suitable for line or area charts.',
|
|
9
|
+
},
|
|
10
|
+
trigger: function (_a) {
|
|
11
|
+
var chartType = _a.chartType;
|
|
12
|
+
return applyChartTypes.includes(chartType);
|
|
13
|
+
},
|
|
14
|
+
validator: function (args) {
|
|
15
|
+
var result = 1;
|
|
16
|
+
var dataProps = args.dataProps;
|
|
17
|
+
if (dataProps) {
|
|
18
|
+
var field4TimeOrOrdinal = dataProps.find(function (field) { return intersects(field.levelOfMeasurements, ['Ordinal', 'Time']); });
|
|
19
|
+
if (field4TimeOrOrdinal) {
|
|
20
|
+
result = MAX_SOFT_RULE_COEFFICIENT * 0.5;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var noRedundantField = {
|
|
2
|
+
id: 'no-redundant-field',
|
|
3
|
+
type: 'HARD',
|
|
4
|
+
docs: {
|
|
5
|
+
lintText: 'No redundant field.',
|
|
6
|
+
},
|
|
7
|
+
trigger: function () {
|
|
8
|
+
return true;
|
|
9
|
+
},
|
|
10
|
+
validator: function (args) {
|
|
11
|
+
var result = 0;
|
|
12
|
+
var dataProps = args.dataProps, chartType = args.chartType, chartWIKI = args.chartWIKI;
|
|
13
|
+
if (dataProps && chartType && chartWIKI[chartType]) {
|
|
14
|
+
var dataPres = chartWIKI[chartType].dataPres || [];
|
|
15
|
+
var maxFieldQty = dataPres
|
|
16
|
+
.map(function (e) {
|
|
17
|
+
if (e.maxQty === '*') {
|
|
18
|
+
return 99;
|
|
19
|
+
}
|
|
20
|
+
return e.maxQty;
|
|
21
|
+
})
|
|
22
|
+
.reduce(function (acc, cv) { return acc + cv; });
|
|
23
|
+
if (dataProps.length) {
|
|
24
|
+
var fieldQty = dataProps.length;
|
|
25
|
+
if (fieldQty <= maxFieldQty) {
|
|
26
|
+
result = 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
},
|
|
32
|
+
};
|