Socket
Socket
Sign inDemoInstall

canvas-linechart

Package Overview
Dependencies
2
Maintainers
31
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

4

API.md
## `canvasLineChart`
Draw a line chart on canvas.
### Parameters

@@ -12,3 +12,3 @@

* `base` **`number`** mathematical base, a number between 0 and 1
* `options` **`Object`**
* `options` **`Object`** optional customizations

@@ -15,0 +15,0 @@

@@ -0,1 +1,5 @@

## 2.1.0
* Removes marker text
## 2.0.0

@@ -2,0 +6,0 @@

var xtend = require('xtend'),
linearScale = require('simple-linear-scale'),
clamp = require('clamp'),
util = require('./util'),

@@ -10,2 +9,3 @@ getControlPoints = require('./get_control_points');

/**
* Draw a line chart on canvas.
* @param {Canvas} c canvas element

@@ -16,3 +16,3 @@ * @param {number} height

* @param {number} base mathematical base, a number between 0 and 1
* @param {Object} options
* @param {Object} options optional customizations
* @param {number} [options.options.scaleFactor=1] dpi ratio

@@ -22,3 +22,3 @@ * @param {number} [options.min=0] minimum x value

* @param {number} [options.tickSize=1] space between each tick mark
* @param {Array<number>} options.marker a marker as a [zoom, val] pair
* @param {number} options.marker a marker as a zoom value
* @param {boolean} options.step whether to represent the chart as stair-steps

@@ -42,3 +42,2 @@ * rather than an interpolated line.

var margin = s(12);
var markerOffset = s(10);
var fontSize = s(10);

@@ -75,2 +74,7 @@ var values = data.map(function(d) { return d[1]; });

if (options.marker) {
ctx.fillStyle = '#ddd';
ctx.fillRect(xScale(options.marker[0]), 0, s(2), chartHeight + margin);
}
// draw the data line

@@ -94,7 +98,2 @@ ctx.strokeStyle = '#222';

if (options.marker) {
ctx.fillStyle = '#ddd';
ctx.fillRect(xScale(options.marker[0]) - s(0.75), 0, s(1.5), chartHeight);
}
ctx.fillStyle = '#fff';

@@ -126,10 +125,2 @@ ctx.strokeStyle = '#222';

});
if (options.marker) {
var xAnchor = clamp(xScale(options.marker[0]), options.max, width - options.max);
ctx.fillStyle = '#ddd';
ctx.font = 'bold' + fontSize + 'px Menlo, monospace';
ctx.textAlign = 'center';
ctx.fillText('' + options.marker[1], xAnchor, chartHeight + markerOffset);
}
}
{
"name": "canvas-linechart",
"version": "2.0.0",
"version": "2.1.0",
"description": "simple, dependency-free canvas chart",

@@ -27,5 +27,2 @@ "main": "index.js",

"dependencies": {
"clamp": "^1.0.1",
"defined": "^1.0.0",
"eslint": "^1.5.0",
"simple-linear-scale": "^1.0.1",

@@ -35,2 +32,3 @@ "xtend": "^4.0.0"

"devDependencies": {
"eslint": "^1.5.0",
"browserify": "^11.1.0",

@@ -37,0 +35,0 @@ "btoa": "^1.1.2",

@@ -5,10 +5,6 @@ # canvas-linechart

## api
## [api](API.md)
lineChart(elem, width, [[x, value, options?], ... ], baseCurve, [x, label], step);
Options are `end` for omitting the dot and `focus` for highlighting the dot. If `step` is true, stops will not be interpolated.
## install
npm install --save canvas-linechart
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