Giter Site home page Giter Site logo

plot-utils's Introduction

plot-utils

This library is designed to plots easy. It isolate some of the core functions of plotting, such as coordinate transformation, grid generation etc. Fair warning, it is my personal attempt for my personal convinience. It is not likely to stabilize. I myself is learning as I go.

Available functions

// Coordinate utils
getRotatedAxisCoordinate(x,y,rotation)
/*
 * Suppose rotating a plot around upper-left origin.
 * Where does the point (x,y) on old coordinate system lie on the rotated plot?
 * Return {x,y}
/*
toDomXCoord_Linear(width,minX,maxX,dataX)
fromDomXCoord_Linear(width,minX,maxX,domX)
toDomYCoord_Linear(height,minY,maxY,dataY)
fromDomYCoord_Linear(height,minY,maxY,domY)

// Grid utils
generateGrids(minX,maxX,rangeMinX,rangeMaxX)
/*
 * Return { grids:[], validFromDiff, validToDiff}
 */
generateDateGrids(minX,maxX,rangeMinX,rangeMaxX)

design guidelines

The beginning of this library is quite chaotic, not gonna lie here. A lot of functions moved in and out of this library. This is bad! So, that is why I think it is helpful to set the guidelines here to help me and anyone else to reason about whether to include a function in this library:

  1. Is the functionality to be reused a lot in all sorts of plots?
  2. Is the functionality technology agnostic? The answer for both question had better be "yes".

Lesson learned/bad examples

I once included a lineplot function in this library:

function linePlot(ctx,domXs,domYs){
  ctx.beginPath();
  ctx.moveTo(domX[0],domY[0]);
  for (let i=1; i<domXs.length; i++) {
    ctx.lineTo(domXs[i],domYs[i]);
  }
  ctx.stroke();
}

I no longer see it a fit in this library because it violated our guideline 2. It is a function for HTML5 canvas and is not suitable for other visualization technologies, e.g. svg. So maybe function like that can be moved in ,say , a canvas plotter library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.