İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
# Cartesian Axes
|
||||
|
||||
Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes are used for line, bar, and bubble charts. Four cartesian axes are included in Chart.js by default.
|
||||
|
||||
* [linear](./linear.md#linear-cartesian-axis)
|
||||
* [logarithmic](./logarithmic.md#logarithmic-cartesian-axis)
|
||||
* [category](./category.md#category-cartesian-axis)
|
||||
* [time](./time.md#time-cartesian-axis)
|
||||
|
||||
## Common Configuration
|
||||
|
||||
All of the included cartesian axes support a number of common options.
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| ---- | ---- | ------- | -----------
|
||||
| `type` | `string` | | Type of scale being employed. Custom scales can be created and registered with a string key. This allows changing the type of an axis for a chart.
|
||||
| `position` | `string` | | Position of the axis in the chart. Possible values are: `'top'`, `'left'`, `'bottom'`, `'right'`
|
||||
| `offset` | `boolean` | `false` | If true, extra space is added to the both edges and the axis is scaled to fit into the chart area. This is set to `true` for a bar chart by default.
|
||||
| `id` | `string` | | The ID is used to link datasets and scale axes together. [more...](#axis-id)
|
||||
| `gridLines` | `object` | | Grid line configuration. [more...](../styling.md#grid-line-configuration)
|
||||
| `scaleLabel` | `object` | | Scale title configuration. [more...](../labelling.md#scale-title-configuration)
|
||||
| `ticks` | `object` | | Tick configuration. [more...](#tick-configuration)
|
||||
|
||||
### Tick Configuration
|
||||
The following options are common to all cartesian axes but do not apply to other axes.
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| ---- | ---- | ------- | -----------
|
||||
| `min` | `number` | | User defined minimum value for the scale, overrides minimum value from data.
|
||||
| `max` | `number` | | User defined maximum value for the scale, overrides maximum value from data.
|
||||
| `sampleSize` | `number` | `ticks.length` | The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
|
||||
| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what.
|
||||
| `autoSkipPadding` | `number` | `0` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled.
|
||||
| `labelOffset` | `number` | `0` | Distance in pixels to offset the label from the centre point of the tick (in the x direction for the x axis, and the y direction for the y axis). *Note: this can cause labels at the edges to be cropped by the edge of the canvas*
|
||||
| `maxRotation` | `number` | `50` | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.*
|
||||
| `minRotation` | `number` | `0` | Minimum rotation for tick labels. *Note: Only applicable to horizontal scales.*
|
||||
| `mirror` | `boolean` | `false` | Flips tick labels around axis, displaying the labels inside the chart instead of outside. *Note: Only applicable to vertical scales.*
|
||||
| `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.
|
||||
|
||||
```javascript
|
||||
var myChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
// This dataset appears on the first axis
|
||||
yAxisID: 'first-y-axis'
|
||||
}, {
|
||||
// This dataset appears on the second axis
|
||||
yAxisID: 'second-y-axis'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
yAxes: [{
|
||||
id: 'first-y-axis',
|
||||
type: 'linear'
|
||||
}, {
|
||||
id: 'second-y-axis',
|
||||
type: 'linear'
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Creating Multiple Axes
|
||||
|
||||
With cartesian axes, it is possible to create multiple X and Y axes. To do so, you can add multiple configuration objects to the `xAxes` and `yAxes` properties. When adding new axes, it is important to ensure that you specify the type of the new axes as default types are **not** used in this case.
|
||||
|
||||
In the example below, we are creating two Y axes. We then use the `yAxisID` property to map the datasets to their correct axes.
|
||||
|
||||
```javascript
|
||||
var myChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
data: [20, 50, 100, 75, 25, 0],
|
||||
label: 'Left dataset',
|
||||
|
||||
// This binds the dataset to the left y axis
|
||||
yAxisID: 'left-y-axis'
|
||||
}, {
|
||||
data: [0.1, 0.5, 1.0, 2.0, 1.5, 0],
|
||||
label: 'Right dataset',
|
||||
|
||||
// This binds the dataset to the right y axis
|
||||
yAxisID: 'right-y-axis'
|
||||
}],
|
||||
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
yAxes: [{
|
||||
id: 'left-y-axis',
|
||||
type: 'linear',
|
||||
position: 'left'
|
||||
}, {
|
||||
id: 'right-y-axis',
|
||||
type: 'linear',
|
||||
position: 'right'
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,69 @@
|
||||
# Category Cartesian Axis
|
||||
|
||||
If global configuration is used, labels are drawn from one of the label arrays included in the chart data. If only `data.labels` is defined, this will be used. If `data.xLabels` is defined and the axis is horizontal, this will be used. Similarly, if `data.yLabels` is defined and the axis is vertical, this property will be used. Using both `xLabels` and `yLabels` together can create a chart that uses strings for both the X and Y axes.
|
||||
|
||||
Specifying any of the settings above defines the x axis as `type: 'category'` if not defined otherwise. For more fine-grained control of category labels it is also possible to add `labels` as part of the category axis definition. Doing so does not apply the global defaults.
|
||||
|
||||
## Category Axis Definition
|
||||
|
||||
Globally:
|
||||
|
||||
```javascript
|
||||
let chart = new Chart(ctx, {
|
||||
type: ...
|
||||
data: {
|
||||
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
|
||||
datasets: ...
|
||||
}
|
||||
});
|
||||
```
|
||||
As part of axis definition:
|
||||
|
||||
```javascript
|
||||
let chart = new Chart(ctx, {
|
||||
type: ...
|
||||
data: ...
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'category',
|
||||
labels: ['January', 'February', 'March', 'April', 'May', 'June']
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Tick Configuration Options
|
||||
|
||||
The category scale provides the following options for configuring tick marks. They are nested in the `ticks` sub object. These options extend the [common tick configuration](README.md#tick-configuration).
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| ---- | ---- | ------- | -----------
|
||||
| `labels` | `string[]` | - | An array of labels to display.
|
||||
| `min` | `string` | | The minimum item to display. [more...](#min-max-configuration)
|
||||
| `max` | `string` | | The maximum item to display. [more...](#min-max-configuration)
|
||||
|
||||
## Min Max Configuration
|
||||
For both the `min` and `max` properties, the value must be in the `labels` array. In the example below, the x axis would only display "March" through "June".
|
||||
|
||||
```javascript
|
||||
let chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
data: [10, 20, 30, 40, 50, 60]
|
||||
}],
|
||||
labels: ['January', 'February', 'March', 'April', 'May', 'June']
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
ticks: {
|
||||
min: 'March'
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,73 @@
|
||||
# Linear Cartesian Axis
|
||||
|
||||
The linear scale is use to chart numerical data. It can be placed on either the x or y axis. The scatter chart type automatically configures a line chart to use one of these scales for the x axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis.
|
||||
|
||||
## Tick Configuration Options
|
||||
|
||||
The following options are provided by the linear scale. They are all located in the `ticks` sub options. These options extend the [common tick configuration](README.md#tick-configuration).
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| ---- | ---- | ------- | -----------
|
||||
| `beginAtZero` | `boolean` | | if true, scale will include 0 if it is not already included.
|
||||
| `maxTicksLimit` | `number` | `11` | Maximum number of ticks and gridlines to show.
|
||||
| `precision` | `number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
|
||||
| `stepSize` | `number` | | User defined fixed step size for the scale. [more...](#step-size)
|
||||
| `suggestedMax` | `number` | | Adjustment used when calculating the maximum data value. [more...](#axis-range-settings)
|
||||
| `suggestedMin` | `number` | | Adjustment used when calculating the minimum data value. [more...](#axis-range-settings)
|
||||
|
||||
## Axis Range Settings
|
||||
|
||||
Given the number of axis range settings, it is important to understand how they all interact with each other.
|
||||
|
||||
The `suggestedMax` and `suggestedMin` settings only change the data values that are used to scale the axis. These are useful for extending the range of the axis while maintaining the auto fit behaviour.
|
||||
|
||||
```javascript
|
||||
let minDataValue = Math.min(mostNegativeValue, options.ticks.suggestedMin);
|
||||
let maxDataValue = Math.max(mostPositiveValue, options.ticks.suggestedMax);
|
||||
```
|
||||
|
||||
In this example, the largest positive value is 50, but the data maximum is expanded out to 100. However, because the lowest data value is below the `suggestedMin` setting, it is ignored.
|
||||
|
||||
```javascript
|
||||
let chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{
|
||||
label: 'First dataset',
|
||||
data: [0, 20, 40, 50]
|
||||
}],
|
||||
labels: ['January', 'February', 'March', 'April']
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
suggestedMin: 50,
|
||||
suggestedMax: 100
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
In contrast to the `suggested*` settings, the `min` and `max` settings set explicit ends to the axes. When these are set, some data points may not be visible.
|
||||
|
||||
## Step Size
|
||||
If set, the scale ticks will be enumerated by multiple of `stepSize`, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm.
|
||||
|
||||
This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5`.
|
||||
|
||||
```javascript
|
||||
let options = {
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
max: 5,
|
||||
min: 0,
|
||||
stepSize: 0.5
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
# Logarithmic Cartesian Axis
|
||||
|
||||
The logarithmic scale is use to chart numerical data. It can be placed on either the x or y axis. As the name suggests, logarithmic interpolation is used to determine where a value lies on the axis.
|
||||
|
||||
## Tick Configuration Options
|
||||
|
||||
The logarithmic scale options extend the [common tick configuration](README.md#tick-configuration). This scale does not define any options that are unique to it.
|
||||
@@ -0,0 +1,157 @@
|
||||
# Time Cartesian Axis
|
||||
|
||||
The time scale is used to display times and dates. When building its ticks, it will automatically calculate the most comfortable unit base on the size of the scale.
|
||||
|
||||
## Date Adapters
|
||||
|
||||
The time scale requires both a date library and corresponding adapter to be present. By default, Chart.js includes an adapter for Moment.js. You may wish to [exclude moment](../../getting-started/integration.md) and choose from [other available adapters](https://github.com/chartjs/awesome#adapters) instead.
|
||||
|
||||
## Data Sets
|
||||
|
||||
### Input Data
|
||||
|
||||
The x-axis data points may additionally be specified via the `t` or `x` attribute when using the time scale.
|
||||
|
||||
```javascript
|
||||
data: [{
|
||||
x: new Date(),
|
||||
y: 1
|
||||
}, {
|
||||
t: new Date(),
|
||||
y: 10
|
||||
}]
|
||||
```
|
||||
|
||||
### Date Formats
|
||||
|
||||
When providing data for the time scale, Chart.js supports all of the formats that Moment.js accepts. See [Moment.js docs](https://momentjs.com/docs/#/parsing/) for details.
|
||||
|
||||
## Configuration Options
|
||||
|
||||
The following options are provided by the time scale. You may also set options provided by the [common tick configuration](README.md#tick-configuration).
|
||||
|
||||
| Name | Type | Default | Description
|
||||
| ---- | ---- | ------- | -----------
|
||||
| `adapters.date` | `object` | `{}` | Options for adapter for external date library if that adapter needs or supports options
|
||||
| `distribution` | `string` | `'linear'` | How data is plotted. [more...](#scale-distribution)
|
||||
| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](#scale-bounds)
|
||||
| `ticks.source` | `string` | `'auto'` | How ticks are generated. [more...](#ticks-source)
|
||||
| `time.displayFormats` | `object` | | Sets how different time units are displayed. [more...](#display-formats)
|
||||
| `time.isoWeekday` | `boolean` | `false` | If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
|
||||
| `time.parser` | <code>string|function</code> | | Custom parser for dates. [more...](#parser)
|
||||
| `time.round` | `string` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units.
|
||||
| `time.tooltipFormat` | `string` | | The Moment.js format string to use for the tooltip.
|
||||
| `time.unit` | `string` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#time-units) section below for details.
|
||||
| `time.stepSize` | `number` | `1` | The number of units between grid lines.
|
||||
| `time.minUnit` | `string` | `'millisecond'` | The minimum display format to be used for a time unit.
|
||||
|
||||
### Time Units
|
||||
|
||||
The following time measurements are supported. The names can be passed as strings to the `time.unit` config option to force a certain unit.
|
||||
|
||||
* `'millisecond'`
|
||||
* `'second'`
|
||||
* `'minute'`
|
||||
* `'hour'`
|
||||
* `'day'`
|
||||
* `'week'`
|
||||
* `'month'`
|
||||
* `'quarter'`
|
||||
* `'year'`
|
||||
|
||||
For example, to create a chart with a time scale that always displayed units per month, the following config could be used.
|
||||
|
||||
```javascript
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
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
|
||||
--- | --- | ---
|
||||
`millisecond` | `'h:mm:ss.SSS a'` | `'11:20:01.123 AM'`
|
||||
`second` | `'h:mm:ss a'` | `'11:20:01 AM'`
|
||||
`minute` | `'h:mm a'` | `'11:20 AM'`
|
||||
`hour` | `'hA'` | `'11AM'`
|
||||
`day` | `'MMM D'` | `'Sep 4'`
|
||||
`week` | `'ll'` | `'Sep 4 2015'`
|
||||
`month` | `'MMM YYYY'` | `'Sep 2015'`
|
||||
`quarter` | `'[Q]Q - YYYY'` | `'Q3 - 2015'`
|
||||
`year` | `'YYYY'` | `'2015'`
|
||||
|
||||
For example, to set the display format for the `quarter` unit to show the month and year, the following config would be passed to the chart constructor.
|
||||
|
||||
```javascript
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
time: {
|
||||
displayFormats: {
|
||||
quarter: 'MMM YYYY'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Scale Distribution
|
||||
|
||||
The `distribution` property controls the data distribution along the scale:
|
||||
|
||||
* `'linear'`: data are spread according to their time (distances can vary)
|
||||
* `'series'`: data are spread at the same distance from each other
|
||||
|
||||
```javascript
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
distribution: 'series'
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Scale Bounds
|
||||
|
||||
The `bounds` property controls the scale boundary strategy (bypassed by `min`/`max` time options).
|
||||
|
||||
* `'data'`: makes sure data are fully visible, labels outside are removed
|
||||
* `'ticks'`: makes sure ticks are fully visible, data outside are truncated
|
||||
|
||||
### Ticks Source
|
||||
|
||||
The `ticks.source` property controls the ticks generation.
|
||||
|
||||
* `'auto'`: generates "optimal" ticks based on scale size and time options
|
||||
* `'data'`: generates ticks from data (including labels from data `{t|x|y}` objects)
|
||||
* `'labels'`: generates ticks from user given `labels` ONLY
|
||||
|
||||
### Parser
|
||||
If this property is defined as a string, it is interpreted as a custom format to be used by Moment.js to parse the date.
|
||||
|
||||
If this is a function, it must return a Moment.js object given the appropriate data value.
|
||||
Reference in New Issue
Block a user