src/AxesTypes.ts

   1/**

   2 * @module Axes

   3 */

   4

   5 /** */

   6import { VisibleCfg, 

   7         LabelCfg }         from './Graph';

   8import { Scale }            from './Scale';

   9import { Domain }   from 'hsdatab';

  10

  11/** scale type: {@link Axes.Axes.type Axes.type}.`linear` | `log` | `date` | `index` | `percent` | `ordinal` | `nominal` */

  12export type AxisType = string;

  13

  14/** Set of `Scales` for x- and y-axis*/

  15export interface XYScale { x: Scale; y:Scale; }

  16

  17/** Set of `Scales` for primary and secondary x- and y-axes. */

  18export interface Scales {

  19    primary:   XYScale;

  20    secondary: XYScale;

  21}

  22

  23/**

  24 * Configures the scale type and domain boundaries `[min, max]` to be displayed.

  25 */

  26export interface ScaleCfg {

  27    /** scale type: {@link Axes.Axes.type Axes.type}.`linear` | `log` | `date` | `index` | `percent` | `ordinal` | `nominal` */

  28    type: AxisType;

  29

  30    /**

  31     * Configures the domain boundaries `[min, max]` to be displayed.

  32     * For ordinal values these are the numeric min and max values of the domain,

  33     * or the special values 

  34     * - `auto`: determines the domain automatically from the data. Boundaries are set 'loosely' 

  35     *   so that the major tick mark below and above the data range are displayed as well.

  36     * - `tight`: same as `auto`, except the domain covers exactly the values contained in data. 

  37     * Both values can be set indepoendently for `min` and `max`

  38     */

  39    domain: Domain;

  40}

  41

  42export interface Ticks {

  43    major: TickDefs;

  44    minor: TickDefs;

  45}

  46

  47export interface TickLabel {

  48    pos:number;     // domain value, at which to print tick label

  49    text:string;    // string to print at labelPos

  50}

  51

  52export interface TickDefs {

  53    marks:  number[];   // domain values where to draw a mark

  54    labels: TickLabel[];// 

  55};

  56

  57/** Defines configurable settings for tick marks */

  58export interface MarkCfg extends VisibleCfg {

  59    /** length in viewBox coordinates */

  60    length:  number; 

  61}

  62

  63/** Defines configurable settings for tick marks and labels per axis */

  64export interface TickStruct {

  65    marks:  MarkCfg;

  66    labels: LabelCfg;

  67    labelFmt: string;

  68}

  69

  70/** Defines configurable settings for major and minor ticks (marks and labels) */

  71export interface TicksCfg {

  72    major:  TickStruct;

  73    minor:  TickStruct;

  74}

  75

  76/** Defines configurable settings. */

  77export interface AxesConfig  {

  78    primary:   { x: AxisCfg; y: AxisCfg; };

  79    secondary: { x: AxisCfg; y: AxisCfg; };

  80}

  81

  82/** Defines configurable settings per axis */

  83export interface AxisCfg extends VisibleCfg{

  84    /** configures the axis title */  

  85    title:      LabelCfg;

  86

  87    /** axis crossing in domain: 'min''max', or domain value */

  88    crossesAt:  number|string; 

  89

  90    /** axis type  */

  91    scale: ScaleCfg;

  92

  93    /** configures the major and minor ticks */

  94    ticks: TicksCfg;

  95}

  96