Skip to content

Commit 7c07db0

Browse files
committed
Update readme and sample file
1 parent 710adcc commit 7c07db0

File tree

2 files changed

+133
-39
lines changed

2 files changed

+133
-39
lines changed

README.md

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,137 @@
11
# Chart.Smith.js
22
[![Build Status](https://travis-ci.org/etimberg/Chart.smith.js.svg?branch=master)](https://travis-ci.org/etimberg/Chart.smith.js)
33

4-
*Smith Chart extension for Chart.js* [chartjs.org](http://www.chartjs.org)
4+
Provides a Smith Chart for use with [Chart.js](http://www.chartjs.org)
55

66
## Documentation
77

8-
You can find documentation at in `/docs`.
8+
To create a Smith Chart, include `Chart.Smith.js` after `Chart.js` and then create the chart by setting the `type` attribute to `'smith'`
9+
10+
```javascript
11+
var mySmithChart = new Chart({
12+
type: 'smith',
13+
data: dataObject
14+
});
15+
```
16+
17+
### Data Representation
18+
19+
The smith chart can graph multiple datasets at once. The data for each dataset is in the form of complex numbers.
20+
21+
```javascript
22+
var smithChartData = {
23+
datasets: [{
24+
label: 'Dataset 1',
25+
data: [{
26+
real: 0,
27+
imag: 1
28+
}, {
29+
real: 1,
30+
imag: 1
31+
}]
32+
}]
33+
};
34+
```
35+
36+
### Scale Configuration
37+
The smith chart scale can be configured by placing options into the config that is passed to the chart upon creation.
38+
39+
```javascript
40+
new Chart({
41+
config: {
42+
scale: {
43+
display: true, // setting false will hide the scale
44+
gridLines: {
45+
// setting false will hide the grid lines
46+
display: true,
47+
48+
// the color of the grid lines
49+
color: rgba(0, 0, 0, 0.1),
50+
51+
// thickness of grid lines
52+
lineWidth: 1,
53+
},
54+
ticks: {
55+
// The color of the scale label text
56+
fontColor: 'black',
57+
58+
// The font family used to render labels
59+
fontFamily: 'Helvetica',
60+
61+
// The font size in px
62+
fontSize: 12,
63+
64+
// Style of font
65+
fontStyle: 'normal'
66+
67+
// Function used to convert real valued ticks to strings
68+
rCallback: function(tick, index, ticks) {}
69+
70+
// Function used to convert imaginary valued ticks to strings
71+
xCallback: function(tick, index, ticks) {}
72+
}
73+
}
74+
}
75+
});
76+
```
77+
78+
### Dataset Configuration
79+
80+
The datasets for smith charts support many of the same options as the line chart
81+
82+
```javascript
83+
{
84+
// Bezier Curve tension. Set to 0 for straight lines
85+
tension: 0,
86+
87+
// Fill color for dataset
88+
backgroundColor: 'rgba(0, 0, 0, 0.1)',
89+
90+
// Width of line
91+
borderWidth: 1,
92+
93+
// Line color
94+
borderColor: 'rgba(0, 0, 0, 0.1)',
95+
96+
// Line ending style
97+
borderCapStyle: 'butt',
98+
99+
// Line dash style
100+
borderDash: [],
101+
102+
// Dash offset. Used in conjunction with borderDash property
103+
borderDashOffset: 0,
104+
105+
// Line join style
106+
borderJoinStyle: 'miter',
107+
108+
// Do we fill the line?
109+
fill: true,
110+
111+
// Point radius
112+
radius: 3,
113+
114+
// Point style (circle, cross, etc)
115+
pointStyle: 'circle',
116+
117+
// Point fill color
118+
pointBackgroundColor: 'rgba(0, 0, 0, 0.1)',
119+
120+
// Point stroke color
121+
pointBorderColor: 'rgba(0, 0, 0, 0.1)',
122+
123+
// Point stroke width
124+
pointBorderWidth: 1,
125+
126+
// Used for hit detection
127+
hitRadius: 3
128+
}
129+
```
9130

10131
## License
11132

12133
Chart.Smith.js is available under the [MIT license](http://opensource.org/licenses/MIT).
13134

14135
## Bugs & issues
15136

16-
When reporting bugs or issues, if you could include a link to a simple [jsbin](http://jsbin.com) or similar demonstrating the issue, that'd be really helpful.
137+
When reporting bugs or issues, if you could include a link to a simple [jsbin](http://jsbin.com) or similar demonstrating the issue, that would be really helpful.

samples/smith.html

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,19 @@
2121

2222

2323
<script>
24-
/*window.onload = function(){
25-
var ctx = document.getElementById("chart-area").getContext("2d");
26-
window.myDoughnut = new Chart(ctx).Doughnut(doughnutData, {responsive : true});
27-
};*/
28-
/*var smithData = {
29-
datasets : [
30-
{
31-
label: "My Trace",
32-
fillColor : "rgba(151,187,205,0.2)",
33-
strokeColor : "rgba(151,187,205,1)",
34-
pointColor : "rgba(151,187,205,1)",
35-
pointStrokeColor : "#fff",
36-
pointHighlightFill : "#fff",
37-
pointHighlightStroke : "rgba(151,187,205,1)",
38-
data : [ { real : 1.0, imag : 2.0},
39-
{ real : 1.0, imag : 1.0},
40-
{ real : 1.0, imag : -1.0}
41-
]
42-
},
43-
{
44-
label: "My Trace 2",
45-
fillColor : "rgba(70,191,189,0.2)",
46-
strokeColor : "rgba(70,191,189,1)",
47-
pointColor : "rgba(70,191,189,1)",
48-
pointStrokeColor : "#fff",
49-
pointHighlightFill : "#fff",
50-
pointHighlightStroke : "rgba(70,191,189,1)",
51-
data : [ { real : 1.0, imag : 2.0},
52-
{ real : 0.5, imag : 2.0},
53-
{ real : 5.0, imag : 2.0}
54-
]
55-
}
56-
]
57-
};*/
58-
5924
window.onload = function() {
6025
var ctx = document.getElementById("chart-area").getContext("2d");
6126
window.mySmith = new Chart(ctx, {
6227
type: 'smith',
63-
options: {},
28+
options: {
29+
elements: {
30+
point: {
31+
pointStyle: 'cross',
32+
radius: 10,
33+
borderColor: 'black'
34+
}
35+
}
36+
},
6437
data: {
6538
datasets: [{
6639
label: 'My Dataset',

0 commit comments

Comments
 (0)