Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@visactor/chart-advisor

Package Overview
Dependencies
Maintainers
15
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visactor/chart-advisor - npm Package Compare versions

Comparing version 0.1.11 to 1.2.5-alpha.4

es/constant.d.ts

56

package.json
{
"name": "@visactor/chart-advisor",
"version": "0.1.11",
"version": "1.2.5-alpha.4",
"description": "图表推荐模块",
"main": "cjs/index.js",
"module": "esm/index.js",
"types": "esm/index.d.ts",
"main": "lib",
"module": "es",
"types": "es",
"sideEffects": false,
"exports": {
".": {
"import": "./es/index.js",
"require": "./lib/index.js"
}
},
"files": [
"cjs",
"esm",
"README.md",
"lib",
"es",
"build"
],
"scripts": {
"test": "npx jest",
"build": "tsc"
},
"author": "",
"license": "MIT",
"dependencies": {
"lodash": "^4.17.21"
"lodash": "4.17.21"
},
"devDependencies": {
"@types/jest": "^29.5.6",
"@types/lodash": "^4.14.172",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2",
"undici-types": "^5.27.2"
"@types/jest": "^26.0.0",
"@types/lodash": "4.14.182",
"@types/node": "*",
"jest": "^26.0.0",
"ts-jest": "^26.0.0",
"typescript": "4.9.5",
"undici-types": "^5.27.2",
"@typescript-eslint/eslint-plugin": "5.30.0",
"@typescript-eslint/parser": "5.30.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"@rushstack/eslint-patch": "~1.1.4",
"@internal/ts-config": "0.0.1",
"@internal/bundler": "0.0.1",
"@internal/eslint-config": "0.0.1"
},
"scripts": {
"clean": "rimraf es lib dist build *.tsbuildinfo",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build": "npm-run-all clean --parallel build:esm build:cjs"
}
}

@@ -1,5 +0,6 @@

# 推荐模块接口
## 如何使用
# Chart Advisor
## How to use
```

@@ -9,51 +10,51 @@ chartAdvisor(originDataset: DataItem[], dimensionList:Field[], measureList:Field[], aliasMap: AliasMap)

输入数据集和维度、指标字段信息,返回当前推荐的图表类型以及字段分配
Enter the dataset and the information about the dimension and indicator fields, it returns the current recommended chart type and field allocation.
## 示例
## Example
```
const dataset=[{ "210816110721021": "家具", "210816110721022": "14138" }, { "210816110721021": "办公用品", "210816110721022": "34611" }, { "210816110721021": "技术", "210816110721022": "12637" }]
const dataset=[{ "210816110721021": "Furniture", "210816110721021": "14138" }, { "210816110721021": "Office supplies", "210816110721021": "34611" }, { "210816110721021": "Technology", "210816110721021": "12637" }]
const dimensionList=[{ "uniqueId": 210816110721021, "type": "textual" }]
const dimensionList=[{ "uniqueId": 210816110721021, "type": "textual" }]
const measureList=[{ "uniqueId": 210816110721022, "type": "numerical" }]
const measureList=[{ "uniqueId": 210816110721022, "type": "numerical" }]
const aliasMap={ "210816110721021": "类别", "210816110721022": "数量" }
const aliasMap={ "210816110721021": "Category", "210816110721022": "Number" }
const result = advisor.calAdvisedChart(dataset, dimensionList, measureList, aliasMap)
const result = advisor.calAdvisedChart(dataset, dimensionList, measureList, aliasMap)
console.log(result)
console.log(result)
```
以上代码输出为:
The output of the above code is:
```
{
chartType: 'column',
cell: [
{
x: ['210816110721021'],
y: ['210816110721022'],
row: [],
column: [],
color: [],
size: [],
angle: []
}
],
colorItems: [],
dataset: [[[[{"210816110721021":"家具","210816110721022":"14138"},{"210816110721021":"办公用品","210816110721022":"34611"},{"210816110721021":"技术","210816110721022":"12637"}]]]],
aliasMap: { '210816110721021': '类别', '210816110721022': '数量' }
chartType: 'column',
cell: [
{
x: ['210816110721021'],
y: ['210816110721022'],
row: [],
column: [],
color: [],
size: [],
angle: []
}
],
colorItems: [],
dataset: [[[[{"210816110721021":"Furniture","210816110721022":"14138"},{"210816110721021":"Office supplies","210816110721022":"34611"},{"210816110721021":"Technology","210816110721022":"12637"}]]]],
aliasMap: { '210816110721021': 'Category', '210816110721022': 'Number' }
}
```
以上数据可直接用于生成 vizData
The above data can be used directly to generate vizData.
最后生成的图表为:
The final generated chart is:
![](exampleChart.png)
## 参数说明:
## Parameter explanation:
originDataset: 原始的数据集,是一个 list,里面每个元素是 DataItem,代表一行数据,格式为{uniqueID1: value1, uniqueID2: value2, ...},其中 uniqueID 为字段的 id,value 为该行数据在该字段上的值
originDataset: The original data set, which is a list, each element is a DataItem, representing a row of data, the format is {uniqueID1: value1, uniqueID2: value2, ...}, where uniqueID is the id of the field, value is the value of this row data in that field.

@@ -66,91 +67,90 @@ ```

dimensionList: 维度信息集合,是一个 list,里面每个元素是 Field
measureList:指标信息集合,是一个 list,里面每个元素是 Field
dimensionList: Collection of dimension information, which is a list, each element is a Field.
measureList: The collection of indicator information, which is list, each element is a Field.
```
type Field={
uniqueId: number; //该字段的id
type: string; //该字段的类型(number,string,date)
uniqueId: number; //id of the field
type: string; //type of the field (number, string, date)
}
```
alisMap: 字段别名表,与 vizData 中的 aliasMap 一致
alisMap: Field alias table, consistent with the aliasMap in vizData.
```
type AliasMap = {
[key: number]: string;
[key: number]: string;
};
```
## 返回值:
## Return value:
返回 AdviseResult。目前支持的图表类型列在了 ChartType 中
Returns AdviseResult. The currently supported chart types are listed in ChartType.
```
type AdviseResult={
chartType: ChartType; //vizData中的chartType
cell:Cell; //vizData中的cell,
colorItems:[] //vizData中的colorItems
dataset: DataItem[]; //处理后的dataset,用于生成vizData
aliasMap: AliasMap; //处理后的字段别名表,用于生成vizData
chartType: ChartType; //chartType in vizData
cell:Cell; //cell in vizData,
colorItems:[] //colorItems in vizData
dataset: DataItem[]; //The processed dataset used to generate vizData
aliasMap: AliasMap; //The processed field alias table used to generate vizData
}
```
各类型说明:
Explanation of each type:
```
enum ChartType {
/** 表格 */
TABLE = 'table',
/** Table */
TABLE = 'table',
/** 柱状图 */
COLUMN = 'column',
/** 百分比柱状图 */
COLUMN_PERCENT = 'column_percent',
/** 并列柱状图 */
COLUMN_PARALLEL = 'column_parallel',
/** Bar chart */
COLUMN = 'column',
/** Percentage Bar chart */
COLUMN_PERCENT = 'column_percent',
/** Parallel Bar chart */
COLUMN_PARALLEL = 'column_parallel',
/** 折线图 */
LINE = 'line',
/** Line chart */
LINE = 'line',
/** 饼图 */
PIE = 'pie',
/** Pie chart */
PIE = 'pie',
/** 散点图 */
SCATTER = 'scatter',
/** Scatter plot */
SCATTER = 'scatter',
/** 组合柱状图 */
COMBINECOLUMN = 'combineColumn', //多个柱状图组成的组合图
/** Combined Bar chart */
COMBINECOLUMN = 'combineColumn', //combined chart composed of multiple bar charts
/** 组合z折线图 */
COMBINELINE = 'combineLine', //多个折线图组成的组合图
/** Combined z line chart */
COMBINELINE = 'combineLine', //combined chart composed of multiple line charts
/** 指标卡 */
MEASURE_CARD = 'measure_card',
/** Measure card */
MEASURE_CARD = 'measure_card',
/** 词云 */
WORD_CLOUD = 'word_cloud',
/** Word cloud */
WORD_CLOUD = 'word_cloud',
}
interface Cell {
column?: UniqueId[];
row?: UniqueId[];
x?: UniqueId[];
y?: UniqueId[];
group?: UniqueId[];
color?: UniqueId[];
size?: UniqueId[];
shape?: UniqueId[];
angle?: UniqueId[];
radius?: UniqueId[];
text?: UniqueId[];
value?: UniqueId[];
tooltip?: UniqueId[];
column?: UniqueId[];
row?: UniqueId[];
x?: UniqueId[];
y?: UniqueId[];
group?: UniqueId[];
color?: UniqueId[];
size?: UniqueId[];
shape?: UniqueId[];
angle?: UniqueId[];
radius?: UniqueId[];
text?: UniqueId[];
value?: UniqueId[];
tooltip?: UniqueId[];
// 维度展开的信息(笛卡尔积)
cartesianInfo?: CartesianInfo;
// 指标展开的信息(指标平坦化)
foldInfo?: FoldInfo;
// Dimension expansion information (Cartesian product)
cartesianInfo?: CartesianInfo;
// Indicator expansion information (Indicator flattening)
foldInfo?: FoldInfo;
}
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc