Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var myChart = new Chart(ctx, {
},
options: {
scales: {
yAxes: [{
y: {
beginAtZero: true
}]
}
}
}
});
Expand Down
17 changes: 8 additions & 9 deletions docs/axes/cartesian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ The following options are common to all cartesian axes but do not apply to other
| `padding` | `number` | `0` | Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.

### Axis ID
The properties `dataset.xAxisID` or `dataset.yAxisID` have to match the scale properties `scales.xAxes.id` or `scales.yAxes.id`. This is especially needed if multi-axes charts are used.

The properties `dataset.xAxisID` or `dataset.yAxisID` have to match to `scales` property. This is especially needed if multi-axes charts are used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might sound more natural to say "have to match a property of scales"


```javascript
var myChart = new Chart(ctx, {
Expand All @@ -54,11 +55,10 @@ var myChart = new Chart(ctx, {
},
options: {
scales: {
yAxes: [{
id: 'first-y-axis',
'first-y-axis': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this syntax works though it's a bit awkward as an example. Maybe firstYAxis would be easier since it wouldn't require the single quotes

type: 'linear'
}, {
id: 'second-y-axis',
},
'second-y-axis': {
type: 'linear'
}]
}
Expand Down Expand Up @@ -93,12 +93,11 @@ var myChart = new Chart(ctx, {
},
options: {
scales: {
yAxes: [{
id: 'left-y-axis',
'left-y-axis': {
type: 'linear',
position: 'left'
}, {
id: 'right-y-axis',
},
'right-y-axis': {
type: 'linear',
position: 'right'
}]
Expand Down
8 changes: 4 additions & 4 deletions docs/axes/cartesian/category.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ let chart = new Chart(ctx, {
data: ...
options: {
scales: {
xAxes: [{
x: {
type: 'category',
labels: ['January', 'February', 'March', 'April', 'May', 'June']
}]
}
}
}
});
Expand Down Expand Up @@ -58,9 +58,9 @@ let chart = new Chart(ctx, {
},
options: {
scales: {
xAxes: [{
x: {
min: 'March'
}]
}
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions docs/axes/cartesian/linear.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ let chart = new Chart(ctx, {
},
options: {
scales: {
yAxes: [{
y: {
suggestedMin: 50,
suggestedMax: 100
}]
}
}
}
});
Expand All @@ -65,13 +65,13 @@ This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5
```javascript
let options = {
scales: {
yAxes: [{
y: {
max: 5,
min: 0,
ticks: {
stepSize: 0.5
}
}]
}
}
};
```
13 changes: 7 additions & 6 deletions docs/axes/cartesian/time.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,19 @@ var chart = new Chart(ctx, {
data: data,
options: {
scales: {
xAxes: [{
x: {
type: 'time',
time: {
unit: 'month'
}
}]
}
}
}
});
```

### Display Formats

The following display formats are used to configure how different time units are formed into strings for the axis tick marks. See [Moment.js](https://momentjs.com/docs/#/displaying/format/) for the allowable format strings.

Name | Default | Example
Expand All @@ -101,14 +102,14 @@ var chart = new Chart(ctx, {
data: data,
options: {
scales: {
xAxes: [{
x: {
type: 'time',
time: {
displayFormats: {
quarter: 'MMM YYYY'
}
}
}]
}
}
}
});
Expand All @@ -127,10 +128,10 @@ var chart = new Chart(ctx, {
data: data,
options: {
scales: {
xAxes: [{
x: {
type: 'time',
distribution: 'series'
}]
}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions docs/axes/labelling.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ var chart = new Chart(ctx, {
data: data,
options: {
scales: {
yAxes: [{
y: {
ticks: {
// Include a dollar sign in the ticks
callback: function(value, index, values) {
return '$' + value;
}
}
}]
}
}
}
});
Expand Down
25 changes: 15 additions & 10 deletions docs/charts/bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ A bar chart provides a way of showing data values represented as vertical bars.
},
"options": {
"scales": {
"yAxes": [{
"y": {
"beginAtZero": true
}]
}
}
}
}
Expand Down Expand Up @@ -160,14 +160,17 @@ data: {
}]
};
```

### barThickness

If this value is a number, it is applied to the width of each bar, in pixels. When this is enforced, `barPercentage` and `categoryPercentage` are ignored.

If set to `'flex'`, the base sample widths are calculated automatically based on the previous and following samples so that they take the full available widths without overlap. Then, bars are sized using `barPercentage` and `categoryPercentage`. There is no gap when the percentage options are 1. This mode generates bars with different widths when data are not evenly spaced.

If not set (default), the base sample widths are calculated using the smallest interval that prevents bar overlapping, and bars are sized using `barPercentage` and `categoryPercentage`. This mode always generates bars equally sized.

## Scale Configuration

The bar chart sets unique default values for the following configuration from the associated `scale` options:

| Name | Type | Default | Description
Expand All @@ -180,16 +183,17 @@ The bar chart sets unique default values for the following configuration from th
```javascript
options = {
scales: {
xAxes: [{
x: {
gridLines: {
offsetGridLines: true
}
}]
}
}
};
```

### offsetGridLines

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, which is the space between the grid lines. If false, the grid line will go right down the middle of the bars. This is set to true for a category scale in a bar chart while false for other scales or chart types by default.

## Default Options
Expand Down Expand Up @@ -249,12 +253,12 @@ var stackedBar = new Chart(ctx, {
data: data,
options: {
scales: {
xAxes: [{
x: {
stacked: true
}],
yAxes: [{
},
y: {
stacked: true
}]
}
}
}
});
Expand All @@ -267,6 +271,7 @@ The following dataset properties are specific to stacked bar charts.
| `stack` | `string` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack).

## Horizontal Bar Chart

A horizontal bar chart is a variation on a vertical bar chart. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
{% chartjs %}
{
Expand Down Expand Up @@ -300,9 +305,9 @@ A horizontal bar chart is a variation on a vertical bar chart. It is sometimes u
},
"options": {
"scales": {
"xAxes": [{
"x": {
"beginAtZero": true
}]
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/charts/line.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ var stackedLine = new Chart(ctx, {
data: data,
options: {
scales: {
yAxes: [{
y: {
stacked: true
}]
}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions docs/charts/mixed.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ At this point we have a chart rendering how we'd like. It's important to note th
},
"options": {
"scales": {
"yAxes": [{
"y": {
"beginAtZero": true
}]
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/charts/scatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ var scatterChart = new Chart(ctx, {
},
options: {
scales: {
xAxes: [{
x: {
type: 'linear',
position: 'bottom'
}]
}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions docs/developers/axes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ var lineChart = new Chart(ctx, {
type: 'line',
options: {
scales: {
yAxes: [{
y: {
type: 'myScale' // this is the same key that was passed to the registerScaleType function
}]
}
}
}
});
Expand Down
29 changes: 14 additions & 15 deletions docs/developers/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function updateConfigAsNewObject(chart) {
text: 'Chart.js'
},
scales: {
xAxes: [{
x: {
display: true
}],
yAxes: [{
},
y: {
display: true
}]
}
}
};
chart.update();
Expand All @@ -64,30 +64,29 @@ Variables referencing any one from `chart.scales` would be lost after updating s

```javascript
function updateScales(chart) {
var xScale = chart.scales['x-axis-0'];
var yScale = chart.scales['y-axis-0'];
var xScale = chart.scales.x;
var yScale = chart.scales.y;
chart.options.scales = {
xAxes: [{
id: 'newId',
newId: {
display: true
}],
yAxes: [{
},
y: {
display: true,
type: 'logarithmic'
}]
}
};
chart.update();
// need to update the reference
xScale = chart.scales['newId'];
yScale = chart.scales['y-axis-0'];
xScale = chart.scales.newId;
yScale = chart.scales.y;
}
```

You can also update a specific scale either by specifying its index or id.
You can also update a specific scale either by its id.

```javascript
function updateScale(chart) {
chart.options.scales.yAxes[0] = {
chart.options.scales.y = {
type: 'logarithmic'
};
chart.update();
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ var myChart = new Chart(ctx, {
},
options: {
scales: {
yAxes: [{
y: {
beginAtZero: true
}]
}
}
}
});
Expand Down
Loading