1.0.19 • Published 7 years ago

simple-charts v1.0.19

Weekly downloads
84
License
-
Repository
github
Last release
7 years ago

simple-charts

Provide ability to draw charts without any dependencies

Supported charts

  • Line Chart

Links

Github Pages

https://sebastian-heinz.github.io/simple-charts/

NPM

npm package
https://www.npmjs.com/package/simple-charts

Installation

npm install simple-charts --save

Usage

Include it into your build process and require it.

var SimpleCharts = require("simple-charts")

Or use the bundled library dircetly in your Browser.

    <script src="./node_modules/simple-charts/bundle.js"></script>

Which will expose a "SimpleCharts"-Variable for you.

var group = new SimpleCharts.LineDataGroup('a');
group.addPosition(1, 1);
group.addPosition(3, 1.5);
group.addPosition(4, 1.7);
group.addPosition(5, 1.9);
group.addPosition(6, 2);

var set = new SimpleCharts.LineDataSet();
set.Height = 200;
set.Width = 600;
set.addLineDataGroup(group);

var chart = new SimpleCharts.LineChart(set);
chart.Update();
chart.appendTo(document.body);

LineChart

Programmatically:
To create a line chart programmatically you will need to utilize three classes.

1) Create an instance of LineDataGroup.ts. This object has a 'addPosition(x,y)'-Method. You need to feed it all your coordinates.

2) Create an instance of LineDataSet.ts. The LineDataSet defines the charts size and which LineDataGroups are displayed. You need to add the previous created LineDataGroup to this Instance via the "addLineDataGroup(group)"-method.

3) Create an instance of LineChart.ts. The constructor takes the previously created LineDataSet as argument. Call the "Update()"-method on the newly created LineChart, followed by the "appendTo(node)"-method. The "appendTo(node)"-method expect an HTML-Node element as input parameter, which will be used to attach the generated chart.

For an example please reffer to LineChartExample.ts.

BarChart

For an example please reffer to BarChartExample.ts.

Structure

Development

First install all development dependencies by running:

npm install

You can run the library in the browser by running:

npm start

This will start a webpack development server.
Navigate to: http://localhost:8080/

The docs/index.html-file is beeing displayed in the development server. It includes the generated bundle.js and uses styles from docs/styles.css. Additionally the docs/ folder makes up the github page. The docs/src/ directory contains the js-code for the page, if the input data for the library need to be tested or changed this is the place.

The library source can be found in src/.

Changes to src/ or docs/src/ trigger a compile of the .ts-files, rebundling the generated .js-files as a single bundle.js-file and finally a reload of the browser to reflect the changes.

Note: The webpack live server will not recreate the bundle.js-file on your disk while developing changes are bundled, the generated bundle.js from the webpack development server will be served from ram. In order to generate an up to date bundle.js-file you need to manually run:

npm run bundle-docs

This will updated your bundle.js file on disk. This step should only be necessary if your updates should be reflected on the github page.

Future Plans

  • BarChart

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago