JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

spork/charts/line-chart

spork


    function
    /usr/local/lib/janet/spork/charts.janet on line 1095, column 1

    
    (line-chart &named canvas width height data font background-color text-color color-map point-radius x-min x-max y-min y-max padding inner-padding inner-padding-x inner-padding-y title circle-points scatter grid legend legend-labels super-sample stroke-thickness format-x format-y save-as legend-map legend-padding tick-length line-style line-style-per-column bar-padding x-label y-label x-suffix x-prefix y-suffix y-prefix x-column y-column x-ticks y-ticks x-minor-ticks y-minor-ticks x-grid-ticks y-grid-ticks x-labels-vertical grid-between-x grid-between-y annotate transpose)

    Render a line chart. Returns a gfx2d/image which can be further 
    manipulated with the spork/gfx2d module.

    Basic Parameters

    * :canvas - a gfx2d/image to draw on
    * :width - (if no canvas provided) - make a new canvas with the 
      given width in pixels
    * :height - (if no canvas provided) - make a new canvas with the 
      given height in pixels
    * :data - a data frame to use for data
    * :title - an optional title to add to the rendered image
    * :font - font used to draw text, including title, legend, and axes 
      labels
    * :save-as - save the generated image to file. Can be any format 
      supported by the gfx2d module
    * :x-column - the name of the data frame column to use for the x 
      axis
    * :y-column - a single column or array of column names to use for 
      the chart
    * :x-ticks - manually set the tick marks on the X axis instead of 
      auto-detecting them
    * :y-ticks - manually set the tick marks on the Y axis instead of 
      auto-detecting them

    Axes Styling

    * :inner-padding - the number of pixels of white space between 
      x-min and the x-axes as well as y-min and the y-axes.
    * :inner-padding-x - inner-padding for x-axis only
    * :inner-padding-y - inner-padding for y-axis only
    * :x-label - optional label for the x axis
    * :y-label - optional label for the y axis
    * :grid - how to draw grid lines. One of :none, :solid, or :stipple
    * :x-suffix - add a string suffix to each tick label on the x-axis
    * :y-suffix - add a string suffix to each tick label on the x-axis
    * :x-prefix - add a string prefix to each tick label on the y-axis
    * :y-prefix - add a string prefix to each tick label on the y-axis
    * :x-ticks - Array of labeled x-coordinate locations.
    * :y-ticks - Array of labeled y-coordinate locations.
    * :x-grid-ticks - Array of x-coordinates for grid lines.
    * :y-grid-ticks - Array of y-coordinates for grid lines.
    * :x-minor-ticks - how many, if any, small ticks to add between 
      each large tick mark on the x axis
    * :y-minor-ticks - how many, if any, small ticks to add between 
      each large tick mark on the y axis
    * :x-labels-vertical - Turn x labels vertical so more can fit on 
      the axis
    * :tick-length - how long to make major tick marks
    * :grid-between-x - Put grid-lines between X-axis labels on the 
      x-axis instead of on them.
    * :grid-between-y - Put grid-lines between X-axis labels on the 
      y-axis instead of on them.

    Chart Styling

    * :padding - the number of pixels of white space around various 
      elements of the chart
    * :background-color - color of background, defaults to white. Use 
      :none to skip drawing a background.
    * :text-color - color of text, defaults to black
    * :color-map - a dictionary mapping columns to colors. By default 
      will hash column name to pseudo-random colors
    * :scatter - set to true to disable lines connecting points
    * :legend - set to true to add a legend to the top of the chart
    * :legend-map - a dictionary mapping column names to pretty text 
      for the chart
    * :legend-labels - optional list of y-column names to display in 
      the legend
    * :legend-padding - extra padding around legend area
    * :point-radius - radius of points when drawing a scatter plot
    * :line-style - How to draw lines. Can be one of :stroke, :plot, 
      :none, :bar, :area, or :stipple. Default is :plot.
    * :line-style-per-column - Optional dictionary to override line 
      style by y-column name.
    * :super-sample - Super Sample anti-aliasing for chart lines. Is a 
      bit slow, but makes smooth plots. Works best with :stroke and 
      :bar
    * :stroke-thickness - thickness in pixels of the stroke of the 
      graph when :line-type = :stroke
    * :annotate - an optional function to add annotations to a rendered 
      chart. This function should take 3 arguments: (fn callback [view 
      to-pixel to-metric] ...)

    Axis Boundaries

    * :x-min - minimum x coordinate on chart
    * :x-max - maximum x coordinate on chart
    * :y-min - minimum y coordinate on chart
    * :y-max - maximum y coordinate on chart


1 exampleSign in to add an example
Loading...
(import spork/charts :as c)
(c/line-chart
  :width 400 :height 200
  :data {:timestamp [1 2 3 5 40 60]
         :temperature-1 [75.1 75.2 75.4 75.5 75.5 75.4]
         :temperature-2 [55.1 55.4 55.7 60.0 60.4 60.9]}
  :save-as "bla.png"
  :x-column :timestamp
  :y-column [:temperature-1 :temperature-2])

# then open bla.png to view
# bakpakin shared this example
veqqqPlayground