@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.
Files changed (534) hide show
  1. package/README.md +72 -0
  2. package/dist/ava.min.js +1 -0
  3. package/esm/advisor/advise-pipeline/advicesForChart.js +68 -0
  4. package/esm/advisor/advise-pipeline/data-to-advices.js +241 -0
  5. package/esm/advisor/advise-pipeline/index.js +1 -0
  6. package/esm/advisor/advise-pipeline/spec-mapping.js +500 -0
  7. package/esm/advisor/advisor.js +35 -0
  8. package/esm/advisor/constants.js +13 -0
  9. package/esm/advisor/index.js +2 -0
  10. package/esm/advisor/lint-pipeline/check-rules.js +43 -0
  11. package/esm/advisor/lint-pipeline/getChartType.js +109 -0
  12. package/esm/advisor/lint-pipeline/index.js +0 -0
  13. package/esm/advisor/lint-pipeline/lintRules.js +32 -0
  14. package/esm/advisor/ruler/index.js +74 -0
  15. package/esm/advisor/ruler/rules/aggregation-single-row.js +21 -0
  16. package/esm/advisor/ruler/rules/all-can-be-table.js +17 -0
  17. package/esm/advisor/ruler/rules/bar-series-qty.js +36 -0
  18. package/esm/advisor/ruler/rules/bar-without-axis-min.js +41 -0
  19. package/esm/advisor/ruler/rules/constants.js +6 -0
  20. package/esm/advisor/ruler/rules/data-check.js +40 -0
  21. package/esm/advisor/ruler/rules/data-field-qty.js +26 -0
  22. package/esm/advisor/ruler/rules/diff-pie-sector.js +33 -0
  23. package/esm/advisor/ruler/rules/index.js +68 -0
  24. package/esm/advisor/ruler/rules/landscape-or-portrait.js +40 -0
  25. package/esm/advisor/ruler/rules/limit-series.js +47 -0
  26. package/esm/advisor/ruler/rules/line-field-time-ordinal.js +25 -0
  27. package/esm/advisor/ruler/rules/no-redundant-field.js +32 -0
  28. package/esm/advisor/ruler/rules/nominal-enum-combinatorial.js +54 -0
  29. package/esm/advisor/ruler/rules/purpose-check.js +27 -0
  30. package/esm/advisor/ruler/rules/series-qty-limit.js +34 -0
  31. package/esm/advisor/ruler/rules/x-axis-line-fading.js +41 -0
  32. package/esm/advisor/ruler/types.js +1 -0
  33. package/esm/advisor/ruler/utils.js +54 -0
  34. package/esm/advisor/types.js +1 -0
  35. package/esm/advisor/utils/clone.js +32 -0
  36. package/esm/advisor/utils/compare.js +14 -0
  37. package/esm/advisor/utils/computeScore.js +25 -0
  38. package/esm/advisor/utils/deep-mix.js +76 -0
  39. package/esm/advisor/utils/hasSubset.js +3 -0
  40. package/esm/advisor/utils/index.js +8 -0
  41. package/esm/advisor/utils/inferDataType.js +70 -0
  42. package/esm/advisor/utils/intersects.js +3 -0
  43. package/esm/advisor/utils/isNil.js +4 -0
  44. package/esm/ckb/base.js +1310 -0
  45. package/esm/ckb/ckb.js +55 -0
  46. package/esm/ckb/constants.js +197 -0
  47. package/esm/ckb/i18n/index.js +23 -0
  48. package/esm/ckb/i18n/types.js +1 -0
  49. package/esm/ckb/i18n/zh-CN.js +525 -0
  50. package/esm/ckb/index.js +14 -0
  51. package/esm/ckb/types.js +1 -0
  52. package/esm/common/types.js +1 -0
  53. package/esm/data/analysis/field/index.js +336 -0
  54. package/esm/data/analysis/field/types.js +1 -0
  55. package/esm/data/analysis/graph/index.js +170 -0
  56. package/esm/data/analysis/graph/types.js +1 -0
  57. package/esm/data/analysis/index.js +1 -0
  58. package/esm/data/analysis/types.js +1 -0
  59. package/esm/data/dataset/field/baseFrame.js +76 -0
  60. package/esm/data/dataset/field/dataFrame.js +556 -0
  61. package/esm/data/dataset/field/index.js +3 -0
  62. package/esm/data/dataset/field/series.js +149 -0
  63. package/esm/data/dataset/field/types.js +1 -0
  64. package/esm/data/dataset/field/utils.js +58 -0
  65. package/esm/data/dataset/graph/index.js +186 -0
  66. package/esm/data/dataset/graph/types.js +1 -0
  67. package/esm/data/dataset/graph/utils.js +15 -0
  68. package/esm/data/dataset/index.js +1 -0
  69. package/esm/data/dataset/types.js +1 -0
  70. package/esm/data/index.js +5 -0
  71. package/esm/data/statistics/IQR.js +49 -0
  72. package/esm/data/statistics/base.js +248 -0
  73. package/esm/data/statistics/bayesian.js +25 -0
  74. package/esm/data/statistics/buishand-u.js +19 -0
  75. package/esm/data/statistics/caches.js +28 -0
  76. package/esm/data/statistics/cdf.js +25 -0
  77. package/esm/data/statistics/constants.js +12 -0
  78. package/esm/data/statistics/index.js +7 -0
  79. package/esm/data/statistics/lowess.js +80 -0
  80. package/esm/data/statistics/mannkendall-test.js +50 -0
  81. package/esm/data/statistics/maxabs.js +9 -0
  82. package/esm/data/statistics/pcorrtest.js +76 -0
  83. package/esm/data/statistics/pettitt-test.js +33 -0
  84. package/esm/data/statistics/quantile.js +56 -0
  85. package/esm/data/statistics/types.js +1 -0
  86. package/esm/data/statistics/vector.js +67 -0
  87. package/esm/data/statistics/window.js +55 -0
  88. package/esm/data/types.js +2 -0
  89. package/esm/data/utils/common.js +58 -0
  90. package/esm/data/utils/index.js +5 -0
  91. package/esm/data/utils/isType/constants.js +24 -0
  92. package/esm/data/utils/isType/index.js +2 -0
  93. package/esm/data/utils/isType/isDateString.js +104 -0
  94. package/esm/data/utils/isType/isType.js +78 -0
  95. package/esm/index.js +11 -0
  96. package/esm/insight/algorithms/base/compare.js +40 -0
  97. package/esm/insight/algorithms/categoryOutlier.js +4 -0
  98. package/esm/insight/algorithms/changePoint.js +10 -0
  99. package/esm/insight/algorithms/index.js +3 -0
  100. package/esm/insight/algorithms/trendDirection.js +4 -0
  101. package/esm/insight/chart/constants.js +25 -0
  102. package/esm/insight/chart/generator/homogeneous.js +70 -0
  103. package/esm/insight/chart/generator/index.js +2 -0
  104. package/esm/insight/chart/generator/insights.js +16 -0
  105. package/esm/insight/chart/index.js +4 -0
  106. package/esm/insight/chart/strategy/augmentedMarks/categoryOutlier.js +30 -0
  107. package/esm/insight/chart/strategy/augmentedMarks/changePoint.js +42 -0
  108. package/esm/insight/chart/strategy/augmentedMarks/correlation.js +6 -0
  109. package/esm/insight/chart/strategy/augmentedMarks/homogeneous.js +5 -0
  110. package/esm/insight/chart/strategy/augmentedMarks/index.js +8 -0
  111. package/esm/insight/chart/strategy/augmentedMarks/lowVariance.js +23 -0
  112. package/esm/insight/chart/strategy/augmentedMarks/majority.js +5 -0
  113. package/esm/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +82 -0
  114. package/esm/insight/chart/strategy/augmentedMarks/trend.js +26 -0
  115. package/esm/insight/chart/strategy/chart.js +45 -0
  116. package/esm/insight/chart/strategy/commonMarks/areaMark.js +12 -0
  117. package/esm/insight/chart/strategy/commonMarks/index.js +5 -0
  118. package/esm/insight/chart/strategy/commonMarks/intervalMark.js +14 -0
  119. package/esm/insight/chart/strategy/commonMarks/lineMark.js +34 -0
  120. package/esm/insight/chart/strategy/commonMarks/pointMark.js +17 -0
  121. package/esm/insight/chart/strategy/commonMarks/textMark.js +28 -0
  122. package/esm/insight/chart/strategy/index.js +4 -0
  123. package/esm/insight/chart/strategy/viewSpec.js +16 -0
  124. package/esm/insight/chart/types.js +1 -0
  125. package/esm/insight/chart/utils.js +4 -0
  126. package/esm/insight/constant.js +21 -0
  127. package/esm/insight/index.js +5 -0
  128. package/esm/insight/insights/checkers.js +97 -0
  129. package/esm/insight/insights/extractors/categoryOutlier.js +90 -0
  130. package/esm/insight/insights/extractors/changePoint.js +55 -0
  131. package/esm/insight/insights/extractors/correlation.js +38 -0
  132. package/esm/insight/insights/extractors/homogeneous.js +98 -0
  133. package/esm/insight/insights/extractors/lowVariance.js +49 -0
  134. package/esm/insight/insights/extractors/majority.js +66 -0
  135. package/esm/insight/insights/extractors/timeSeriesOutlier.js +61 -0
  136. package/esm/insight/insights/extractors/trend.js +49 -0
  137. package/esm/insight/insights/index.js +28 -0
  138. package/esm/insight/insights/util.js +77 -0
  139. package/esm/insight/narrative/factory.js +22 -0
  140. package/esm/insight/narrative/index.js +14 -0
  141. package/esm/insight/narrative/strategy/base.js +6 -0
  142. package/esm/insight/narrative/strategy/categoryOutlier.js +74 -0
  143. package/esm/insight/narrative/strategy/changePoint.js +52 -0
  144. package/esm/insight/narrative/strategy/commonness.js +45 -0
  145. package/esm/insight/narrative/strategy/correlation.js +51 -0
  146. package/esm/insight/narrative/strategy/exception.js +70 -0
  147. package/esm/insight/narrative/strategy/helpers.js +25 -0
  148. package/esm/insight/narrative/strategy/index.js +13 -0
  149. package/esm/insight/narrative/strategy/lowVariance.js +48 -0
  150. package/esm/insight/narrative/strategy/majority.js +62 -0
  151. package/esm/insight/narrative/strategy/timeSeriesOutlier.js +92 -0
  152. package/esm/insight/narrative/strategy/trend.js +57 -0
  153. package/esm/insight/pipeline/extract.js +236 -0
  154. package/esm/insight/pipeline/index.js +11 -0
  155. package/esm/insight/pipeline/insight.js +81 -0
  156. package/esm/insight/pipeline/preprocess.js +33 -0
  157. package/esm/insight/pipeline/specificInsight.js +71 -0
  158. package/esm/insight/pipeline/util.js +14 -0
  159. package/esm/insight/pipeline/visualize.js +41 -0
  160. package/esm/insight/types.js +1 -0
  161. package/esm/insight/utils/aggregate.js +87 -0
  162. package/esm/insight/utils/common.js +35 -0
  163. package/esm/ntv/generate/generateTextSpec.js +157 -0
  164. package/esm/ntv/generate/index.js +5 -0
  165. package/esm/ntv/generate/types.js +1 -0
  166. package/esm/ntv/generate/utils.js +86 -0
  167. package/esm/ntv/index.js +4 -0
  168. package/esm/ntv/schema/common.js +1 -0
  169. package/esm/ntv/schema/index.js +4 -0
  170. package/esm/ntv/schema/paragraph.js +1 -0
  171. package/esm/ntv/schema/phrase.js +52 -0
  172. package/esm/ntv/schema/structure.js +1 -0
  173. package/esm/ntv/types.js +1 -0
  174. package/esm/ntv/utils/index.js +1 -0
  175. package/esm/ntv/utils/isSpecType.js +58 -0
  176. package/esm/utils/arr2map.js +7 -0
  177. package/esm/utils/dataFormat.js +32 -0
  178. package/esm/utils/index.js +3 -0
  179. package/esm/utils/isType.js +14 -0
  180. package/lib/advisor/advise-pipeline/advicesForChart.d.ts +13 -0
  181. package/lib/advisor/advise-pipeline/advicesForChart.js +73 -0
  182. package/lib/advisor/advise-pipeline/data-to-advices.d.ts +22 -0
  183. package/lib/advisor/advise-pipeline/data-to-advices.js +245 -0
  184. package/lib/advisor/advise-pipeline/index.d.ts +1 -0
  185. package/lib/advisor/advise-pipeline/index.js +5 -0
  186. package/lib/advisor/advise-pipeline/spec-mapping.d.ts +14 -0
  187. package/lib/advisor/advise-pipeline/spec-mapping.js +504 -0
  188. package/lib/advisor/advisor.d.ts +18 -0
  189. package/lib/advisor/advisor.js +38 -0
  190. package/lib/advisor/constants.d.ts +1 -0
  191. package/lib/advisor/constants.js +16 -0
  192. package/lib/advisor/index.d.ts +2 -0
  193. package/lib/advisor/index.js +7 -0
  194. package/lib/advisor/lint-pipeline/check-rules.d.ts +4 -0
  195. package/lib/advisor/lint-pipeline/check-rules.js +47 -0
  196. package/lib/advisor/lint-pipeline/getChartType.d.ts +7 -0
  197. package/lib/advisor/lint-pipeline/getChartType.js +113 -0
  198. package/lib/advisor/lint-pipeline/index.d.ts +0 -0
  199. package/lib/advisor/lint-pipeline/index.js +0 -0
  200. package/lib/advisor/lint-pipeline/lintRules.d.ts +5 -0
  201. package/lib/advisor/lint-pipeline/lintRules.js +36 -0
  202. package/lib/advisor/ruler/index.d.ts +21 -0
  203. package/lib/advisor/ruler/index.js +80 -0
  204. package/lib/advisor/ruler/rules/aggregation-single-row.d.ts +2 -0
  205. package/lib/advisor/ruler/rules/aggregation-single-row.js +24 -0
  206. package/lib/advisor/ruler/rules/all-can-be-table.d.ts +2 -0
  207. package/lib/advisor/ruler/rules/all-can-be-table.js +20 -0
  208. package/lib/advisor/ruler/rules/bar-series-qty.d.ts +2 -0
  209. package/lib/advisor/ruler/rules/bar-series-qty.js +39 -0
  210. package/lib/advisor/ruler/rules/bar-without-axis-min.d.ts +2 -0
  211. package/lib/advisor/ruler/rules/bar-without-axis-min.js +44 -0
  212. package/lib/advisor/ruler/rules/constants.d.ts +6 -0
  213. package/lib/advisor/ruler/rules/constants.js +9 -0
  214. package/lib/advisor/ruler/rules/data-check.d.ts +2 -0
  215. package/lib/advisor/ruler/rules/data-check.js +43 -0
  216. package/lib/advisor/ruler/rules/data-field-qty.d.ts +2 -0
  217. package/lib/advisor/ruler/rules/data-field-qty.js +29 -0
  218. package/lib/advisor/ruler/rules/diff-pie-sector.d.ts +2 -0
  219. package/lib/advisor/ruler/rules/diff-pie-sector.js +36 -0
  220. package/lib/advisor/ruler/rules/index.d.ts +19 -0
  221. package/lib/advisor/ruler/rules/index.js +71 -0
  222. package/lib/advisor/ruler/rules/landscape-or-portrait.d.ts +2 -0
  223. package/lib/advisor/ruler/rules/landscape-or-portrait.js +43 -0
  224. package/lib/advisor/ruler/rules/limit-series.d.ts +2 -0
  225. package/lib/advisor/ruler/rules/limit-series.js +50 -0
  226. package/lib/advisor/ruler/rules/line-field-time-ordinal.d.ts +2 -0
  227. package/lib/advisor/ruler/rules/line-field-time-ordinal.js +28 -0
  228. package/lib/advisor/ruler/rules/no-redundant-field.d.ts +2 -0
  229. package/lib/advisor/ruler/rules/no-redundant-field.js +35 -0
  230. package/lib/advisor/ruler/rules/nominal-enum-combinatorial.d.ts +2 -0
  231. package/lib/advisor/ruler/rules/nominal-enum-combinatorial.js +57 -0
  232. package/lib/advisor/ruler/rules/purpose-check.d.ts +2 -0
  233. package/lib/advisor/ruler/rules/purpose-check.js +30 -0
  234. package/lib/advisor/ruler/rules/series-qty-limit.d.ts +2 -0
  235. package/lib/advisor/ruler/rules/series-qty-limit.js +37 -0
  236. package/lib/advisor/ruler/rules/x-axis-line-fading.d.ts +2 -0
  237. package/lib/advisor/ruler/rules/x-axis-line-fading.js +44 -0
  238. package/lib/advisor/ruler/types.d.ts +125 -0
  239. package/lib/advisor/ruler/types.js +2 -0
  240. package/lib/advisor/ruler/utils.d.ts +10 -0
  241. package/lib/advisor/ruler/utils.js +61 -0
  242. package/lib/advisor/types.d.ts +218 -0
  243. package/lib/advisor/types.js +4 -0
  244. package/lib/advisor/utils/clone.d.ts +2 -0
  245. package/lib/advisor/utils/clone.js +34 -0
  246. package/lib/advisor/utils/compare.d.ts +3 -0
  247. package/lib/advisor/utils/compare.js +17 -0
  248. package/lib/advisor/utils/computeScore.d.ts +7 -0
  249. package/lib/advisor/utils/computeScore.js +27 -0
  250. package/lib/advisor/utils/deep-mix.d.ts +2 -0
  251. package/lib/advisor/utils/deep-mix.js +78 -0
  252. package/lib/advisor/utils/hasSubset.d.ts +1 -0
  253. package/lib/advisor/utils/hasSubset.js +7 -0
  254. package/lib/advisor/utils/index.d.ts +5 -0
  255. package/lib/advisor/utils/index.js +19 -0
  256. package/lib/advisor/utils/inferDataType.d.ts +6 -0
  257. package/lib/advisor/utils/inferDataType.js +75 -0
  258. package/lib/advisor/utils/intersects.d.ts +1 -0
  259. package/lib/advisor/utils/intersects.js +7 -0
  260. package/lib/advisor/utils/isNil.d.ts +2 -0
  261. package/lib/advisor/utils/isNil.js +6 -0
  262. package/lib/ckb/base.d.ts +2 -0
  263. package/lib/ckb/base.js +1313 -0
  264. package/lib/ckb/ckb.d.ts +8 -0
  265. package/lib/ckb/ckb.js +59 -0
  266. package/lib/ckb/constants.d.ts +79 -0
  267. package/lib/ckb/constants.js +200 -0
  268. package/lib/ckb/i18n/index.d.ts +10 -0
  269. package/lib/ckb/i18n/index.js +27 -0
  270. package/lib/ckb/i18n/types.d.ts +52 -0
  271. package/lib/ckb/i18n/types.js +2 -0
  272. package/lib/ckb/i18n/zh-CN.d.ts +7 -0
  273. package/lib/ckb/i18n/zh-CN.js +528 -0
  274. package/lib/ckb/index.d.ts +4 -0
  275. package/lib/ckb/index.js +20 -0
  276. package/lib/ckb/types.d.ts +185 -0
  277. package/lib/ckb/types.js +2 -0
  278. package/lib/common/types.d.ts +14 -0
  279. package/lib/common/types.js +2 -0
  280. package/lib/data/analysis/field/index.d.ts +79 -0
  281. package/lib/data/analysis/field/index.js +355 -0
  282. package/lib/data/analysis/field/types.d.ts +99 -0
  283. package/lib/data/analysis/field/types.js +2 -0
  284. package/lib/data/analysis/graph/index.d.ts +28 -0
  285. package/lib/data/analysis/graph/index.js +178 -0
  286. package/lib/data/analysis/graph/types.d.ts +62 -0
  287. package/lib/data/analysis/graph/types.js +2 -0
  288. package/lib/data/analysis/index.d.ts +1 -0
  289. package/lib/data/analysis/index.js +5 -0
  290. package/lib/data/analysis/types.d.ts +1 -0
  291. package/lib/data/analysis/types.js +2 -0
  292. package/lib/data/dataset/field/baseFrame.d.ts +30 -0
  293. package/lib/data/dataset/field/baseFrame.js +78 -0
  294. package/lib/data/dataset/field/dataFrame.d.ts +35 -0
  295. package/lib/data/dataset/field/dataFrame.js +558 -0
  296. package/lib/data/dataset/field/index.d.ts +3 -0
  297. package/lib/data/dataset/field/index.js +8 -0
  298. package/lib/data/dataset/field/series.d.ts +18 -0
  299. package/lib/data/dataset/field/series.js +151 -0
  300. package/lib/data/dataset/field/types.d.ts +54 -0
  301. package/lib/data/dataset/field/types.js +2 -0
  302. package/lib/data/dataset/field/utils.d.ts +13 -0
  303. package/lib/data/dataset/field/utils.js +68 -0
  304. package/lib/data/dataset/graph/index.d.ts +18 -0
  305. package/lib/data/dataset/graph/index.js +188 -0
  306. package/lib/data/dataset/graph/types.d.ts +35 -0
  307. package/lib/data/dataset/graph/types.js +2 -0
  308. package/lib/data/dataset/graph/utils.d.ts +1 -0
  309. package/lib/data/dataset/graph/utils.js +19 -0
  310. package/lib/data/dataset/index.d.ts +1 -0
  311. package/lib/data/dataset/index.js +4 -0
  312. package/lib/data/dataset/types.d.ts +1 -0
  313. package/lib/data/dataset/types.js +4 -0
  314. package/lib/data/index.d.ts +5 -0
  315. package/lib/data/index.js +8 -0
  316. package/lib/data/statistics/IQR.d.ts +21 -0
  317. package/lib/data/statistics/IQR.js +53 -0
  318. package/lib/data/statistics/base.d.ts +106 -0
  319. package/lib/data/statistics/base.js +271 -0
  320. package/lib/data/statistics/bayesian.d.ts +5 -0
  321. package/lib/data/statistics/bayesian.js +30 -0
  322. package/lib/data/statistics/buishand-u.d.ts +7 -0
  323. package/lib/data/statistics/buishand-u.js +23 -0
  324. package/lib/data/statistics/caches.d.ts +13 -0
  325. package/lib/data/statistics/caches.js +33 -0
  326. package/lib/data/statistics/cdf.d.ts +7 -0
  327. package/lib/data/statistics/cdf.js +29 -0
  328. package/lib/data/statistics/constants.d.ts +5 -0
  329. package/lib/data/statistics/constants.js +15 -0
  330. package/lib/data/statistics/index.d.ts +7 -0
  331. package/lib/data/statistics/index.js +14 -0
  332. package/lib/data/statistics/lowess.d.ts +10 -0
  333. package/lib/data/statistics/lowess.js +87 -0
  334. package/lib/data/statistics/mannkendall-test.d.ts +15 -0
  335. package/lib/data/statistics/mannkendall-test.js +54 -0
  336. package/lib/data/statistics/maxabs.d.ts +5 -0
  337. package/lib/data/statistics/maxabs.js +13 -0
  338. package/lib/data/statistics/pcorrtest.d.ts +3 -0
  339. package/lib/data/statistics/pcorrtest.js +80 -0
  340. package/lib/data/statistics/pettitt-test.d.ts +9 -0
  341. package/lib/data/statistics/pettitt-test.js +38 -0
  342. package/lib/data/statistics/quantile.d.ts +16 -0
  343. package/lib/data/statistics/quantile.js +61 -0
  344. package/lib/data/statistics/types.d.ts +70 -0
  345. package/lib/data/statistics/types.js +2 -0
  346. package/lib/data/statistics/vector.d.ts +15 -0
  347. package/lib/data/statistics/vector.js +78 -0
  348. package/lib/data/statistics/window.d.ts +12 -0
  349. package/lib/data/statistics/window.js +60 -0
  350. package/lib/data/types.d.ts +2 -0
  351. package/lib/data/types.js +5 -0
  352. package/lib/data/utils/common.d.ts +26 -0
  353. package/lib/data/utils/common.js +67 -0
  354. package/lib/data/utils/index.d.ts +2 -0
  355. package/lib/data/utils/index.js +8 -0
  356. package/lib/data/utils/isType/constants.d.ts +15 -0
  357. package/lib/data/utils/isType/constants.js +27 -0
  358. package/lib/data/utils/isType/index.d.ts +2 -0
  359. package/lib/data/utils/isType/index.js +5 -0
  360. package/lib/data/utils/isType/isDateString.d.ts +18 -0
  361. package/lib/data/utils/isType/isDateString.js +111 -0
  362. package/lib/data/utils/isType/isType.d.ts +13 -0
  363. package/lib/data/utils/isType/isType.js +94 -0
  364. package/lib/index.d.ts +10 -0
  365. package/lib/index.js +75 -0
  366. package/lib/insight/algorithms/base/compare.d.ts +14 -0
  367. package/lib/insight/algorithms/base/compare.js +45 -0
  368. package/lib/insight/algorithms/categoryOutlier.d.ts +4 -0
  369. package/lib/insight/algorithms/categoryOutlier.js +7 -0
  370. package/lib/insight/algorithms/changePoint.d.ts +10 -0
  371. package/lib/insight/algorithms/changePoint.js +13 -0
  372. package/lib/insight/algorithms/index.d.ts +3 -0
  373. package/lib/insight/algorithms/index.js +6 -0
  374. package/lib/insight/algorithms/trendDirection.d.ts +4 -0
  375. package/lib/insight/algorithms/trendDirection.js +7 -0
  376. package/lib/insight/chart/constants.d.ts +13 -0
  377. package/lib/insight/chart/constants.js +28 -0
  378. package/lib/insight/chart/generator/homogeneous.d.ts +3 -0
  379. package/lib/insight/chart/generator/homogeneous.js +75 -0
  380. package/lib/insight/chart/generator/index.d.ts +2 -0
  381. package/lib/insight/chart/generator/index.js +5 -0
  382. package/lib/insight/chart/generator/insights.d.ts +3 -0
  383. package/lib/insight/chart/generator/insights.js +20 -0
  384. package/lib/insight/chart/index.d.ts +4 -0
  385. package/lib/insight/chart/index.js +7 -0
  386. package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.d.ts +5 -0
  387. package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.js +35 -0
  388. package/lib/insight/chart/strategy/augmentedMarks/changePoint.d.ts +5 -0
  389. package/lib/insight/chart/strategy/augmentedMarks/changePoint.js +47 -0
  390. package/lib/insight/chart/strategy/augmentedMarks/correlation.d.ts +3 -0
  391. package/lib/insight/chart/strategy/augmentedMarks/correlation.js +10 -0
  392. package/lib/insight/chart/strategy/augmentedMarks/homogeneous.d.ts +3 -0
  393. package/lib/insight/chart/strategy/augmentedMarks/homogeneous.js +9 -0
  394. package/lib/insight/chart/strategy/augmentedMarks/index.d.ts +8 -0
  395. package/lib/insight/chart/strategy/augmentedMarks/index.js +24 -0
  396. package/lib/insight/chart/strategy/augmentedMarks/lowVariance.d.ts +5 -0
  397. package/lib/insight/chart/strategy/augmentedMarks/lowVariance.js +28 -0
  398. package/lib/insight/chart/strategy/augmentedMarks/majority.d.ts +3 -0
  399. package/lib/insight/chart/strategy/augmentedMarks/majority.js +9 -0
  400. package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.d.ts +5 -0
  401. package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +87 -0
  402. package/lib/insight/chart/strategy/augmentedMarks/trend.d.ts +5 -0
  403. package/lib/insight/chart/strategy/augmentedMarks/trend.js +31 -0
  404. package/lib/insight/chart/strategy/chart.d.ts +7 -0
  405. package/lib/insight/chart/strategy/chart.js +49 -0
  406. package/lib/insight/chart/strategy/commonMarks/areaMark.d.ts +3 -0
  407. package/lib/insight/chart/strategy/commonMarks/areaMark.js +16 -0
  408. package/lib/insight/chart/strategy/commonMarks/index.d.ts +5 -0
  409. package/lib/insight/chart/strategy/commonMarks/index.js +13 -0
  410. package/lib/insight/chart/strategy/commonMarks/intervalMark.d.ts +5 -0
  411. package/lib/insight/chart/strategy/commonMarks/intervalMark.js +18 -0
  412. package/lib/insight/chart/strategy/commonMarks/lineMark.d.ts +3 -0
  413. package/lib/insight/chart/strategy/commonMarks/lineMark.js +38 -0
  414. package/lib/insight/chart/strategy/commonMarks/pointMark.d.ts +5 -0
  415. package/lib/insight/chart/strategy/commonMarks/pointMark.js +21 -0
  416. package/lib/insight/chart/strategy/commonMarks/textMark.d.ts +5 -0
  417. package/lib/insight/chart/strategy/commonMarks/textMark.js +32 -0
  418. package/lib/insight/chart/strategy/index.d.ts +4 -0
  419. package/lib/insight/chart/strategy/index.js +10 -0
  420. package/lib/insight/chart/strategy/viewSpec.d.ts +3 -0
  421. package/lib/insight/chart/strategy/viewSpec.js +20 -0
  422. package/lib/insight/chart/types.d.ts +60 -0
  423. package/lib/insight/chart/types.js +2 -0
  424. package/lib/insight/chart/utils.d.ts +3 -0
  425. package/lib/insight/chart/utils.js +8 -0
  426. package/lib/insight/constant.d.ts +12 -0
  427. package/lib/insight/constant.js +24 -0
  428. package/lib/insight/index.d.ts +6 -0
  429. package/lib/insight/index.js +13 -0
  430. package/lib/insight/insights/checkers.d.ts +16 -0
  431. package/lib/insight/insights/checkers.js +107 -0
  432. package/lib/insight/insights/extractors/categoryOutlier.d.ts +12 -0
  433. package/lib/insight/insights/extractors/categoryOutlier.js +95 -0
  434. package/lib/insight/insights/extractors/changePoint.d.ts +8 -0
  435. package/lib/insight/insights/extractors/changePoint.js +60 -0
  436. package/lib/insight/insights/extractors/correlation.d.ts +9 -0
  437. package/lib/insight/insights/extractors/correlation.js +43 -0
  438. package/lib/insight/insights/extractors/homogeneous.d.ts +4 -0
  439. package/lib/insight/insights/extractors/homogeneous.js +103 -0
  440. package/lib/insight/insights/extractors/lowVariance.d.ts +8 -0
  441. package/lib/insight/insights/extractors/lowVariance.js +54 -0
  442. package/lib/insight/insights/extractors/majority.d.ts +10 -0
  443. package/lib/insight/insights/extractors/majority.js +71 -0
  444. package/lib/insight/insights/extractors/timeSeriesOutlier.d.ts +2 -0
  445. package/lib/insight/insights/extractors/timeSeriesOutlier.js +65 -0
  446. package/lib/insight/insights/extractors/trend.d.ts +9 -0
  447. package/lib/insight/insights/extractors/trend.js +54 -0
  448. package/lib/insight/insights/index.d.ts +12 -0
  449. package/lib/insight/insights/index.js +32 -0
  450. package/lib/insight/insights/util.d.ts +13 -0
  451. package/lib/insight/insights/util.js +87 -0
  452. package/lib/insight/narrative/factory.d.ts +6 -0
  453. package/lib/insight/narrative/factory.js +25 -0
  454. package/lib/insight/narrative/index.d.ts +3 -0
  455. package/lib/insight/narrative/index.js +18 -0
  456. package/lib/insight/narrative/strategy/base.d.ts +9 -0
  457. package/lib/insight/narrative/strategy/base.js +9 -0
  458. package/lib/insight/narrative/strategy/categoryOutlier.d.ts +9 -0
  459. package/lib/insight/narrative/strategy/categoryOutlier.js +76 -0
  460. package/lib/insight/narrative/strategy/changePoint.d.ts +8 -0
  461. package/lib/insight/narrative/strategy/changePoint.js +54 -0
  462. package/lib/insight/narrative/strategy/commonness.d.ts +9 -0
  463. package/lib/insight/narrative/strategy/commonness.js +47 -0
  464. package/lib/insight/narrative/strategy/correlation.d.ts +8 -0
  465. package/lib/insight/narrative/strategy/correlation.js +53 -0
  466. package/lib/insight/narrative/strategy/exception.d.ts +10 -0
  467. package/lib/insight/narrative/strategy/exception.js +72 -0
  468. package/lib/insight/narrative/strategy/helpers.d.ts +5 -0
  469. package/lib/insight/narrative/strategy/helpers.js +31 -0
  470. package/lib/insight/narrative/strategy/index.d.ts +9 -0
  471. package/lib/insight/narrative/strategy/index.js +28 -0
  472. package/lib/insight/narrative/strategy/lowVariance.d.ts +8 -0
  473. package/lib/insight/narrative/strategy/lowVariance.js +50 -0
  474. package/lib/insight/narrative/strategy/majority.d.ts +8 -0
  475. package/lib/insight/narrative/strategy/majority.js +64 -0
  476. package/lib/insight/narrative/strategy/timeSeriesOutlier.d.ts +8 -0
  477. package/lib/insight/narrative/strategy/timeSeriesOutlier.js +94 -0
  478. package/lib/insight/narrative/strategy/trend.d.ts +8 -0
  479. package/lib/insight/narrative/strategy/trend.js +59 -0
  480. package/lib/insight/pipeline/extract.d.ts +13 -0
  481. package/lib/insight/pipeline/extract.js +243 -0
  482. package/lib/insight/pipeline/index.d.ts +2 -0
  483. package/lib/insight/pipeline/index.js +15 -0
  484. package/lib/insight/pipeline/insight.d.ts +10 -0
  485. package/lib/insight/pipeline/insight.js +86 -0
  486. package/lib/insight/pipeline/preprocess.d.ts +6 -0
  487. package/lib/insight/pipeline/preprocess.js +39 -0
  488. package/lib/insight/pipeline/specificInsight.d.ts +11 -0
  489. package/lib/insight/pipeline/specificInsight.js +79 -0
  490. package/lib/insight/pipeline/util.d.ts +5 -0
  491. package/lib/insight/pipeline/util.js +20 -0
  492. package/lib/insight/pipeline/visualize.d.ts +3 -0
  493. package/lib/insight/pipeline/visualize.js +46 -0
  494. package/lib/insight/types.d.ts +238 -0
  495. package/lib/insight/types.js +2 -0
  496. package/lib/insight/utils/aggregate.d.ts +7 -0
  497. package/lib/insight/utils/aggregate.js +93 -0
  498. package/lib/insight/utils/common.d.ts +3 -0
  499. package/lib/insight/utils/common.js +41 -0
  500. package/lib/ntv/generate/generateTextSpec.d.ts +9 -0
  501. package/lib/ntv/generate/generateTextSpec.js +160 -0
  502. package/lib/ntv/generate/index.d.ts +2 -0
  503. package/lib/ntv/generate/index.js +12 -0
  504. package/lib/ntv/generate/types.d.ts +58 -0
  505. package/lib/ntv/generate/types.js +2 -0
  506. package/lib/ntv/generate/utils.d.ts +29 -0
  507. package/lib/ntv/generate/utils.js +96 -0
  508. package/lib/ntv/index.d.ts +4 -0
  509. package/lib/ntv/index.js +10 -0
  510. package/lib/ntv/schema/common.d.ts +17 -0
  511. package/lib/ntv/schema/common.js +2 -0
  512. package/lib/ntv/schema/index.d.ts +4 -0
  513. package/lib/ntv/schema/index.js +7 -0
  514. package/lib/ntv/schema/paragraph.d.ts +34 -0
  515. package/lib/ntv/schema/paragraph.js +2 -0
  516. package/lib/ntv/schema/phrase.d.ts +70 -0
  517. package/lib/ntv/schema/phrase.js +55 -0
  518. package/lib/ntv/schema/structure.d.ts +18 -0
  519. package/lib/ntv/schema/structure.js +2 -0
  520. package/lib/ntv/types.d.ts +2 -0
  521. package/lib/ntv/types.js +2 -0
  522. package/lib/ntv/utils/index.d.ts +1 -0
  523. package/lib/ntv/utils/index.js +4 -0
  524. package/lib/ntv/utils/isSpecType.d.ts +17 -0
  525. package/lib/ntv/utils/isSpecType.js +76 -0
  526. package/lib/utils/arr2map.d.ts +1 -0
  527. package/lib/utils/arr2map.js +11 -0
  528. package/lib/utils/dataFormat.d.ts +11 -0
  529. package/lib/utils/dataFormat.js +35 -0
  530. package/lib/utils/index.d.ts +3 -0
  531. package/lib/utils/index.js +8 -0
  532. package/lib/utils/isType.d.ts +4 -0
  533. package/lib/utils/isType.js +21 -0
  534. package/package.json +88 -0
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChartType = void 0;
4
+ var getPointChart = function (spec) {
5
+ if (spec.encode.size) {
6
+ return 'bubble_chart';
7
+ }
8
+ return 'scatter_plot';
9
+ };
10
+ /**
11
+ * 推荐所有 type 为 interval 的 spec 对应的具体图表类型
12
+ * type 为 interval的图表,可能为 column chart、bar chart、pie chart、donut chart
13
+ * @param spec
14
+ * @returns
15
+ */
16
+ var getIntervalChart = function (spec) {
17
+ var _a;
18
+ /** 饼图类型推断 */
19
+ var coordinate = spec.coordinate;
20
+ if ((coordinate === null || coordinate === void 0 ? void 0 : coordinate.type) === 'theta') {
21
+ if (coordinate === null || coordinate === void 0 ? void 0 : coordinate.innerRadius) {
22
+ return 'donut_chart';
23
+ }
24
+ return 'pie_chart';
25
+ }
26
+ /** 柱状图、条形图类型推断 */
27
+ var transform = spec.transform;
28
+ 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'; });
29
+ var isNormalized = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'normalizeY'; });
30
+ var isStacked = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'stackY'; });
31
+ var isGrouped = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'dodgeX'; });
32
+ if (isBarChart) {
33
+ // Bar
34
+ if (isGrouped)
35
+ return 'grouped_bar_chart';
36
+ if (isNormalized)
37
+ return 'stacked_bar_chart';
38
+ if (isStacked)
39
+ return 'percent_stacked_bar_chart';
40
+ return 'bar_chart';
41
+ }
42
+ // Column
43
+ if (isGrouped)
44
+ return 'grouped_column_chart';
45
+ if (isNormalized)
46
+ return 'stacked_column_chart';
47
+ if (isStacked)
48
+ return 'percent_stacked_column_chart';
49
+ return 'column_chart';
50
+ };
51
+ /**
52
+ * 推荐所有 type 为 area 的 spec 对应的具体图表类型
53
+ * @param spec
54
+ * @returns
55
+ */
56
+ var getAreaChart = function (spec) {
57
+ var transform = spec.transform;
58
+ var isStacked = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'stackY'; });
59
+ var isNormalized = transform === null || transform === void 0 ? void 0 : transform.some(function (item) { return item.type === 'normalizeY'; });
60
+ if (isStacked) {
61
+ if (isNormalized) {
62
+ return 'percent_stacked_area_chart';
63
+ }
64
+ return 'stacked_area_chart';
65
+ }
66
+ return 'area_chart';
67
+ };
68
+ /**
69
+ * 推荐所有 type 为 line 的 spec 对应的具体图表类型
70
+ * @param spec
71
+ * @returns
72
+ */
73
+ var getLineChart = function (spec) {
74
+ var encode = spec.encode;
75
+ if (encode.shape && encode.shape === 'hvh') {
76
+ return 'step_line_chart';
77
+ }
78
+ return 'line_chart';
79
+ };
80
+ /**
81
+ * 由于一种类型的 mark 可能对应多种可能的图表,所以需要此处进行转换
82
+ * @param spec
83
+ * @returns
84
+ */
85
+ var getChartType = function (spec) {
86
+ var chartType;
87
+ var chartSpec = spec;
88
+ var mark = chartSpec.type;
89
+ switch (mark) {
90
+ case 'area':
91
+ chartType = getAreaChart(chartSpec);
92
+ break;
93
+ case 'interval':
94
+ chartType = getIntervalChart(chartSpec);
95
+ break;
96
+ case 'line':
97
+ chartType = getLineChart(chartSpec);
98
+ break;
99
+ case 'point':
100
+ chartType = getPointChart(chartSpec);
101
+ break;
102
+ case 'rect':
103
+ chartType = 'histogram';
104
+ break;
105
+ case 'cell':
106
+ chartType = 'heatmap';
107
+ break;
108
+ default:
109
+ chartType = '';
110
+ }
111
+ return chartType;
112
+ };
113
+ exports.getChartType = getChartType;
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ import { Info, RuleModule } from '../ruler';
2
+ import type { Specification } from '../../common/types';
3
+ import type { ScoringResultForRule, Lint } from '../types';
4
+ import type { ChartKnowledgeBase } from '../../ckb';
5
+ export declare function lintRules(ruleBase: Record<string, RuleModule>, ruleTypeToLint: 'notDESIGN' | 'DESIGN', info: Info, log: ScoringResultForRule[], lints: Lint[], ckb: ChartKnowledgeBase, spec?: Specification): void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lintRules = void 0;
4
+ var tslib_1 = require("tslib");
5
+ function lintRules(ruleBase, ruleTypeToLint, info, log, lints, ckb, spec) {
6
+ var judge = function (type) {
7
+ if (ruleTypeToLint === 'DESIGN') {
8
+ return type === 'DESIGN';
9
+ }
10
+ return type !== 'DESIGN';
11
+ };
12
+ Object.values(ruleBase)
13
+ .filter(function (r) {
14
+ var _a;
15
+ var _b = r.option || {}, weight = _b.weight, extra = _b.extra;
16
+ return judge(r.type) && !((_a = r.option) === null || _a === void 0 ? void 0 : _a.off) && r.trigger(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, info), { weight: weight }), extra), { chartWIKI: ckb }));
17
+ })
18
+ .forEach(function (r) {
19
+ var type = r.type, id = r.id, docs = r.docs;
20
+ var score;
21
+ if (ruleTypeToLint === 'DESIGN') {
22
+ var fix = r.optimizer(info.dataProps, spec);
23
+ // no fix -> means no violation
24
+ score = Object.keys(fix).length === 0 ? 1 : 0;
25
+ lints.push({ type: type, id: id, score: score, fix: fix, docs: docs });
26
+ }
27
+ else {
28
+ var _a = r.option || {}, weight = _a.weight, extra = _a.extra;
29
+ // no weight for linter's result
30
+ score = r.validator(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, info), { weight: weight }), extra), { chartWIKI: ckb }));
31
+ lints.push({ type: type, id: id, score: score, docs: docs });
32
+ }
33
+ log.push({ phase: 'LINT', ruleId: id, score: score, base: score, weight: 1, ruleType: type });
34
+ });
35
+ }
36
+ exports.lintRules = lintRules;
@@ -0,0 +1,21 @@
1
+ import type { RuleModule, RuleConfig } from './types';
2
+ export declare const builtInRules: string[];
3
+ /**
4
+ *
5
+ * @param id rule id
6
+ * @returns the rule object or null if `id` not exist in built-in rules
7
+ */
8
+ export declare const getChartRule: (id: string) => RuleModule | null;
9
+ /**
10
+ *
11
+ * @param ids rule list
12
+ * @returns rule object list
13
+ */
14
+ export declare const getChartRules: (ids: string[]) => Record<string, RuleModule>;
15
+ /**
16
+ * processing ckb config and setup ckb used for advising
17
+ * @param ruleCfg rule configuration
18
+ * @returns rule base Record<string, RuleModule>
19
+ */
20
+ export declare const processRuleCfg: (ruleCfg?: RuleConfig) => Record<string, RuleModule>;
21
+ export * from './types';
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processRuleCfg = exports.getChartRules = exports.getChartRule = exports.builtInRules = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var rules_1 = require("./rules");
6
+ exports.builtInRules = Object.keys(rules_1.rules);
7
+ /**
8
+ *
9
+ * @param id rule id
10
+ * @returns the rule object or null if `id` not exist in built-in rules
11
+ */
12
+ var getChartRule = function (id) {
13
+ if (Object.keys(rules_1.rules).includes(id)) {
14
+ return rules_1.rules[id];
15
+ }
16
+ return null;
17
+ };
18
+ exports.getChartRule = getChartRule;
19
+ /**
20
+ *
21
+ * @param ids rule list
22
+ * @returns rule object list
23
+ */
24
+ var getChartRules = function (ids) {
25
+ var chartRules = {};
26
+ ids.forEach(function (id) {
27
+ if (Object.keys(rules_1.rules).includes(id)) {
28
+ chartRules[id] = rules_1.rules[id];
29
+ }
30
+ });
31
+ return chartRules;
32
+ };
33
+ exports.getChartRules = getChartRules;
34
+ /**
35
+ * processing ckb config and setup ckb used for advising
36
+ * @param ruleCfg rule configuration
37
+ * @returns rule base Record<string, RuleModule>
38
+ */
39
+ var processRuleCfg = function (ruleCfg) {
40
+ if (!ruleCfg) {
41
+ // no specific rule configuration -> return default rules
42
+ return (0, exports.getChartRules)(exports.builtInRules);
43
+ }
44
+ // step 1: remove excluded rule
45
+ var ruleBase = (0, exports.getChartRules)(exports.builtInRules);
46
+ if (ruleCfg.exclude) {
47
+ // have `exclude` definition
48
+ var toExclude = ruleCfg.exclude;
49
+ toExclude.forEach(function (id) {
50
+ if (Object.keys(ruleBase).includes(id)) {
51
+ delete ruleBase[id];
52
+ }
53
+ });
54
+ }
55
+ // step 2: remove rules that are not included
56
+ if (ruleCfg.include) {
57
+ var toInclude_1 = ruleCfg.include;
58
+ Object.keys(ruleBase).forEach(function (id) {
59
+ if (!toInclude_1.includes(id)) {
60
+ delete ruleBase[id];
61
+ }
62
+ });
63
+ }
64
+ // step 3: combine ruleBase and custom rules
65
+ var finalRuleBase = tslib_1.__assign(tslib_1.__assign({}, ruleBase), ruleCfg.custom);
66
+ // step 4: check options
67
+ var options = ruleCfg.options;
68
+ if (options) {
69
+ var ruleWithOption = Object.keys(options);
70
+ ruleWithOption.forEach(function (rule) {
71
+ if (Object.keys(finalRuleBase).includes(rule)) {
72
+ var ruleOption = options[rule];
73
+ finalRuleBase[rule] = tslib_1.__assign(tslib_1.__assign({}, finalRuleBase[rule]), { option: ruleOption });
74
+ }
75
+ });
76
+ }
77
+ return finalRuleBase;
78
+ };
79
+ exports.processRuleCfg = processRuleCfg;
80
+ tslib_1.__exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const aggregationSingleRow: RuleModule;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aggregationSingleRow = void 0;
4
+ exports.aggregationSingleRow = {
5
+ id: 'aggregation-single-row',
6
+ type: 'HARD',
7
+ docs: {
8
+ lintText: 'Recommend kpi_panel when only one row of aggregated data is available.',
9
+ },
10
+ trigger: function () {
11
+ return true;
12
+ },
13
+ validator: function (args) {
14
+ var result = 0;
15
+ var chartType = args.chartType, dataProps = args.dataProps;
16
+ if (dataProps.every(function (i) { return i.count === 1 && i.levelOfMeasurements.includes('Interval'); })) {
17
+ result = chartType === 'kpi_panel' ? 1 : 0.2;
18
+ }
19
+ else {
20
+ result = chartType === 'kpi_panel' ? 0 : 1;
21
+ }
22
+ return result;
23
+ },
24
+ };
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const allCanBeTable: RuleModule;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allCanBeTable = void 0;
4
+ var utils_1 = require("../utils");
5
+ var applyChartTypes = ['table'];
6
+ exports.allCanBeTable = {
7
+ id: 'all-can-be-table',
8
+ type: 'HARD',
9
+ docs: {
10
+ lintText: 'all dataset can be table',
11
+ },
12
+ trigger: function (_a) {
13
+ var chartType = _a.chartType;
14
+ return applyChartTypes.includes(chartType);
15
+ },
16
+ validator: function (_a) {
17
+ var weight = _a.weight;
18
+ return (0, utils_1.isUndefined)(weight) ? 1 : weight;
19
+ },
20
+ };
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const barSeriesQty: RuleModule;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.barSeriesQty = void 0;
4
+ var utils_1 = require("../../utils");
5
+ var constants_1 = require("./constants");
6
+ var applyChartTypes = [
7
+ 'bar_chart',
8
+ 'grouped_bar_chart',
9
+ 'stacked_bar_chart',
10
+ 'percent_stacked_bar_chart',
11
+ 'column_chart',
12
+ 'grouped_column_chart',
13
+ 'stacked_column_chart',
14
+ 'percent_stacked_column_chart',
15
+ ];
16
+ exports.barSeriesQty = {
17
+ id: 'bar-series-qty',
18
+ type: 'SOFT',
19
+ docs: {
20
+ lintText: 'Bar chart should has proper number of bars or bar groups.',
21
+ },
22
+ trigger: function (_a) {
23
+ var chartType = _a.chartType;
24
+ return applyChartTypes.includes(chartType);
25
+ },
26
+ validator: function (args) {
27
+ var result = 1;
28
+ var dataProps = args.dataProps, chartType = args.chartType;
29
+ if (dataProps && chartType) {
30
+ var field4Series = dataProps.find(function (field) { return (0, utils_1.hasSubset)(field.levelOfMeasurements, ['Nominal']); });
31
+ var seriesQty = field4Series && field4Series.count ? field4Series.count : 0;
32
+ if (seriesQty > 20) {
33
+ result = 20 / seriesQty;
34
+ }
35
+ }
36
+ result = result < 1 / constants_1.MAX_SOFT_RULE_COEFFICIENT ? 1 / constants_1.MAX_SOFT_RULE_COEFFICIENT : result;
37
+ return result;
38
+ },
39
+ };
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const barWithoutAxisMin: RuleModule;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.barWithoutAxisMin = void 0;
4
+ var applyChartTypes = [
5
+ 'bar_chart',
6
+ 'grouped_bar_chart',
7
+ 'stacked_bar_chart',
8
+ 'percent_stacked_bar_chart',
9
+ 'column_chart',
10
+ 'grouped_column_chart',
11
+ 'stacked_column_chart',
12
+ 'percent_stacked_column_chart',
13
+ ];
14
+ exports.barWithoutAxisMin = {
15
+ id: 'bar-without-axis-min',
16
+ type: 'DESIGN',
17
+ docs: {
18
+ lintText: 'It is not recommended to set the minimum value of axis for the bar or column chart.',
19
+ fixText: 'Remove the minimum value config of axis.',
20
+ },
21
+ trigger: function (_a) {
22
+ var chartType = _a.chartType;
23
+ return applyChartTypes.includes(chartType);
24
+ },
25
+ optimizer: function (_, chartSpec) {
26
+ var _a, _b;
27
+ var scale = chartSpec.scale;
28
+ if (!scale)
29
+ return {};
30
+ // @ts-ignore 待 g2 发版后去掉@ts-ignore
31
+ var xMin = (_a = scale.x) === null || _a === void 0 ? void 0 : _a.domainMin;
32
+ // @ts-ignore 同上
33
+ var yMin = (_b = scale.y) === null || _b === void 0 ? void 0 : _b.domainMin;
34
+ if (xMin || yMin) {
35
+ var newScale = JSON.parse(JSON.stringify(scale));
36
+ if (xMin)
37
+ newScale.x.domainMin = 0;
38
+ if (yMin)
39
+ newScale.y.domainMin = 0;
40
+ return { scale: newScale };
41
+ }
42
+ return {};
43
+ },
44
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * MAX_SOFT_RULE_COEFFICIENT is the max benifit coefficient for soft rule in advisor
3
+ * correspondingly,
4
+ * ( 1 / MAX_SOFT_RULE_COEFFICIENT )is the "max" penalty coefficient for soft rule in advisor
5
+ * */
6
+ export declare const MAX_SOFT_RULE_COEFFICIENT = 10;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_SOFT_RULE_COEFFICIENT = void 0;
4
+ /**
5
+ * MAX_SOFT_RULE_COEFFICIENT is the max benifit coefficient for soft rule in advisor
6
+ * correspondingly,
7
+ * ( 1 / MAX_SOFT_RULE_COEFFICIENT )is the "max" penalty coefficient for soft rule in advisor
8
+ * */
9
+ exports.MAX_SOFT_RULE_COEFFICIENT = 10;
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const dataCheck: RuleModule;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataCheck = void 0;
4
+ var utils_1 = require("../utils");
5
+ var utils_2 = require("../../utils");
6
+ exports.dataCheck = {
7
+ id: 'data-check',
8
+ type: 'HARD',
9
+ docs: {
10
+ lintText: 'Data must satisfy the data prerequisites.',
11
+ },
12
+ trigger: function () {
13
+ return true;
14
+ },
15
+ validator: function (args) {
16
+ var result = 0;
17
+ var dataProps = args.dataProps, chartType = args.chartType, chartWIKI = args.chartWIKI;
18
+ if (dataProps && chartType && chartWIKI[chartType]) {
19
+ result = 1;
20
+ var dataPres_1 = chartWIKI[chartType].dataPres || [];
21
+ dataPres_1.forEach(function (dataPre) {
22
+ if (!(0, utils_1.verifyDataProps)(dataPre, dataProps)) {
23
+ result = 0;
24
+ }
25
+ });
26
+ var fieldsLOMs = dataProps.map(function (info) {
27
+ return info.levelOfMeasurements;
28
+ });
29
+ fieldsLOMs.forEach(function (fieldLOM) {
30
+ var flag = false;
31
+ dataPres_1.forEach(function (dataPre) {
32
+ if (fieldLOM && (0, utils_2.intersects)(fieldLOM, dataPre.fieldConditions)) {
33
+ flag = true;
34
+ }
35
+ });
36
+ if (!flag) {
37
+ result = 0;
38
+ }
39
+ });
40
+ }
41
+ return result;
42
+ },
43
+ };
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const dataFieldQty: RuleModule;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataFieldQty = void 0;
4
+ exports.dataFieldQty = {
5
+ id: 'data-field-qty',
6
+ type: 'HARD',
7
+ docs: {
8
+ lintText: 'Data must have at least the min qty of the prerequisite.',
9
+ },
10
+ trigger: function () {
11
+ return true;
12
+ },
13
+ validator: function (args) {
14
+ var result = 0;
15
+ var dataProps = args.dataProps, chartType = args.chartType, chartWIKI = args.chartWIKI;
16
+ if (dataProps && chartType && chartWIKI[chartType]) {
17
+ result = 1;
18
+ var dataPres = chartWIKI[chartType].dataPres || [];
19
+ var minFieldQty = dataPres.map(function (e) { return e.minQty; }).reduce(function (acc, cv) { return acc + cv; });
20
+ if (dataProps.length) {
21
+ var fieldQty = dataProps.length;
22
+ if (fieldQty >= minFieldQty) {
23
+ result = 1;
24
+ }
25
+ }
26
+ }
27
+ return result;
28
+ },
29
+ };
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const diffPieSector: RuleModule;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.diffPieSector = void 0;
4
+ var utils_1 = require("../../utils");
5
+ var constants_1 = require("./constants");
6
+ var applyChartTypes = ['pie_chart', 'donut_chart'];
7
+ exports.diffPieSector = {
8
+ id: 'diff-pie-sector',
9
+ type: 'SOFT',
10
+ docs: {
11
+ lintText: 'The difference between sectors of a pie chart should be large enough.',
12
+ },
13
+ trigger: function (_a) {
14
+ var chartType = _a.chartType;
15
+ return applyChartTypes.includes(chartType);
16
+ },
17
+ validator: function (args) {
18
+ var result = 1;
19
+ var dataProps = args.dataProps;
20
+ if (dataProps) {
21
+ var intervalField = dataProps.find(function (field) { return (0, utils_1.hasSubset)(field.levelOfMeasurements, ['Interval']); });
22
+ if (intervalField && intervalField.sum && intervalField.rawData) {
23
+ var sum = intervalField.sum;
24
+ var scale_1 = 1 / sum;
25
+ var scaledSamples = intervalField.rawData.map(function (v) { return v * scale_1; });
26
+ var scaledProduct = scaledSamples.reduce(function (a, c) { return a * c; });
27
+ var count = intervalField.rawData.length;
28
+ var maxProduct = Math.pow((1 / count), count);
29
+ // Math.abs(maxProduct - Math.abs(scaledProduct)) / maxProduct 这个值 小于 0.5 会被认为有点问题
30
+ result = constants_1.MAX_SOFT_RULE_COEFFICIENT * 0.2 * (Math.abs(maxProduct - Math.abs(scaledProduct)) / maxProduct);
31
+ }
32
+ }
33
+ result = result < 1 / constants_1.MAX_SOFT_RULE_COEFFICIENT ? 1 / constants_1.MAX_SOFT_RULE_COEFFICIENT : result;
34
+ return result;
35
+ },
36
+ };
@@ -0,0 +1,19 @@
1
+ import type { RuleModule } from '../types';
2
+ /**
3
+ * @public
4
+ */
5
+ export declare const CHART_RULE_ID: readonly string[];
6
+ /**
7
+ * @public
8
+ */
9
+ export type ChartRuleID = (typeof CHART_RULE_ID)[number];
10
+ /**
11
+ * @public
12
+ */
13
+ export declare const CHART_DESIGN_RULE_ID: readonly ["x-axis-line-fading", "bar-without-axis-min"];
14
+ /**
15
+ * @public
16
+ */
17
+ export type ChartDesignRuleID = (typeof CHART_DESIGN_RULE_ID)[number];
18
+ export type RuleId = ChartRuleID | ChartDesignRuleID;
19
+ export declare const rules: Partial<Record<RuleId, RuleModule>>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rules = exports.CHART_DESIGN_RULE_ID = exports.CHART_RULE_ID = void 0;
4
+ var tslib_1 = require("tslib");
5
+ // Chart rules (hard and soft)
6
+ // table and kpi_panel not include currently
7
+ // import { aggregationSingleRow } from './aggregation-single-row';
8
+ // import { allCanBeTable } from './all-can-be-table';
9
+ var bar_series_qty_1 = require("./bar-series-qty");
10
+ var bar_without_axis_min_1 = require("./bar-without-axis-min");
11
+ var data_check_1 = require("./data-check");
12
+ var data_field_qty_1 = require("./data-field-qty");
13
+ var diff_pie_sector_1 = require("./diff-pie-sector");
14
+ var landscape_or_portrait_1 = require("./landscape-or-portrait");
15
+ var limit_series_1 = require("./limit-series");
16
+ var line_field_time_ordinal_1 = require("./line-field-time-ordinal");
17
+ var no_redundant_field_1 = require("./no-redundant-field");
18
+ var nominal_enum_combinatorial_1 = require("./nominal-enum-combinatorial");
19
+ var purpose_check_1 = require("./purpose-check");
20
+ var series_qty_limit_1 = require("./series-qty-limit");
21
+ // Design rules
22
+ var x_axis_line_fading_1 = require("./x-axis-line-fading");
23
+ /** hard rules for validating chart type */
24
+ var HARD_RULE_ID = [
25
+ // table and kpi_panel not include currently
26
+ // 'aggregation-single-row',
27
+ // 'all-can-be-table',
28
+ 'data-check',
29
+ 'data-field-qty',
30
+ 'no-redundant-field',
31
+ 'purpose-check',
32
+ ];
33
+ /** soft rules for scoring chart type */
34
+ var SOFT_RULE_ID = [
35
+ 'series-qty-limit',
36
+ 'bar-series-qty',
37
+ 'line-field-time-ordinal',
38
+ 'landscape-or-portrait',
39
+ 'diff-pie-sector',
40
+ 'nominal-enum-combinatorial',
41
+ 'limit-series',
42
+ ];
43
+ /**
44
+ * @public
45
+ */
46
+ exports.CHART_RULE_ID = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(HARD_RULE_ID), false), tslib_1.__read(SOFT_RULE_ID), false);
47
+ /**
48
+ * @public
49
+ */
50
+ exports.CHART_DESIGN_RULE_ID = ['x-axis-line-fading', 'bar-without-axis-min'];
51
+ exports.rules = {
52
+ /** -- hard rules -- */
53
+ // table and kpi_panel not include currently
54
+ // 'aggregation-single-row': aggregationSingleRow,
55
+ // 'all-can-be-table': allCanBeTable,
56
+ 'data-check': data_check_1.dataCheck,
57
+ 'data-field-qty': data_field_qty_1.dataFieldQty,
58
+ 'no-redundant-field': no_redundant_field_1.noRedundantField,
59
+ 'purpose-check': purpose_check_1.purposeCheck,
60
+ /** -- soft rules -- */
61
+ 'bar-series-qty': bar_series_qty_1.barSeriesQty,
62
+ 'diff-pie-sector': diff_pie_sector_1.diffPieSector,
63
+ 'landscape-or-portrait': landscape_or_portrait_1.landscapeOrPortrait,
64
+ 'limit-series': limit_series_1.limitSeries,
65
+ 'line-field-time-ordinal': line_field_time_ordinal_1.lineFieldTimeOrdinal,
66
+ 'nominal-enum-combinatorial': nominal_enum_combinatorial_1.nominalEnumCombinatorial,
67
+ 'series-qty-limit': series_qty_limit_1.seriesQtyLimit,
68
+ /** -- design rules -- */
69
+ 'x-axis-line-fading': x_axis_line_fading_1.xAxisLineFading,
70
+ 'bar-without-axis-min': bar_without_axis_min_1.barWithoutAxisMin,
71
+ };
@@ -0,0 +1,2 @@
1
+ import type { RuleModule } from '../types';
2
+ export declare const landscapeOrPortrait: RuleModule;