Smith Charts with Chart.js
Installation
> npm install chartjs-chart-smith
To create a Smith Chart, include chartjs-chart-smith.js
after Chart.js
and then create the chart by setting the type
attribute to 'smith'
.
var mySmithChart = new Chart({type: 'smith',data: dataObject});
Data Representation
The smith chart can graph multiple datasets at once. The data for each dataset is in the form of complex numbers.
var smithChartData = {datasets: [{label: 'Dataset 1',data: [{real: 0,imag: 1}, {real: 1,imag: 1}]}]};
Scale Configuration
The smith chart scale can be configured by placing options into the config that is passed to the chart upon creation.
new Chart({config: {scale: {display: true, // setting false will hide the scalegridLines: {// setting false will hide the grid linesdisplay: true,// the color of the grid linescolor: rgba(0, 0, 0, 0.1),// thickness of grid lineslineWidth: 1,},ticks: {// The color of the scale label textfontColor: 'black',// The font family used to render labelsfontFamily: 'Helvetica',// The font size in pxfontSize: 12,// Style of fontfontStyle: 'normal'// Function used to convert real valued ticks to stringsrCallback: function(tick, index, ticks) {}// Function used to convert imaginary valued ticks to stringsxCallback: function(tick, index, ticks) {}}}}});
Dataset Configuration
The datasets for smith charts support many of the same options as the line chart
{// Bezier Curve tension. Set to 0 for straight linestension: 0,// Fill color for datasetbackgroundColor: 'rgba(0, 0, 0, 0.1)',// Width of lineborderWidth: 1,// Line colorborderColor: 'rgba(0, 0, 0, 0.1)',// Line ending styleborderCapStyle: 'butt',// Line dash styleborderDash: [],// Dash offset. Used in conjunction with borderDash propertyborderDashOffset: 0,// Line join styleborderJoinStyle: 'miter',// Do we fill the line?fill: true,// Point radiusradius: 3,// Point style (circle, cross, etc)pointStyle: 'circle',// Point fill colorpointBackgroundColor: 'rgba(0, 0, 0, 0.1)',// Point stroke colorpointBorderColor: 'rgba(0, 0, 0, 0.1)',// Point stroke widthpointBorderWidth: 1,// Used for hit detectionhitRadius: 3}
License
chartjs-chart-smith is available under the MIT license.
Bugs & issues
When reporting bugs or issues, if you could include a link to a simple jsbin or similar demonstrating the issue, that would be really helpful.