chart-series.ts 6.1 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
import { ChartDataSetField } from './chart-dataset-field';

/**
 * 图表序列模型
 *
 * @export
 * @class ChartSeries
 */
export class ChartSeries {

    /**
     * 序列类型
     *
     * @type {string}
     * @memberof ChartSeries
     */
    public type: string = '';

    /**
     * 图表对象
     *
     * @type {*}
     * @memberof ChartSeries
     */
    public chart: any = null;

    /**
     * 序列名称
     *
     * @type {string}
     * @memberof ChartSeries
     */
    public name: string = '';

    /**
     * 序列标题
     *
     * @type {string}
     * @memberof ChartSeries
     */
    public caption: string = '';

    /**
     * 序列标识属性
     *
     * @type {string}
     * @memberof ChartSeries
     */
    public seriesIdField: string = '';

    /**
     * 序列名称属性
     *
     * @type {string}
     * @memberof ChartSeries
     */
    public seriesNameField: string = '';

    /**
     * 序列标识名称键值对
     *
     * @type {any}
     * @memberof ChartSeries
     */
    public seriesMap:any = null;

    /**
     * 对象索引
     *
     * @type {number}
     * @memberof ChartSeries
     */
    public index: number = 0;

    /**
     * 序列映射数据
     *
     * @type {*}
     * @memberof ChartSeries
     */
    public dataSet: any = [];

    /**
     * 预置配置
     *
     * @type {number}
     * @memberof ChartSeries
     */
    public ecxObject:any;

    /**
     * 用户自定义配置
     *
     * @type {number}
     * @memberof ChartSeries
     */
    public ecObject:any;

    /**
     * 序列索引
     *
     * @type {number}
     * @memberof ChartSeries
     */
    public seriesIndex:number = 0;

    /**
     * 数据集属性集合
     *
     * @type {Array<ChartDataSetField>}
     * @memberof ChartSeries
     */
    public dataSetFields:Array<ChartDataSetField> = [];

    /**
     * 取值方式
     * 'column':默认,dataset 的列对应于系列,从而 dataset 中每一列是一个维度(dimension)
     * 'row':dataset 的行对应于系列,从而 dataset 中每一行是一个维度(dimension
     *
     * @type {string}
     * @memberof ChartSeries
     */
    public seriesLayoutBy:string = "column";

    /**
     * Creates an instance of ChartSeries.
     * ChartSeries 实例
     * 
     * @param {*} [opts={}]
     * @memberof ChartSeries
     */
    constructor(opts: any = {}) {
        this.type = !Object.is(opts.type, '') ? opts.type : '';
        this.name = !Object.is(opts.name, '') ? opts.name : '';
        this.caption = !Object.is(opts.caption, '') ? opts.caption : '';
        this.seriesIdField = (opts.seriesIdField && !Object.is(opts.seriesIdField, '')) ? opts.seriesIdField : (opts.seriesNameField && !Object.is(opts.seriesNameField, '')) ? opts.seriesNameField : '';
        this.seriesNameField = !Object.is(opts.seriesNameField, '') ? opts.seriesNameField : '';
        this.index = this.index ? this.index : 0;
        this.chart = opts.chart ? opts.chart : null;
        this.dataSet = opts.dataSet ? opts.dataSet : [];
        this.ecxObject = opts.ecxObject ? opts.ecxObject : null;
        this.ecObject = opts.ecObject ? opts.ecObject : null;
        this.seriesLayoutBy = opts.seriesLayoutBy ? opts.seriesLayoutBy:"column";
        this.dataSetFields = opts.dataSetFields ? opts.dataSetFields:[];
        this.seriesMap = opts.seriesMap ? opts.seriesMap:null;
        this.seriesIndex = opts.seriesIndex? opts.seriesIndex:0;
    }

    /**
     * 设置序列类型
     *
     * @param {string} state
     * @memberof ChartSeries
     */
    public setType(state: string): void {
        this.type = state;
    }

    /**
     * 设置序列名称
     *
     * @param {string} state
     * @memberof ChartSeries
     */
    public setCaption(state: string): void {
        this.caption = state;
    }

    /**
     * 设置序列标题
     *
     * @param {string} state
     * @memberof ChartSeries
     */
    public setName(state: string): void {
        this.name = state;
    }

    /**
     * 设置数据集
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setDataSet(state: any): void {
        this.dataSet = state;
    }

    /**
     * 设置序列标识名称键值对
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setSeriesMap(state: any): void {
        this.seriesMap = state;
    }

    /**
     * 设置序列映射的图表
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setChart(state: any): void {
        this.chart = state;
    }

    /**
     * 设置序列标识属性
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setSeriesIdField(state: any): void {
        this.seriesIdField = state;
    }

    /**
     * 设置序列名称属性
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setSeriesNameField(state: any): void {
        this.seriesNameField = state;
    }

    /**
     * 设置对象索引
     *
     * @param {number} state
     * @memberof ChartSeries
     */
    public setIndex(state: number): void {
        this.index = state;
    }

    /**
     * 设置预置配置
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setECXObject(state: any): void {
        this.ecxObject = state;
    }

    /**
     * 设置用户自定义参数
     *
     * @param {*} state
     * @memberof ChartSeries
     */
    public setECObject(state: any): void {
        this.ecObject = state;
    }

    /**
     * 设置取值方式
     *
     * @param {string} state
     * @memberof ChartSeries
     */
    public setSeriesLayoutBy(state: string): void {
        this.seriesLayoutBy = state;
    }

    /**
     * 设置数据集属性集合
     *
     * @param {Array<ChartDataSetField>} state
     * @memberof ChartSeries
     */
    public setDataSetFields(state: Array<ChartDataSetField>): void {
        this.dataSetFields = state;
    }

    /**
     * 设置序列索引
     *
     * @param {number} state
     * @memberof ChartSeries
     */
    public setSeriesIndex(state: number): void {
        this.seriesIndex = state;
    }
}