Socket
Socket
Sign inDemoInstall

cojasclib

Package Overview
Dependencies
12
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cojasclib

COmmon JAvascript Standard for Charting LIbraries


Version published
Maintainers
1
Install size
5.60 MB
Created

Readme

Source

COJASCLIB

COmmon JAvascript Standard for Charting LIBraries

Note: This package is in active development and therefore should not be used until further notice

Introduction

With the increasing number of javascript libraries for data visualization, and the benefits and flaws of each of them, programmers are often obliged to use several libraries for the same project. These heterogeneity adds unnecessary complexity to the code and can lead to problems. We developped this package as an intent to define a standard for data visualization with a system of pluggable adaptors for external libraries.

Quick start:

npm install cojasclib --save

let Cojasclib = require('cojasclib')

let chart = new Cojasclib.Chart(graphOptions)
let serie = new Cojasclib.Serie({ name: 'serie name', options: serieOptions)

serie.setDataPoint({ x: '', y: '', label: '', options: {} })

chart.setSerie(serie)
chart.render("chartjs", renderingOptions).then(res => {
  this.renderChart(res[0], res[1]);
)

chart Object

setSerie(): Adds serie to final chart object. can be done several time for multi-series

Note: Sort can be set at chartSerie or at chartObject at rendering

  • renderingOptions:
    • sort: true is sorted, false not
    • order: defaults to numeric sort
      • 'array': sort according to the array
      • 'date': date sorted
      • 'alpha': alpha sorted
      • typeof function: The function is passed directly to the lodash function "orderBy"
    • direction: 'ASC' or 'DESC'. Defaults to 'ASC'
    • noConsolidation: true, skips consolidation (only for multiple series). Consolidation populates with empty values the points that are set in one serie and not in another
    • missingPointOptions: In case of consolidation, the options that are used for the created points
    • sortOrdinates: if true, sorts by ordinate (y values)
    • yLabels: Array of labels that defines the order they have to appear. For example: ["fruits", "Vegetables", "Meat"]
    • labelFunction: String modifier function applied to x Labels before displaying. Ex: labelFunction: label => { return label.split("-")[1]; }
    • lengthXMax: INTEGER Max Number of character for splitting x labels, splitting is done on spaces
chart serie object:
  • name: name of the serie. Appears as serie legend
  • opts:
    • sort: true is sorted, false not
    • order: defaults to numeric sort
      • 'array': sort according to the array
      • 'date': date sorted
      • 'alpha': alpha sorted
      • typeof function: The function is passed directly to the lodash function "orderBy"
    • direction: 'ASC' or 'DESC'. Defaults to 'ASC'
    • fillNullDateValues: if a date are missing in the serie, replaces it with the point {label: date, x: date, y: 0}
    • dateFormat: defines the output of the label if it is moment object. see Moment formatting
    • cumulative: adds each value of serie to previous one
    • grouped: if 2 points have the same label, they are cumulated.
    • limitedPoints: Allow to limit the number of points and define a point with "name" as label and the sum of remaining points y as value
  options {
      ...
    limitedPoints = {
        max: x,
        name: 'Others',
    }
    ...
  }
  ;

Data point
  • x: the absciss value
  • label: the x label (defaults to x)
  • y: the ordinate value (defaults to label)
  • z: the z coordinate for a 3d point (defaults to none)
  • options:
    • color: Set this to change a single point color (color: "#C7E84D")

Available plugins

  • chartist
  • chartjs
  • chartcsv

Plugin Development

The idea is that the same settings will work with any Library

TODO

Common Options:

OptionTypeDescription
defaultFontColorstringDefines font color for all graph text
legendDisplayBoolWether legend should be displayed
xDisplayBoolIf xaxis legends, ticks and labels should be displayed
yDisplayBoolIf yaxis legends, ticks and labels should be displayed
xDisplayGridBoolIf xaxis grid should be displayed
yDisplayGridBoolIf yaxis grid should be displayed

TODO

Keywords

FAQs

Last updated on 10 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc