99[ npm-download ] :https://img.shields.io/npm/dm/@coreui/react-chartjs.svg?style=flat-square
1010
1111#####install:
12+
1213``` bash
13- npm install @coreui/react-chartjs
14+ npm install @coreui/react-chartjs@next
15+
16+ # or
17+
18+ yarn add @coreui/react-chartjs@next
1419```
1520
16- #####import:
21+ #####import:
22+
1723``` jsx
18- import {CChart }from ' @coreui/react-chartjs' ;
24+ import {CChart }from ' @coreui/react-chartjs'
1925```
20- or
26+
27+ or
28+
2129``` js
2230import {
2331CChart ,
@@ -31,79 +39,145 @@ import {
3139}from ' @coreui/react-chartjs'
3240```
3341
34- #####props:
35- - ` innerRef ` object | func | string
36- - ` datasets ` array
37- - ` labels ` array | string
38- - ` options ` object
39- - ` plugins ` array
40- - ` type ` string:` bar ` |` horizontalBar ` |` line ` |` doughnut ` |` radar ` |` pie ` |` polarArea `
42+ #####props:
43+
44+ ``` js
45+
46+ /**
47+ * A string of all className you want applied to the base component.
48+ */
49+ className?: string
50+ /**
51+ * Enables custom html based tooltips instead of standard tooltips.
52+ *
53+ *@default true
54+ */
55+ customTooltips?: boolean
56+ /**
57+ * The data object that is passed into the Chart.js chart (more info).
58+ */
59+ data: Chart .ChartData | ((canvas : HTMLCanvasElement )=> Chart .ChartData )
60+ /**
61+ * A fallback for when the canvas cannot be rendered. Can be used for accessible chart descriptions.
62+ *
63+ *{@link https://www.chartjs.org/docs/latest/general/accessibility.html More Info}
64+ */
65+ fallbackContent?: React .ReactNode
66+ /**
67+ * Proxy for Chart.js getDatasetAtEvent. Calls with dataset and triggering event.
68+ */
69+ getDatasetAtEvent?: (dataset : Array < {}> ,event : React .MouseEvent < HTMLCanvasElement > )=> void
70+ /**
71+ * Proxy for Chart.js getElementAtEvent. Calls with single element array and triggering event.
72+ */
73+ getElementAtEvent?: (element : [{}],event : React .MouseEvent < HTMLCanvasElement > )=> void
74+ /**
75+ * Proxy for Chart.js getElementsAtEvent. Calls with element array and triggering event.
76+ */
77+ getElementsAtEvent?: (elements : Array < {}> ,event : React .MouseEvent < HTMLCanvasElement > )=> void
78+ /**
79+ * Height attribute applied to the rendered canvas.
80+ *
81+ *@default 150
82+ */
83+ height?: number
84+ /**
85+ * ID attribute applied to the rendered canvas.
86+ */
87+ id?: string
88+ /**
89+ * The options object that is passed into the Chart.js chart.
90+ *
91+ *{@link https://www.chartjs.org/docs/latest/general/options.html More Info}
92+ */
93+ options?: Chart .ChartOptions
94+ /**
95+ * The plugins array that is passed into the Chart.js chart (more info)
96+ *
97+ *{@link https://www.chartjs.org/docs/latest/developers/plugins.html More Info}
98+ */
99+ plugins?: Chart .PluginServiceRegistrationOptions []
100+ /**
101+ * If true, will tear down and redraw chart on all updates.
102+ *
103+ *@default false
104+ */
105+ redraw?: boolean
106+ /**
107+ * Chart.js chart type.
108+ *
109+ *@type {'line' | 'bar' | 'horizontalBar' | 'radar' | 'doughnut' | 'polarArea' | 'bubble' | 'pie' | 'scatter'}
110+ */
111+ type: Chart .ChartType
112+ /**
113+ * Width attribute applied to the rendered canvas.
114+ *
115+ *@default 300
116+ */
117+ width?: number
118+ /**
119+ * Put the chart into the wrapper div element.
120+ *
121+ *@default true
122+ */
123+ wrapper?: boolean
124+ ```
41125
42126#####usage:
127+
43128``` jsx
44129...
45130class CoreUICharts extends Component {
46131...
47132render () {
48133return (
49134< CChart
50- type= " radar"
51- datasets= {[
52- {
53- label: ' 2019' ,
54- backgroundColor: ' rgba(179,181,198,0.2)' ,
55- borderColor: ' rgba(179,181,198,1)' ,
56- pointBackgroundColor: ' rgba(179,181,198,1)' ,
57- pointBorderColor: ' #fff' ,
58- pointHoverBackgroundColor: ' #fff' ,
59- pointHoverBorderColor: ' rgba(179,181,198,1)' ,
60- tooltipLabelColor: ' rgba(179,181,198,1)' ,
61- data: [65 ,59 ,90 ,81 ,56 ,55 ,40 ]
62- },
63- {
64- label: ' 2020' ,
65- backgroundColor: ' rgba(255,99,132,0.2)' ,
66- borderColor: ' rgba(255,99,132,1)' ,
67- pointBackgroundColor: ' rgba(255,99,132,1)' ,
68- pointBorderColor: ' #fff' ,
69- pointHoverBackgroundColor: ' #fff' ,
70- pointHoverBorderColor: ' rgba(255,99,132,1)' ,
71- tooltipLabelColor: ' rgba(255,99,132,1)' ,
72- data: [28 ,48 ,40 ,19 ,96 ,27 ,100 ]
73- }
74- ]}
135+ type= ' line'
136+ data= {{
137+ labels: [' January' ,' February' ,' March' ,' April' ,' May' ,' June' ,' July' ],
138+ datasets: [
139+ {
140+ label: ' 2019' ,
141+ backgroundColor: ' rgba(179,181,198,0.2)' ,
142+ borderColor: ' rgba(179,181,198,1)' ,
143+ pointBackgroundColor: ' rgba(179,181,198,1)' ,
144+ pointBorderColor: ' #fff' ,
145+ pointHoverBackgroundColor: ' #fff' ,
146+ pointHoverBorderColor: ' rgba(179,181,198,1)' ,
147+ tooltipLabelColor: ' rgba(179,181,198,1)' ,
148+ data: [65 ,59 ,90 ,81 ,56 ,55 ,40 ]
149+ },
150+ {
151+ label: ' 2020' ,
152+ backgroundColor: ' rgba(255,99,132,0.2)' ,
153+ borderColor: ' rgba(255,99,132,1)' ,
154+ pointBackgroundColor: ' rgba(255,99,132,1)' ,
155+ pointBorderColor: ' #fff' ,
156+ pointHoverBackgroundColor: ' #fff' ,
157+ pointHoverBorderColor: ' rgba(255,99,132,1)' ,
158+ tooltipLabelColor: ' rgba(255,99,132,1)' ,
159+ data: [28 ,48 ,40 ,19 ,96 ,27 ,100 ]
160+ }
161+ ],
162+ }}
75163 options= {{
76164 aspectRatio: 1.5 ,
77165 tooltips: {
78166 enabled: true
79167 }
80168 }}
81- labels= {[
82- ' Eating' ,' Drinking' ,' Sleeping' ,' Designing' ,
83- ' Coding' ,' Cycling' ,' Running'
84- ]}
85169/ >
86170 )
87171}
88172...
89173` ` `
90174
91- ---
92-
93- - bootstrapped with [nwb](https://github.com/insin/nwb) toolkit
94-
95175#####` npm run` scripts
96176
97- ` package .json ` is configured with` " scripts" ` we can use with` npm run` while developing the project.
177+ ` package .json ` is configured with` " scripts" ` we can use with` npm run` or ` yarn ` while developing the project.
98178
99- Command | Description |
100- --- | ---
101- ` npm start` | start a development server for the demo app
102- ` npm test` | run tests
103- ` npm run test: coverage` | run tests and produce a code coverage report in` coverage/ `
104- ` npm run test: watch` | start a test server and re-run tests on every change
105- ` npm run build` | prepare for publishing to npm
106- ` npm run clean` | delete built resources
179+ | Command | Description |
180+ | ------------------------------- | ------------------------------ |
181+ |` npm run build` or` yarn build` | build production ready version |
182+ |` npm run lint` or` yarn lint` | run eslint |
107183
108- #### see also:
109- - [Developing React Components and Libraries with nwb](https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#developing-react-components-and-libraries-with-nwb)