Mana Dashboard Api 主要由如下Config, DataSource和Record组成,Config代表用户配置, DataSource代表数据源,Record代表数据源中的记录。
1、config_name, 配置名称,对应界面上的配置编号。
config_name.
配置名称。
title.
配置标题,与config_name相同。
get_title()
取得标题,获取内容与title和config_name相同。
raw_config.
原如配置数据。
data_source.
数据源,一个配置可能对应一个数据源,也可能对应多个数据源。
get_config_id()
取得配置维一编号,此处id为系统表的维一id。
get_ref_config_id()
系统内有多种配置,每种配置种结构都不相同,此处取得指向的真实配置id。此函数仅为内部使用。
has_data_source()
是否有数据源,一种情况下是没有配置数据源,一种是本身不需要数据源。
get_data_source(index)
取得数据源,由于可能存在多个数据源,默认为0,也就是默认获取第一个数据源,返回datasource对象。get_data_source_count()
取得数据源数量。
get_first_data_source()
取得第一个数据源。
get_styles()
取得自定义样式内容。
get_scripts()
取得脚本内容。
get_template()
取得自定义模板内容。
get_demo_template()
取得demo模板,用于没有数据源或是数据源不合法时显示。
get_data_source_type()
取得数据源类型,目前支持如下数据源格式
- model 通过模型配置。
- sql 通过sql配置。
- method 调用模型方法配置。
- code 通过Python代码配置。
Datasource代表了数据源对象。
_valid.
数据源是否合法,此为后端进行判断,如通过模型配置时,没有设置分组或是字段等,或者通过sql配置,但没有sql语句。
confg.
数据配置对象。
index.
数据源索引。
data_source_info.
数据源信息。
records.
数据记录,内容为record对象。
hiddenFields.
隐藏字段,对应数据配置界面字段管理中的字段隐藏。
raw_data_source.
原始数据源信息。
previous_datas.
上一周期数据源对象。
selections.
选项数据信息,只针对数据源为model时有效,用于保存。
get_previous_data.
是否获取上一周期数据,需要配置时间范围。
get_previous_data_source.
取得上一周期数据源信息。
is_valid()
是否合法。
init_data_records()
内部方法,初始化数据记录。
_init_previous_data_source()
内部方法,初始化上一周期数据记录。
_init_raw_fields_cache()
初始化字段信息缓存。
is_custom()
数据结果类型是否为自定义,数据结果类型分为标准类型和自定义类型,标准类型数解析为数据记录,自定义类型则不会。
get_domain()
取得domain
get_context()
取得context
is_get_data_from_model()
是否从模型取得数据
is_get_data_from_sql()
是否从sql取得数据。
get_raw_datas()
取得原始数据。
get_records()
取得所有数据记录。
get_record(index)
取得索引为index的数据记录。
get_records_count()
取得数据记录总数。
get_raw_fields()
取得所有字段信息。
get_raw_field(name)
取得名称为name的字段信息。
get_data_source_type()
取得数据源类型。
get_data_source_info()
取得数据源信息。
fields_as_category()
是否将字段名称作为类别使用,用于只有数据,没有提供字段信息的情况。数据格式如下。
[
['Product', 'Sales', 'Price', 'Year'],
['Cake', 123, 32, 2011],
['Cereal', 231, 14, 2011],
['Tofu', 235, 5, 2011],
['Dumpling', 341, 25, 2011],
['Biscuit', 122, 29, 2011],
['Cake', 143, 30, 2012],
['Cereal', 201, 19, 2012],
['Tofu', 255, 7, 2012],
['Dumpling', 241, 27, 2012],
['Biscuit', 102, 34, 2012],
['Cake', 153, 28, 2013],
['Cereal', 181, 21, 2013],
['Tofu', 395, 4, 2013],
['Dumpling', 281, 31, 2013],
['Biscuit', 92, 39, 2013],
['Cake', 223, 29, 2014],
['Cereal', 211, 17, 2014],
['Tofu', 345, 3, 2014],
['Dumpling', 211, 35, 2014],
['Biscuit', 72, 24, 2014]
]
has_previous_data()
是否获取上一周期数据。
has_group_by()
是否有分组。
has_multi_group_by()
是否有多个分组。
has_domain_field()
字段中是否有__domain字段。
get_first_group_by()
取得第一个排序字段。
has_multi_order_by()
是否有多个排序。
get_fields_info()
取得字段信息,只牟从模型获取数据有效。
get_group_by_infos()
取得分组信息。
get_title()
取得标题信息。
get_max_value(column_name)
取得列的最大值。
get_alias(column_name)
取得列的别名。
convert_to_alias(column_names)
将列名称转换为列名称。
get_category_fields()
取得分类信息。
get_hidden_fields()
取得隐藏字段信息。
is_hide_field(column_name)
取得隐藏字段信息。
get_categories()
取得类别。
get_category_values(category_name)
取得名称为category_name类别的所有值。
get_field_info_by_name(field_name)
通过名称取得字段信息。
get_group_by_names()
取得分组名称。
get_field_names()
取得字段名称。只针对从模型获取数据时有效,配置界面中取得的字段信息,而不是字段管理中的信息。
get_col_names()
取得列名称。
get_measures()
取得维度值。
get_aggregate_columns()
取得统计数据的所有列
get_first_aggregate_column_value()
取得第一个统计数据列的值。
format_name()
格式化名称。
is_selection(col_name)
字段是否为选项字段。
get_selection_val(col_name, key)、get_column_values(col_name, format = false)
取得选项的值。
get_col_values(col_name, formatter = null)
取得列的值,并进行格式化。
get_unique_col_values(col_name, formatter = null)
取得列的值并进行唯处理。
get_aggregate_value(col_name, aggregate_type)
取得列的统计值。统计类型有 sum、 avg、 max、 min、 count
get_cols_values(col_names)
取得某几个列的值。
get_col_value(row_index, col_name)
取得某行某列的值。
get_row_values(row_index)
取得某行的值。
get_group_by_name_values(
__group_by_name, measure_name, unique_category_values, category_name)
record_data
记录数据。
get_value(col_name)
取得某列的值。
get_col_names()
取得列名称。
values()
取得名称。