Socket
Socket
Sign inDemoInstall

jscharting

Package Overview
Dependencies
0
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jscharting

JavaScript charting library


Version published
Weekly downloads
937
increased by9.72%
Maintainers
1
Install size
15.3 MB
Created
Weekly downloads
 

Changelog

Source

[3.4.0] - 2023-2-14

Changed

  • Linear column gauges with roundCaps offset X axis labels by automatically adjusting xAxis.caOffset if not set.
  • System square shape corners radius added.
  • Improve gauge layout algorithm.
  • Improve shape label positioning.
  • Middle center aligned shape labels render in center of circular gauges regardless of arc sweep.
  • Improve organizational chart layout stability.
  • Shape label offset is applied after layout instead of during.
  • Point exploded option has been deprecated in favor of the point selected option.
  • Point marker rotation corrected. Rotation now offsets the initial angle by rotation amount.
  • Enable type: 'gauge circle column' without clipping smaller arc angle sweeps.
  • series.points(hierarchicalPathSelection) creates a collection with points that are sorted in the say they were added to the chart.
  • API documentation lists items alphabetically.

Added

  • Axis_scale_maxTickCount property.
  • Outside middle left/right shape label placement.
  • AxisTick.gridLine.center
  • Label autoWrap:false setting always works.
  • Label width and maxWidth are always enforced even if they overflow visually.
  • label textOverflow:'ellipsis' works with autoWrap:false and width or maxWidth restrictions.
  • Series.yAt(x) value interpolation function adds support for y range values.
  • Series.defaultLeafPoint option to set point defaults for hierarchical points without children.
  • Point.defaultLeafPoint option to set point defaults for child leaf points.
  • Point.leafPointLayout option to allow 'vertical' layout of leaf points in organizational charts with the default down orientation.
  • AxisMarker.label.color:'%color' will take on the marker color if defined. Color modifiers like darken are supported as well.
  • Muted state for point.complete value visualization.
  • series.points.add([]) Allows adding multiple points at once.
  • Use series.points(date as string | number) to select calendar points.
  • Chart level overlapBranding property so branded charts are the same size as non-branded.

Bug Fixes

  • Labels in linear gauge columns with roundcaps label collision bug.
  • Point axis ticks not working with radar category xAxis chart.
  • Linear gauge tooltip with followCursor: false not aligning to column correctly.
  • Prevent axis tick rounding 2500 to 3k automatically.
  • Tooltip not showing when alternating hovering between same two data points on different charts.
  • Shape label.color='%color' will use the color of the first series of the shape.
  • Csv parsing bug with text that includes numbers like 'Group 1'..
  • Marker series type with custom SVG paths hit test is not accurate.
  • Shape label right margin has no effect.
  • Make xAxis.staticColumnWidth work with circular gauge charts.
  • Enable circular gauges resizing with container DIV resize.
  • Series.shape.offset not working with gauges.
  • Series states.mute.fill not working.
  • Series states.select.fill and opacity not working.
  • Countries with iso codes SQ, GF, GP, GZ, HM, MQ, QO, RE, YT are not showing on maps.
  • Series.mouseTracking and Point.mouseTracking set to false is not consistently preventing crosshair from highlighting points or excluding points from combined tooltips.
  • Axis ticks with inside placement hide first and last ticks even if they are within the axis range.
  • Icon loading issue when defaults({baseUrl}) doesnt have trailing '/'
  • Point.getParents() and Point.getChildren() definition in jscharting.d.ts is incorrect.
  • Improve memory cleanup.
  • Circular gauges with < 360 angle sweep not handling overflowing axis marker values well.
  • Some syntax issues in jscharting.d.ts with more strict processors.
  • label text <img> tag does not work with src attributes containing '=' characters.
  • Using null for axis scale range min/max value doesn't reset the range.
  • Point click event interaction is not working well when crosshair is enabled.
  • Scrolling is not working immediately after a date zoom range is applied through Axis.zoom().
  • Point.zoomTo() not working when only Y axis zoom is enabled.
  • A shape label may not animate its position when updated in some rare cases.
  • In some cases the column label is placed inside the column even if it doesn't fit but should be placed somewhere else.
  • Exception thrown when shape label text is too large to fit inside the chart image.
  • Numeric text animation ignoring leading zeros.
  • Line series line hover works despite series.mouseTracking === false.
  • AxisMarkers with date string value not working on a time scale axis.
  • Regression bug: Issue when adding series with category x values to an existing chart.
  • Issue parsing micro chart string tag booleans in presence of other quoted string attribute values.
  • Bug parsing custom axis tick value set with date object.
  • Point marker offset and rotation not working with some series types.
  • Point marker with SVG image sizing and rendering issue.
  • Raster image point marker does not size to marker.size setting.
  • Point mouseTracking=false not working in some scenarios.
  • series.points(hierarchicalPathSelection) returns duplicate points.
  • Extra blank pages created when printing a chart or page containing a chart.
  • Chart callback can fail to get called if "JSC.Chart()" is instantiated without new keyword.
  • Exception with treemap and calendar types when no series are provided.

Readme

Source

JSCharting: Any Chart. Anywhere.

JSCharting is a JavaScript chart library for visualizing your data across all devices and platforms. Every JSCharting license includes the full suite of 150+ advanced chart types plus Gantt charts, JavaScript Org Charts, interactive stock and finance charts, seamless grid and calendar charts, JavaScript maps, and micro charts all for no additional charge. JSCharting has all the features you need and many you don't yet know you want.

Example Charts: Chart Types | Feature Examples

Install

Using CDN

Visit code.jscharting.com for a list of available releases.

<script src="https://code.jscharting.com/latest/jscharting.js"></script>
Download

The latest release can be downloaded here.

Using npm

See npm documentation to get started with npm.

npm install --save jscharting
Working with a local copy of JSCharting

The npm package folder jscharting/dist/ includes all the necessary charting JavaScript files and resources such as icons, polyfills, and mapping data files. The chart loads these resources dynamically as needed. The content of this folder should be accessible through http, so when building, copy this folder to a destination in the output website.

If the chart detects a script tag pointing to the main jscharting.js file, it will assume the rest of the resources are located in the same place and will load them from there.

If the JSC namespace is imported from the jscharting.js file as a module, the chart will not know where resources are located and will load them from the CDN. If debug: true chart option is set, a warning message will note that the chart is using the CDN. In order to use local resources, point the chart baseUrl option to the location of the local copy of the jscharting/dist/ folder.

To avoid setting the baseUrl property on every chart instance, it can be set as a global default like so:

JSC.defaults({ baseUrl: './js/jsc/' });

A wrapper module can be used to apply the baseUrl and any other default options that should be used globally such as debug, or styling options. All subsequent charts can import this wrapper instead of the chart itself to ensure the default options are always applied.

import * as JSC from "jscharting";

JSC.defaults({ baseUrl: './js/jsc/' });

export default JSC;

First Chart

Add a target div element to you HTML page for the chart to render in and specify a CSS height setting.

<div id="chartDiv" style="max-width: 500px; height: 300px;"></div>
The chart will automatically conform to the container size by default.

Create an instance of a chart with some static data.

const chart = new JSC.Chart('chartDiv', { 
  type: 'column',
  series:[{
	name: 'Teams',
    points: [{ x: 'A', y: 10 }, { x: 'B', y: 5 }]
  }], 
});

First Chart

Edit in CodePen

Get data from CSV

JSC.fetch() is an alias for the standard JavaScript fetch() function and includes a polyfill for IE11. Use this function to effortlessly retrieve chart data from your disk.

JSC.fetch('./data.csv')
    .then(response => response.text())
    .then(text => {
        //Use csv text 
    });

Data in CSV, TSV, or delimiter-separated values format can be converted to JSON. Refer to the fetch(), CSV, and JSON tutorial for more information.

let data = JSC.csv2Json(
 'date,actual,goal\n1/1/2023,5409,7000\n1/8/2023,4893,7000'
);
// -> 
//[{date: 1672552800000, actual: 5409, goal: 7000},
//{date: 1673157600000, actual: 4893, goal: 7000}]
Map data to chart points
let points = data.map(d => {  
  return { x: d.date, y: d.actual }; 
});
//-> [{ x: 1672552800000, y: 5409 }, { x: 1673157600000, y: 4893 }]
Render a chart using data
const chart = new JSC.Chart('chartDiv', {
   /* Set the x axis scale to time. */
   xAxis_scale_type: 'time',
   /* Pass points to the series */
   series: [{
       points: points
   }]
});

CSV Data Chart

Edit in CodePen

Crash Course

(5 min read to hit the ground running)

The JSCharting API is designed to be user-friendly. The chart selects default options that are intuitive, reducing the need for customization.

Chart Types

You can set chart types through the chart type property:

const chart = new JSC.Chart('divId', { type: 'horizontal column' });

There are a variety of chart types, series types, and modifiers that can be combined in the "type" property.

Examples of chart types:

horizontal, pie, radar, map, organizational, calendar, full list

Examples of series types:

column, line, area, bubble, candlestick, full list

A few illustrated examples of type settings:

line column area horizontal column radar spider column gauge column roundcaps More Examples

Chart Types Overview

Be sure to check out our chart types gallery for examples and usage guidance.

Chart Options

Chart options can be set in the chart constructor,

const chart = new JSC.Chart('divId', { /*options*/ });

or at any time after the chart is rendered.

chart.options({ /*options*/ });
Property Expansion

JSCharting provides a declarative API with options such as

chart.options({ title: { label: { text: 'title text' }}});

For convenience, property paths can be combined into single property names as shown:

chart.options({ title_label_text: 'title text' });

Property Expansion Details

Hide Legend
chart.options({ legend_visible: false });
Legend Columns
// Less Detail
chart.options({ legend_template: '%icon %name' });
// More Detail
chart.options({ legend_template: '%average %sum %icon %name' });

Refer to the Token Reference Tutorial for a comprehensive list of over 54 available tokens, listed under the 'Series Tokens' section.

Legend template

Try it out in this CodePen

Legend Entries for Points

The code snippet below sets a series palette, which results in each point in a series having a corresponding entry in the legend box.

chart.options({ defaultSeries_palette: 'default' });

No Setting Series Palette Set

Legend Tutorial

Labels
chart.options({
    /* Title text */
    title_label_text: 'Title text',
    /* Axis label text */
    xAxis_label_text: 'Time',
    yAxis_label_text: 'Steps',
    /* Point labels */
    defaultPoint_label_text: '%yValue',
    /* Annotations */
    annotations:[{
        position: 'top',
        label_text: 'Annotation text'
    }]
});

Chart Labels

Using Labels tutorial.

Chart with a button

Do you need a user interface control to adjust a chart setting or test a line of code in real-time?

Traditionally, you would have to create an HTML element and link its events to JavaScript code, but this process can be made much easier by using the integrated UI controls provided by JSCharting. This allows you to add simple UI elements without any HTML required.

JSC.Chart('chartDiv', { 
    toolbar_items: {
        'Click Me': {
            events_click: function(){ alert('Button clicked'); }
        }}
});

Try it in CodePen.

Toolbar & UiItems tutorial.

Keywords

FAQs

Last updated on 20 Feb 2023

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