| `maxBarThickness` | `number` | | Set this to ensure that bars are not sized thicker than this.
| `minBarLength` | `number` | | Set this to ensure that bars have a minimum length in pixels.
-### Example Usage
+### Example dataset configuration
```javascript
data: {
| `offset` | `boolean` | `true` | If true, extra space is added to both edges and the axis is scaled to fit into the chart area.
| `gridLines.offsetGridLines` | `boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval. If false, the grid line will go right down the middle of the bars. [more...](#offsetgridlines)
-### Example Usage
+### Example scale configuration
```javascript
options = {
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
- axis: 'y',
+ axis: 'y',
label: 'My First Dataset',
data: [65, 59, 80, 81, 56, 55, 40],
fill: false,
}]
},
options: {
- indexAxis: 'y',
+ indexAxis: 'y',
scales: {
x: {
beginAtZero: true
type: 'bar',
data: data,
options: {
- indexAxis: 'y'
+ indexAxis: 'y'
}
});
```
-### Config Options
+### Horizontal Bar Chart config Options
The configuration options for the horizontal bar chart are the same as for the [bar chart](#scale-configuration). However, any options specified on the x-axis in a bar chart, are applied to the y-axis in a horizontal bar chart.
The default for this property is `'x'` and thus will show horizontal lines.
export const ExampleChart1 = () => {
- useEffect(() => {
- const cfg = {
- type: 'line',
- data: {
- labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
- datasets: [{
- axis: 'y',
- label: 'My First Dataset',
- data: [65, 59, 80, 81, 56, 55, 40],
- fill: false,
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(255, 159, 64, 0.2)',
- 'rgba(255, 205, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- 'rgba(201, 203, 207, 0.2)'
- ],
- borderColor: [
- 'rgb(255, 99, 132)',
- 'rgb(255, 159, 64)',
- 'rgb(255, 205, 86)',
- 'rgb(75, 192, 192)',
- 'rgb(54, 162, 235)',
- 'rgb(153, 102, 255)',
- 'rgb(201, 203, 207)'
- ],
- borderWidth: 1
- }]
- },
- options: {
- indexAxis: 'y',
- scales: {
- x: {
- beginAtZero: true
- }
- }
- }
- };
- const chart = new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg);
- return () => chart.destroy();
- });
- return <div className="chartjs-wrapper"><canvas id="chartjs-1" className="chartjs"></canvas></div>;
+ useEffect(() => {
+ const cfg = {
+ type: 'line',
+ data: {
+ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
+ datasets: [{
+ axis: 'y',
+ label: 'My First Dataset',
+ data: [65, 59, 80, 81, 56, 55, 40],
+ fill: false,
+ backgroundColor: [
+ 'rgba(255, 99, 132, 0.2)',
+ 'rgba(255, 159, 64, 0.2)',
+ 'rgba(255, 205, 86, 0.2)',
+ 'rgba(75, 192, 192, 0.2)',
+ 'rgba(54, 162, 235, 0.2)',
+ 'rgba(153, 102, 255, 0.2)',
+ 'rgba(201, 203, 207, 0.2)'
+ ],
+ borderColor: [
+ 'rgb(255, 99, 132)',
+ 'rgb(255, 159, 64)',
+ 'rgb(255, 205, 86)',
+ 'rgb(75, 192, 192)',
+ 'rgb(54, 162, 235)',
+ 'rgb(153, 102, 255)',
+ 'rgb(201, 203, 207)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options: {
+ indexAxis: 'y',
+ scales: {
+ x: {
+ beginAtZero: true
+ }
+ }
+ }
+ };
+ const chart = new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg);
+ return () => chart.destroy();
+ });
+ return <div className="chartjs-wrapper"><canvas id="chartjs-1" className="chartjs"></canvas></div>;
}
<ExampleChart1/>
type: 'line',
data: data,
options: {
- indexAxis: 'y'
+ indexAxis: 'y'
}
});
```