|
1 | 1 | # Chart.Smith.js |
2 | 2 | [](https://travis-ci.org/etimberg/Chart.smith.js) |
3 | 3 |
|
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) |
5 | 5 |
|
6 | 6 | ## Documentation |
7 | 7 |
|
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 | +``` |
9 | 130 |
|
10 | 131 | ## License |
11 | 132 |
|
12 | 133 | Chart.Smith.js is available under the [MIT license](http://opensource.org/licenses/MIT). |
13 | 134 |
|
14 | 135 | ## Bugs & issues |
15 | 136 |
|
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. |
0 commit comments