/** * @typedef {object} DockService * @property {string} type The type of the service. Can be either 'major-minor' or 'x-y'. * @property {object} config The configuration that was used to create the service. * @property {boolean|object} config.logicalSize Logical size of the chart. * @property {boolean} config.rtl If using RTL. * @property {object} meta Resolved meta of the service. * @property {object} meta.chart Resolved chart meta of the service. * @property {object} meta.chart.orientation Chart orientation. Only available for type 'major-minor'. * @property {object} meta.chart.size Chart size. * @property {object} meta.chart.mode Chart mode. Can be 'FULL', 'MEDIUM', 'SMALL', 'XSMALL' or 'SPARK'. * @property {object} meta.major Resolved major axis meta of the service. Only available for type 'major-minor'. * @property {string} meta.major.orientation Orientation of the major axis. Can be either 'horizontal' or 'vertical'. * @property {string} meta.major.dock Dock of the major axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {string} meta.major.opposite Opposite value of the dock of the major axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {number} meta.major.size Width of the major axis if axis is horizontal, height if vertical. * @property {object} meta.minor Resolved major axis meta of the service. Only available for type 'major-minor'. * @property {string} meta.minor.orientation Orientation of the minor axis. * @property {string} meta.minor.dock Dock of the minor axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {string} meta.minor.opposite Opposite value of the dock of the minor axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {string} meta.minor.start Where the minor axis starts. Can be 'bottom', 'top', 'left' or 'right'. * @property {string} meta.minor.end Where the minor axis ends. Can be 'bottom', 'top', 'left' or 'right'. * @property {number} meta.minor.size Width of the minor axis if axis is horizontal, height if vertical. * @property {object} meta.x Resolved x-axis meta of the service. Only available for type 'x-y'. * @property {string} meta.x.dock Dock of the x-axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {string} meta.x.opposite Opposite value of the dock of the x-axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {number} meta.x.size Width of the x-axis if the axis is horizontal, height if vertical. * @property {object} meta.y Resolved y-axis meta of the service. Only available for type 'x-y'. * @property {object} meta.y Resolved x-axis meta of the service. Only available for type 'x-y'. * @property {string} meta.y.dock Dock of the y-axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {string} meta.y.opposite Opposite value of the dock of the y-axis. Can be 'bottom', 'top', 'left' or 'right'. * @property {number} meta.y.size Width of the y-axis if the axis is horizontal, height if vertical. * @property {function(object):undefined} update Updates the dock-service with a new size. */ /** * Creates a dock-service. * * @param {object} args Arguments object. * @param {object} args.chart PicassoJS chart instance. * @param {object} args.layoutService Layout-service instance. * @param {object} args.config Configuration object with settings relevant to all dock-service types. * @param {boolean|object} args.config.logicalSize Logical size of the chart. Should be 'false' if not used, otherwise an object with 'width' and 'height'. * @param {boolean} args.config.rtl If should use RTL. * @param {object} args.typeConfig Configuration object with settings relevant only to specified dock-service type. * @param {string} args.typeConfig.type Type of the docks-service. Can be either 'major-minor' or 'x-y'. * @param {string} args.typeConfig.fallback Fallback value for chart orientation. Can be either 'horizontal' or 'vertical'. Only relevant for type 'major-minor'. * @param {boolean} args.typeConfig.invert If the major axis orientation should be inverted from the chart orientation. Only relevant for type 'major-minor'. * @param {object[]} args.typeConfig.measureAxes Configuration for additional measure axes. Only relevant for type 'major-minor'. * * @returns {DockService} The created dock-service. * * @example * * const service = createDockService({ * chart, * layoutService, * config: { * logicalSize, * rtl, * }, * typeConfig: { * type: 'major-minor', * fallback: 'horizontal', * invert: false, * }, * }); * * console.log(service.meta); * // => * { * chart: { * orientation: 'horizontal', * size: { width: 800, height: 600 }, * mode: 'FULL', * }, * major: { * orientation: 'horizontal', * dock: 'bottom', * opposite: 'top', * size: 800, * }, * minor: { * orientation: 'vertical', * dock: 'left', * opposite: 'right', * start: 'bottom', * end: 'top', * size: 600, * }, * } * * const service = createDockService({ * chart, * layoutService, * config: { * logicalSize, * rtl, * }, * typeConfig: { * type: 'x-y', * }, * }); * * console.log(service.meta); * // => * { * chart: { * size: { width: 800, height: 600 }, * mode: 'FULL', * }, * x: { * dock: 'bottom', * opposite: 'top', * size: 800, * }, * y: { * dock: 'left', * opposite: 'right', * size: 600, * }, * } */ export default function createDockService({ chart, layoutService, config, typeConfig }: { chart: object; layoutService: object; config: { logicalSize: boolean | object; rtl: boolean; }; typeConfig: { type: string; fallback: string; invert: boolean; measureAxes: object[]; }; }): DockService; export type DockService = { /** * The type of the service. Can be either 'major-minor' or 'x-y'. */ type: string; /** * The configuration that was used to create the service. */ config: { logicalSize: boolean | object; rtl: boolean; }; /** * Resolved meta of the service. */ meta: { chart: { orientation: object; size: object; mode: object; }; major: { orientation: string; dock: string; opposite: string; size: number; }; minor: { orientation: string; dock: string; opposite: string; start: string; end: string; size: number; }; x: { dock: string; opposite: string; size: number; }; y: object; y: object; }; /** * Updates the dock-service with a new size. */ update: (arg0: object) => undefined; };