Members
__assign
- Source:
Datart
Copyright 2021
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Methods
getColumnRenderName(fieldopt) → {string}
- Source:
[中文] 获取字段的图表显示名称
[EN] Get data field render name by alias, colName and aggregate
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
field |
ChartDataSectionField |
<optional> |
Returns:
- Type
- string
getDefaultThemeColor() → {*}
- Source:
[中文] 获取系统默认颜色
[EN] Gets an array of default colors
Example
const colorList = getDefaultThemeColor();
console.log(colorList); // ["#298ffe","#dae9ff","#fe705a","#ffdcdc","#751adb","#8663d7","#15AD31","#FAD414","#E62412"]
Returns:
default color array
- Type
- *
getSettingValue(configs, path, targetKey) → {*}
- Source:
- Deprecated:
- This function will be removed in next versiion, please use @see getStyles instread
[中文] 使用路径语法获取配置信息,此方法已过时,请参考方法getStyles
[EN] Get setting config info by value path, please use getStyles instread
Parameters:
Name | Type | Description |
---|---|---|
configs |
Array.<ChartStyleConfig> | |
path |
string | |
targetKey |
string |
Returns:
- Type
- *
getStyles(configs, parentKeyPaths, childTargetKeys) → {*}
- Source:
[中文] 通过数组路径语法,获取对应的配置的值集合
[EN] Get config style values
Example
const styleConfigs = [
{
key: 'label',
rows: [
{ key: 'color', value: 'red' },
{ key: 'font', value: 'sans-serif' },
],
},
];
const [color, font] = getStyles(styleConfigs, ['label'], ['color', 'font']);
console.log(color); // red
console.log(font); // sans-serif
Parameters:
Name | Type | Description |
---|---|---|
configs |
Array.<ChartStyleConfig> | required |
parentKeyPaths |
Array.<string> | required |
childTargetKeys |
Array.<string> | required |
Returns:
array of child keys with the same order
- Type
- *
getStyleValue(styleConfigs, paths) → {*}
- Source:
- Deprecated:
- This function will be removed in next versiion, please use @see getStyles instread
[中文] 使用路径语法获取配置信息,此方法已过时,请参考方法getStyles
[EN] Get config info by value path, please use getStyles instread
Parameters:
Name | Type | Description |
---|---|---|
styleConfigs |
Array.<ChartStyleConfig> | |
paths |
Array.<string> |
Returns:
{*}
- Type
- *
getStyleValueByGroup(styles, groupPath, childPath) → {*}
- Source:
- Deprecated:
- This function will be removed in next versiion, please use @see getStyles instread
[中文] 使用路径语法获取配置信息,此方法已过时,请参考方法getStyles
[EN] Get setting config info by value path, please use getStyles instread
Parameters:
Name | Type | Description |
---|---|---|
styles |
Array.<ChartStyleConfig> | |
groupPath |
string | |
childPath |
string |
Returns:
- Type
- *
getValue(configs, keyPaths, targetKeyopt) → {*}
- Source:
[中文] 通过数组路径语法,获取对应的配置信息
[EN] Get style config value base funtion with default target key
Example
const styleConfigs = [
{
key: 'label',
rows: [
{ key: 'color', value: 'red' },
{ key: 'font', value: 'sans-serif' },
],
},
];
const colorValue = getValue(styleConfigs, ['label', 'color']);
console.log(colorValue); // red
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
configs |
Array.<ChartStyleConfig> | |||
keyPaths |
Array.<string> | |||
targetKey |
string |
<optional> |
'value'
|
Returns:
- Type
- *
isMatchRequirement(meta, config) → {boolean}
- Source:
[中文] 是否满足当前meta中标识的限制要求,以满足图表绘制
[EN] Check if current config with requried fields match the chart basic requirement of meta info.
Example
const meta = {
requirements: [
{
group: [1, 999],
aggregate: [1, 999],
},
],
};
const config = {
datas: [
{
type: 'group',
required: true,
rows: [
{
colName: 'category',
},
],
},
{
type: 'aggregate',
required: true,
rows: [
{
colName: 'amount',
},
],
},
],
};
const isMatch = isMatchRequirement(meta, config);
console.log(isMatch); // true;
Parameters:
Name | Type | Description |
---|---|---|
meta |
ChartMetadata | |
config |
ChartConfig |
Returns:
- Type
- boolean
toFormattedValue(valueopt, formatopt) → {*}
- Source:
[中文] 获取格式聚合数据
[EN] Gets format aggregate data
Example
const format = {
percentage: {
decimalPlaces: 2,
},
type: "percentage",
}
const formattedData = toFormattedValue('1', format);
console.log(formattedData); // '100.00%';
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
number | string |
<optional> |
|
format |
IFieldFormatConfig |
<optional> |
Returns:
- Type
- *
transformToDataSet(datasopt, metasopt, sortedConfigsopt) → {*}
- Source:
[中文] 将服务端返回数据转换为ChartDataSet模型
[EN] Create ChartDataSet Model with sorted values
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datas |
Array.<Array.<T>> |
<optional> |
|
metas |
Array.<ChartDatasetMeta> |
<optional> |
|
sortedConfigs |
Array.<ChartDataConfig> |
<optional> |
Returns:
{IChartDataSet}
- Type
- *
transformToObjectArray(columnsopt, metasopt) → {*}
- Source:
- Deprecated:
- shoule use DataSet model, @see transformToDataSet
Support:
1. Case Insensitive to get value
2. More util helper
Example
const columns = [
['r1-c1-v', 'r1-c2-v'],
['r2-c1-v', 'r2-c2-v'],
];
const metas = [{ name: 'name' }, { name: 'age' }];
const datas = transformToObjectArray(columns, metas);
console.log(datas); // [{"name":"r1-c1-v","age":"r1-c2-v2"},{"name":"r2-c1-v","age":"r2-c2-v"}]
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
columns |
Array.<Array.<string>> |
<optional> |
|
metas |
Array.<ChartDatasetMeta> |
<optional> |
Returns:
- Type
- *
valueFormatter(configopt, valueopt) → {string}
- Source:
[中文] 获取字段的Tooltip显示名称和内容
[EN] Get chart render string with field name and value
Example
const config = {
aggregate: "SUM"
colName: 'name',
type: 'STRING',
category: 'field',
uid: '123456',
}
const formatValue = valueFormatter(config, '示例');
console.log(formatValue) // SUM(name): 示例
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
ChartDataSectionField |
<optional> |
|
value |
number |
<optional> |
Returns:
- Type
- string