ggplotnim/ggplot_types

    Dark Mode
Search:
Group by:
Source   Edit  

two constants for count columns and previous valuesNOTE: all the following could be generated by a macro. But amount of code isn't enough to make that worthwhile.NOTE: the explicit generics are there to avoid code gen errors. LINK NIM-LANG ISSUE Essentially if missing() appears for two "same" (e.g. PossibleFloat) fields, but one of them is used, the other isn't, the second field is just uhhh, literally, missing

Types

AestheticError = object of CatchableError
Source   Edit  
Aesthetics = object
  x*: Option[Scale]
  xMin*: Option[Scale]
  xMax*: Option[Scale]
  y*: Option[Scale]
  yMin*: Option[Scale]
  yMax*: Option[Scale]
  fill*: Option[Scale]
  color*: Option[Scale]
  alpha*: Option[Scale]
  size*: Option[Scale]
  shape*: Option[Scale]
  width*: Option[Scale]
  height*: Option[Scale]
  text*: Option[Scale]
  yRidges*: Option[Scale]
  weight*: Option[Scale]
Source   Edit  
Annotation = object
  left*: Option[float]
  bottom*: Option[float]
  x*: Option[float]
  y*: Option[float]
  text*: string
  font*: Font
  rotate*: Option[float]
  backgroundColor*: Color
Source   Edit  
BinByKind = enum
  bbFull = "full", bbSubset = "subset"
Source   Edit  
BinPositionKind = enum
  bpNone = "none", bpCenter = "center", bpLeft = "left", bpRight = "right" ## `GgStyle` object is an `Option` wrapper around `ginger.Style`.
                                                                           ## This allows us to differentiate between user settings of styles
                                                                           ## and mappings. Settings take higher priority!
Source   Edit  
ColorScale = object
  name*: string
  colors*: seq[uint32]
Source   Edit  
ContinuousFormat = proc (x: float): string
Source   Edit  
DataKind = enum
  dkMapping = "mapping",    ## default for size / color: compute mapping based on
                             ## data *values* stored in the column
  dkSetting = "setting" ## default for scLinear / scTransformed. Treat data
                        ## in referenced column literally. x/y: data position,
                        ## size/color: literal size/color using column value
Source   Edit  
DateScale = object
  name*: string
  axKind*: AxisKind          ## which axis does it belong to?
  isTimestamp*: bool         ## is it a timestamp?
  breaks*: seq[float] ## timestamps to use as tick labels. Overrides `dateSpacing`. Forces
                      ## `dateAlgo` to `dtaCustomBreaks`.
  parseDate*: proc (s: string): DateTime ## possible parser for string columns
  formatString*: string      ## the string to format dates with
  dateSpacing*: Duration     ## required duration between two ticks
  dateAlgo*: DateTickAlgorithmKind ## See enum description above
  
Source   Edit  
DateTickAlgorithmKind = enum
  dtaFilter,                ## compute the date ticks by filtering to closest matches
  dtaAddDuration,           ## compute the date ticks by adding given duration to start time
  dtaCustomBreaks            ## use user given custom breaks (as unix timestamp)
Source   Edit  
DiscreteFormat = proc (x: Value): string
Source   Edit  
DiscreteKind = enum
  dcDiscrete, dcContinuous
Source   Edit  
Draw = object
  fname*: string
  width*: Option[float]
  height*: Option[float]
  texOptions*: TeXOptions
  backend*: BackendKind
Source   Edit  
Facet = object
  columns*: seq[string]
  sfKind*: ScaleFreeKind
Source   Edit  
FilledGeom = object
  geom*: Geom
  xCol*: string
  yCol*: string
  xScale*: ginger.Scale
  yScale*: ginger.Scale
  reversedX*: bool
  reversedY*: bool
  yieldData*: OrderedTable[Value, (GgStyle, seq[GgStyle], DataFrame)]
  case dcKindX*: DiscreteKind
  of dcDiscrete:
      xLabelSeq*: seq[Value]

  else:
    nil
  case dcKindY*: DiscreteKind
  of dcDiscrete:
      yLabelSeq*: seq[Value]

  else:
    nil
  numX*: int
  numY*: int
  case geomKind*: GeomKind
  of gkErrorBar:
      xMin*: Option[string]
      yMin*: Option[string]
      xMax*: Option[string]
      yMax*: Option[string]

  of gkTile, gkRaster:
      fillCol*: string
      fillDataScale*: ginger.Scale
      width*: Option[string]
      height*: Option[string]
      colorScale*: ColorScale

  of gkText:
      text*: string

  of gkHistogram:
      hdKind*: HistogramDrawingStyle

  else:
    nil
  
Source   Edit  
FilledScales = object
  xScale*: ginger.Scale
  yScale*: ginger.Scale
  reversedX*: bool
  reversedY*: bool
  discreteX*: bool
  discreteY*: bool
  geoms*: seq[FilledGeom]
  x*: MainAddScales
  y*: MainAddScales
  color*: MainAddScales
  fill*: MainAddScales
  alpha*: MainAddScales
  size*: MainAddScales
  shape*: MainAddScales
  xMin*: MainAddScales
  xMax*: MainAddScales
  yMin*: MainAddScales
  yMax*: MainAddScales
  width*: MainAddScales
  height*: MainAddScales
  text*: MainAddScales
  yRidges*: MainAddScales
  weight*: MainAddScales
  facets*: seq[Scale]
Source   Edit  
Geom = object
  gid*: uint16
  data*: Option[DataFrame]
  userStyle*: GgStyle
  position*: PositionKind
  aes*: Aesthetics
  binPosition*: BinPositionKind
  case kind*: GeomKind
  of gkHistogram:
      hdKind*: HistogramDrawingStyle

  else:
    nil
  case statKind*: StatKind
  of stBin:
      numBins*: int
      binWidth*: Option[float]
      binEdges*: Option[seq[float]]
      binBy*: BinByKind
      density*: bool ## if true will compute the density instead of counts in
                     ## each bin
    
  of stSmooth:
      span*: float           ## The window width we use to compute the smoothed output
      polyOrder*: int        ## Polynomial order to use for SVG filter
      methodKind*: SmoothMethodKind ## The method to use for smoothing (Savitzky-Golay, LM)
    
  else:
    nil
  
Source   Edit  
GeomKind = enum
  gkPoint, gkBar, gkHistogram, gkFreqPoly, gkTile, gkLine, gkErrorBar, gkText,
  gkRaster
Source   Edit  
GgPlot = object
  data*: DataFrame
  title*: string
  subTitle*: string
  aes*: Aesthetics
  facet*: Option[Facet]
  ridges*: Option[Ridges]
  geoms*: seq[Geom]
  annotations*: seq[Annotation]
  theme*: Theme
  backend*: BackendKind ## the backend to use. Determined automatically from filename and
                        ## possible options given to `ggsave`
  
Source   Edit  
GgStyle = object
  color*: Option[Color]
  size*: Option[float]
  lineType*: Option[LineType]
  lineWidth*: Option[float]
  fillColor*: Option[Color]
  marker*: Option[MarkerKind]
  errorBarKind*: Option[ErrorBarKind]
  alpha*: Option[float]
  font*: Option[Font]
Source   Edit  
HistogramDrawingStyle = enum
  hdBars = "bars", ## draws historams by drawing individual bars right next to
                    ## one another
  hdOutline = "line"         ## draws histograms by drawing the outline of all bars
Source   Edit  
JsonDummyDraw = object
  fname*: string
  width*: Option[float]
  height*: Option[float]
  backend*: BackendKind
Source   Edit  
MainAddScales = tuple[main: Option[Scale], more: seq[Scale]]
Source   Edit  
Missing = object
Source   Edit  
OutsideRangeKind = enum
  orkNone = "none", ## leave points where they are. Will be drawn somewhere outside the plot area,
                     ## unless so much larger than plot range that they don't fit canvas at all
  orkDrop = "drop",         ## remove points outside of plot range
  orkClip = "clip" ## clip outside points either to max value along the range or, if any is set
                   ## to the `*MarginRange`. That is the data range + the `*Margin`. See the
                   ## `*Margin` procs for more information.
Source   Edit  
PlotView = object
  filledScales*: FilledScales
  view*: Viewport
Source   Edit  
PositionKind = enum
  pkIdentity = "identity", pkStack = "stack", pkDodge = "dodge", pkFill = "fill"
Source   Edit  
PossibleColor = Missing | Color | uint32 | string | Option[Color]
Source   Edit  
PossibleErrorBar = Missing | ErrorBarKind | Option[ErrorBarKind]
Source   Edit  
PossibleFloat = Missing | SomeNumber | string | Option[float]
Source   Edit  
PossibleFont = Missing | Font | Option[Font]
Source   Edit  
PossibleLineType = Missing | LineType | Option[LineType]
Source   Edit  
PossibleMarker = Missing | MarkerKind | Option[MarkerKind]
Source   Edit  
Ridges = object
  col*: FormulaNode
  overlap*: float
  showTicks*: bool
  labelOrder*: Table[Value, int]
Source   Edit  
Scale = ref object
  col*: FormulaNode
  name*: string
  ids*: set[uint16]
  vKind*: ValueKind
  hasDiscreteness*: bool
  numTicks*: Option[int]
  breaks*: seq[float]
  dataKind*: DataKind
  case scKind*: ScaleKind
  of scLinearData, scTransformedData:
      axKind*: AxisKind
      reversed*: bool
      trans*: ScaleTransform
      invTrans*: ScaleTransform
      secondaryAxis*: Option[SecondaryAxis]
      dateScale*: Option[DateScale]

  of scColor, scFillColor:
      colorScale*: ColorScale

  of scSize:
      sizeRange*: tuple[low, high: float]

  of scAlpha:
      alphaRange*: tuple[low, high: float]

  else:
    nil
  case dcKind*: DiscreteKind
  of dcDiscrete:
      valueMap*: OrderedTable[Value, ScaleValue]
      labelSeq*: seq[Value]
      formatDiscreteLabel*: DiscreteFormat

  of dcContinuous:
      dataScale*: ginger.Scale
      mapData*: proc (df: DataFrame): seq[ScaleValue]
      formatContinuousLabel*: ContinuousFormat

  
Source   Edit  
ScaleFreeKind = enum
  sfFixed = "fixed", sfFreeX = "free_x", sfFreeY = "free_y", sfFree = "free"
Source   Edit  
ScaleKind = enum
  scLinearData, scTransformedData, scColor, scFillColor, scAlpha, scShape,
  scSize, scText
Source   Edit  
ScaleTransform = proc (v: float): float
Source   Edit  
ScaleValue = object
  case kind*: ScaleKind
  of scLinearData, scTransformedData:
      val*: Value

  of scFillColor, scColor:
      color*: Color

  of scAlpha:
      alpha*: float

  of scShape:
      marker*: MarkerKind
      lineType*: LineType

  of scSize:
      size*: float

  of scText:
    nil
  
Source   Edit  
SecondaryAxis = object
  name*: string
  axKind*: AxisKind
  case scKind*: ScaleKind
  of scLinearData:
      trans*: Option[FormulaNode]

  of scTransformedData:
      transFn*: ScaleTransform
      invTransFn*: ScaleTransform

  else:
    nil
  
Source   Edit  
SmoothMethodKind = enum
  smSVG = "svg",            ## Savitzky-Golay filter smoothing ("LOESS")
  smLM = "lm",              ## Perform a Levenberg-Marquardt fit
  smPoly = "poly"            ## Perform a polynomial fit of given order
Source   Edit  
StatKind = enum
  stIdentity = "identity", stCount = "count", stBin = "bin", stSmooth = "smooth"
Source   Edit  
StyleLabel = object
  style*: GgStyle
  label*: Value
Source   Edit  
Theme = object
  baseFontSize*: Option[float]
  fontSizeScale*: Option[float]
  labelFont*: Option[Font]
  titleFont*: Option[Font]
  subTitleFont*: Option[Font]
  tickLabelFont*: Option[Font]
  hideTicks*: Option[bool]
  hideTickLabels*: Option[bool]
  hideLabels*: Option[bool]
  title*: Option[string]
  subTitle*: Option[string]
  xLabel*: Option[string]
  xLabelMargin*: Option[float]
  xLabelSecondary*: Option[string]
  yLabel*: Option[string]
  yLabelMargin*: Option[float]
  yLabelSecondary*: Option[string]
  xTicksRotate*: Option[float]
  xTicksTextAlign*: Option[TextAlignKind]
  xTickLabelMargin*: Option[float]
  yTicksRotate*: Option[float]
  yTicksTextAlign*: Option[TextAlignKind]
  yTickLabelMargin*: Option[float]
  legendPosition*: Option[Coord]
  legendOrder*: Option[seq[int]]
  hideLegend*: Option[bool]
  canvasColor*: Option[Color]
  plotBackgroundColor*: Option[Color]
  gridLines*: Option[bool]
  gridLineColor*: Option[Color]
  gridLineWidth*: Option[float]
  minorGridLines*: Option[bool]
  minorGridLineWidth*: Option[float]
  onlyAxes*: Option[bool]
  discreteScaleMargin*: Option[Quantity]
  xRange*: Option[Scale]
  yRange*: Option[Scale]
  xMargin*: Option[float]
  xMarginRange*: ginger.Scale
  yMargin*: Option[float]
  yMarginRange*: ginger.Scale
  xOutsideRange*: Option[OutsideRangeKind]
  yOutsideRange*: Option[OutsideRangeKind]
  plotMarginLeft*: Option[Quantity]
  plotMarginRight*: Option[Quantity]
  plotMarginTop*: Option[Quantity]
  plotMarginBottom*: Option[Quantity]
  facetMargin*: Option[Quantity]
  preferRowsOverColumns*: Option[bool]
Source   Edit  
ThemeMarginLayout = object
  left*: Quantity
  right*: Quantity
  top*: Quantity
  bottom*: Quantity
  requiresLegend*: bool
Source   Edit  
VegaDraw = object
  fname*: string
  width*: Option[float]
  height*: Option[float]
  asPrettyJson*: bool
Source   Edit  
VegaTeX = object
  fname*: string
  width*: Option[float]
  height*: Option[float]
  texOptions*: TeXOptions
Source   Edit  

Consts

CountCol = "counts_GGPLOTNIM_INTERNAL"
Source   Edit  
PrevValsCol = "prevVals_GGPLOTNIM_INTERNAL"
Source   Edit  
SmoothValsCol = "smoothVals_GGPLOTNIM_INTERNAL"
Source   Edit  

Procs

proc `$`(aes: Aesthetics): string {....raises: [Exception], tags: [RootEffect].}
Source   Edit  
proc `$`(f: Facet): string {....raises: [], tags: [].}
Source   Edit  
proc `$`(g: Geom): string {....raises: [ValueError, Exception], tags: [RootEffect].}
Source   Edit  
proc `$`(p: GgPlot): string {....raises: [ValueError, KeyError, Exception],
                              tags: [RootEffect].}
Source   Edit  
proc `$`(s: Scale): string {....raises: [ValueError], tags: [].}
Source   Edit  
proc `==`(s1, s2: Scale): bool {....raises: [], tags: [].}
Source   Edit  
proc assignIdentityScalesGetStyle[C: PossibleColor; S: PossibleFloat;
                                  M: PossibleMarker; LT: PossibleLineType;
                                  LW: PossibleFloat; FC: PossibleColor;
                                  EB: PossibleErrorBar; A: PossibleFloat;
                                  F: PossibleFont](aes: var Aesthetics;
    pColor: C = missing(); pSize: S = missing(); pMarker: M = missing();
    pLineType: LT = missing(); pLineWidth: LW = missing();
    pFillColor: FC = missing(); pErrorBarKind: EB = missing();
    pAlpha: A = missing(); pFont: F = missing()): GgStyle
Modifies the given aes for all inputs that are interpreted as being a "column 'setting'" (i.e. DataKind = dkSetting). For every other case, fills the corresponding field of a GgStyle, which will be returned. Source   Edit  
proc hash(s: GgStyle): Hash {....raises: [], tags: [].}
Source   Edit  
proc hash(s: Style): Hash {....raises: [], tags: [].}
Source   Edit  
proc hash(x: Scale): Hash {....raises: [Exception], tags: [RootEffect].}
Source   Edit  
proc hash(x: ScaleValue): Hash {....raises: [], tags: [].}
Source   Edit  
proc hash(x: StyleLabel): Hash {....raises: [], tags: [].}
Source   Edit  
proc missing(): Missing {....raises: [], tags: [].}
Helper to get a Missing instance. Source   Edit  
proc toOptColor[T: PossibleColor](x: T): Option[Color]
Source   Edit  
proc toOptSecAxis[T: PossibleSecondaryAxis](x: T; axis: AxisKind): Option[
    SecondaryAxis]
Source   Edit