NOPE, NOPE, NOPE! I started building this to graph options profit and loss for a trading project, but Plotta.js is too unfinished to use. I spent several hours just trying to figure out how to hide the legend and title, because the 'visible' properties don't work yet, and finally realized my time could be better spent looking for a working package to build on than trying to fix the unfinished features of this one myself.
You can use what you find in this repo, some of the functions work, but I won't be working on, supporting, or paying any attention to it at all.
Original README follows:
Plotta.js
is a Open Source JavaScript library that plot mathematical functions And Datas.
Plotta.js
Renders using an HTML5 Canvas.
Plotta.js uses HTML5 Canvas without library dependency.
Plotta.js supports Zoom In/Zoom Out, Data table.
You can customize various properties such as axis, grid, font, title, tics, lineDatas, and colors.
https://iamsjy17.github.io/plotta.js-page/
1.1.1
- April 2019, Initial Release
- only supports Chrome and whale browsers.
- Coming in July 2019
- Added more documentation on usage and examples.
- Supports all major browsers.
- Coming in 2021
- Feature: Line Types.(Dotted lines, stick lines, Bar etc.)
- Feature: Add export related API(SaveAsImage, SaveAsPDF)
- Feature: Move coordinate system by dragging mouse
Chrome | Interner Exploer | Edge | Safari | FireFox | Whale |
---|---|---|---|---|---|
Latest | 9+ | Latest | Latest | Latest | Latest |
Uncompressed file for development
- https://iamsjy17.github.io/plotta.js-page/release/latest/plotta.js
- https://iamsjy17.github.io/plotta.js-page/release/[VERSION]/plotta.js
Compressed file for Production
- https://iamsjy17.github.io/plotta.js-page/release/latest/plotta.min.js
- https://iamsjy17.github.io/plotta.js-page/release/[VERSION]/plotta.min.js
$ npm install plotta.js
<canvas
id="canvas"
width="700px"
height="700px"
style="width:700px; height:700px; border:1px solid #d3d3d3;"
></canvas>
const canvas = document.getElementById('canvas');
const plotta = new Plotta(canvas, {
linedatas: [
{
id: 'line1',
type: 'func',
legend: 'cos',
color: '#55A8DE',
visible: true,
func: Math.cos,
dotNum: 1000,
},
],
config: {
title: {
location: 'center',
color: '#666666',
text: 'Plotta.js',
},
grid: {
visible: true,
color: '#888888',
},
border: {
visible: true,
color: '#DDDDDD',
width: 1,
},
},
});
Provides APIs to control various properties.
- Graph
- Line
- Font
- Title
- Grid
- Border
- Tics
- Axis
- Table
Update all graph data And only the properties of the dataSet object with the properties of the graph.
Plotta.UpdateGraph(dataSet);
Name | Type | Description |
---|---|---|
dataSet | Object | Data set to update |
Update line1
, gridVisible, gridColor, borderVisible, borderColor, borderWidth.
Plotta.UpdateGraph({
linedatas: [
{
id: 'line1',
type: 'func',
legend: 'cos',
color: '#55A8DE',
visible: true,
func: Math.cos,
dotNum: 1000,
},
],
config: {
grid: {
visible: true,
color: '#888888',
},
border: {
visible: true,
color: '#DDDDDD',
width: 1,
},
},
});
Add New Line. If it is an existing id, it is not added.
Plotta.AddLine(lineData);
Name | Type | Description |
---|---|---|
lineData | Object | LineData set to Add |
Plotta.AddLine({
id: 'line1',
type: 'func',
legend: 'cos',
color: '#55A8DE',
visible: true,
func: Math.cos,
dotNum: 1000,
});
Delete the line that matches the id you entered.
Plotta.DeleteLine(id);
Name | Type | Description |
---|---|---|
id | String | Id of the line to delete |
Plotta.DeleteLine('line1');
Set the font.
Plotta.SetFont(font);
Name | Type | Description |
---|---|---|
font | String | font |
Plotta.SetFont(`Helvetica Neue', Helvetica, Arial, sans-serif`);
Set the graph title.
Plotta.SetTitle(title);
Name | Type | Description |
---|---|---|
title | String | Graph Title |
Plotta.SetTitle('Hello Graph');
set color of graph title.
Plotta.SetTitleColor(color);
Name | Type | Description |
---|---|---|
color | String | it is parsed as a CSS <color> value. |
Plotta.SetTitleColor(`#FFA500`);
Set the location of the title.
Plotta.SetTitleLocation(location);
The default value is center.
Name | Type | Description |
---|---|---|
location | String | Enter either left, center, or right. |
Plotta.SetTitleLocation('left');
Set the visibility value of the grid.
Plotta.ShowGrid(show);
Name | Type | Description |
---|---|---|
show | boolean | visibility value of the grid. |
Plotta.ShowGrid(true);
set color of grid.
Plotta.SetGridColor(color);
Name | Type | Description |
---|---|---|
color | String | it is parsed as a CSS <color> value. |
Plotta.SetGridColor(`orange`);
Set the visibility value of the border.
Plotta.ShowBorder(show);
Name | Type | Description |
---|---|---|
show | boolean | visibility value of the border. |
Plotta.ShowBorder(false);
set color of border.
Plotta.SetBorderColor(color);
Name | Type | Description |
---|---|---|
color | String | it is parsed as a CSS <color> value. |
Plotta.SetGridColor(`black`);
set width of border.
Plotta.SetBorderWidth(width);
Name | Type | Description |
---|---|---|
width | Number | width of border |
Plotta.SetBorderWidth(1);
Set the visibility value of the ticks.
Plotta.ShowTics(show);
Name | Type | Description |
---|---|---|
show | boolean | visibility value of the ticks. |
Plotta.ShowTics(true);
set color of ticks.
Plotta.SetTicsColor(color);
Name | Type | Description |
---|---|---|
color | String | it is parsed as a CSS <color> value. |
Plotta.SetTicsColor(`#888888`);
Set the tick value object.
The tick value
is the unit size of a tick on the x and y axes.
Plotta.SetTicsValue(value);
Name | Type | Description |
---|---|---|
value | Object | An Object with x, y ticks as properties |
Plotta.SetTicsValue({ x: 2, y: 2 });
Set the visibility value of the X axis label.
Plotta.ShowAxisXLabel(show);
Name | Type | Description |
---|---|---|
show | boolean | visibility value of the X axis label. |
Plotta.ShowAxisXLabel(true);
Set the X axis label.
Plotta.SetAxisXLabel(lebel);
Name | Type | Description |
---|---|---|
lebel | String | X axis label. |
Plotta.SetAxisXLabel('X label');
set color of X axis label.
Plotta.SetAxisXLabelColor(color);
Name | Type | Description |
---|---|---|
color | String | it is parsed as a CSS <color> value. |
Plotta.SetAxisXLabelColor(`#888888`);
Set the location of the X axis label.
Plotta.SetAxisXLabelLocation(location);
The default value is center.
Name | Type | Description |
---|---|---|
location | String | Enter either left, center, or right. |
Plotta.SetAxisXLabelLocation('center');
Set the visibility value of the Y axis label.
Plotta.ShowAxisYLabel(show);
Name | Type | Description |
---|---|---|
show | boolean | visibility value of the X axis label. |
Plotta.ShowAxisYLabel(true);
Set the Y axis label.
Plotta.SetAxisYLabel(lebel);
Name | Type | Description |
---|---|---|
lebel | String | X axis label. |
Plotta.SetAxisXLabel('Y label');
set color of Y axis label.
Plotta.SetAxisYLabelColor(color);
Name | Type | Description |
---|---|---|
color | String | it is parsed as a CSS <color> value. |
Plotta.SetAxisYLabelColor(`#888888`);
Set the location of the Y axis label.
Plotta.SetAxisYLabelLocation(location);
The default value is center.
Name | Type | Description |
---|---|---|
location | String | Enter either top, middle, or bottom. |
Plotta.SetAxisYLabelLocation('middle');
Set the visibility value of the Table.
Plotta.ShowTable(show);
Name | Type | Description |
---|---|---|
show | boolean | visibility value of the Table. |
Plotta.ShowTable(true);
Copyright (c) 2019 Song Jewoo. Plotta.js, Plotta.js is released under the MIT license.