数据源

准备原始数据

1份原始模拟数据源的链接可在此下载:点我 使用sqliteBrower打开db.

元数据:

dataSetId:09378648cb5e4365be6f1ac908c1060b

截图1 各列字段代表的意义:

year:年
month:月
LVL1CHANNELNAMEC:销售渠道
PROVCOMNAME:分公司
MANAGECOMNAME:支部
DIMEN1NAME:险种
yujiguimobaofei:预收规模保费
chengbaoguimobaofei:承保规模保费
chengbaobiaozhunbaofei:承保标准保费
biaobaoyusuan:标保预算

定义多维结构

将多维数据源的结构以json定义:


[
        {
            "dataSetId": "01a50a94-5909-435b-9dd7-490bf989e84e",
            "dimensions": [
                {
                    "granularities": [
                        {
                            "index": -1,
                            "key": "year",
                            "selection": {
                                "selectionType": "NXSelectionLabelEqual",
                                "selectionValue": "2015"
                            },
                            "title": "年"
                        },
                        {
                            "key": "month",
                            "title": "月"
                        }
                    ],
                    "key": "Dimension_1",
                    "title": "时间"
                },
                {
                    "granularities": [
                        {
                            "key": "LVL1CHANNELNAMEC",
                            "selection": {
                                "selectionType": "NXSelectionLabelEqual",
                                "selectionValue": "团险"
                            },
                            "title": "销售渠道"
                        }
                    ],
                    "key": "Dimension_2",
                    "title": "渠道"
                },
                {
                    "granularities": [
                        {
                            "key": "PROVCOMNAME",
                            "selection": {
                                "selectionType": "NXSelectionLabelEqual",
                                "selectionValue": "浙江"
                            },
                            "title": "分公司"
                        },
                        {
                            "key": "MANAGECOMNAME",
                            "selection": {
                                "selectionType": "NXSelectionLabelEqual",
                                "selectionValue": "杭州中支"
                            },
                            "title": "支部"
                        }
                    ],
                    "key": "Dimension_3",
                    "title": "分支"
                },
                {
                    "granularities": [
                        {
                            "key": "DIMEN1NAME",
                            "selection": {
                                "selectionType": "NXSelectionLabelEqual",
                                "selectionValue": "人寿险"
                            },
                            "title": "险种"
                        }
                    ],
                    "key": "Dimension_4",
                    "title": "险种分类"
                }
            ],
            "measures": [
                {
                    "key": "yujiguimobaofei",
                    "title": "预收规模保费"
                },
                {
                    "key": "chengbaoguimobaofei",
                    "title": "承保规模保费"
                },
                {
                    "key": "chengbaobiaozhunbaofei",
                    "title": "承保标准保费"
                },
                {
                    "key": "biaobaoyusuan",
                    "title": "标保预算"
                }
            ]
        }
    ]

维粒度设定解析
index:程序会自动根据该属性值大小来将图表上所有的可见粒度进行排序。index值越小,越排在前面。例如,当前年粒度的index最小为-1,则年粒度排在所有可见粒度链的最前面。
selection:用户可以根据需要手动配置某粒度选择的数据。selectionType表示选择数据的类型。可选项有NXSelectionLabelEqual,NXSelectionFirst(选中第一个数据项),NXSelectionLast(选中最后一个数据项),NXSelectionSpecificIndex(选中指定index的数据项)。如果选择了NXSelectionLabelEqual,还需要设置selectionValueselectionValue表示默认选择的数据项。例如,本例中年粒度默认选择的数据项是2015年。

使用服务器生成多维数据db

将上面的json转化为NXCubeStructure,并生成多层级的sqlitedb.此处源数据从sqlite里读的,因此使用NXProducerSQLiteDataSource. 若源数据从mysql,oracle读的,使用相应的NXProducerMysqlDataSource,NXProducerOracleDataSource。

NXCubeStructure cube=NXCubeStructure.fill("json structure string abrove"); NXProducerSQLiteDataSource productor = new NXProducerSQLiteDataSource(){ @Override public String getTargetDatabaseFolderPath() { return "db file generate path folder"; } }; productor.createCube("datasetid", cube.getDataSetId(), cube.getDimensions(), cube.getMeasures(), cube.getEncrypt());

接下来需要定义图表配置文件。 点我跳转

results matching ""

    No results matching ""