Skip to content

Commit

Permalink
Docs proofreading
Browse files Browse the repository at this point in the history
  • Loading branch information
timocov committed Jun 9, 2020
1 parent 6a469af commit ef8cfa4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
26 changes: 13 additions & 13 deletions docs/3.0-breaking-changes.md
@@ -1,38 +1,38 @@
# Version 3.0 breaking changes

Lightweight charts library 3.0 announces the major improvements: supporting two price scales and improving the time scale API.
In order of keeping API clear and consistent, we decided to allow breaking change of the API.
In order of keep the API clear and consistent, we decided to allow breaking change of the API.

In this document you can find migration guide from previous version to 3.0.
In this document you can find the migration guide from the previous version to 3.0.

## Time Scale API

Previously to handle changing visible time range you needed to use `subscribeVisibleTimeRangeChange` and `unsubscribeVisibleTimeRangeChange` to subscribe and unsubscribe from visible range event.
Previously, to handle changing visible time range you needed to use `subscribeVisibleTimeRangeChange` and `unsubscribeVisibleTimeRangeChange` to subscribe and unsubscribe from visible range events.
These methods were available in the chart object (e.g. you call it like `chart.subscribeVisibleTimeRangeChange(func)`).

In 3.0 in order to make API more consistency with the new API we decided to move these methods to [time scale API](./time-scale.md)
In 3.0 in order to make API more consistent with the new API we decided to move these methods to [time scale API](./time-scale.md)
(along with the new subscription methods [`subscribeVisibleLogicalRangeChange`](./time-scale.md#subscribevisiblelogicalrangechange) and [`unsubscribeVisibleLogicalRangeChange`](./time-scale.md#unsubscribevisiblelogicalrangechange)).

So, to migrate your code to 3.0 you need to just replace:
So, to migrate your code to 3.0 you just need to replace:

- `chart.subscribeVisibleTimeRangeChange` with `chart.timeScale().subscribeVisibleTimeRangeChange`
- `chart.unsubscribeVisibleTimeRangeChange` with `chart.timeScale().unsubscribeVisibleTimeRangeChange`

## Two price scales

We understand disadvantages of breaking changes in the API, so we have not removed support of the current API at all, but have deprecated it, so the most common cases will continue working.
We understand disadvantages of breaking changes in the API, so we have not removed support of the current API at all, but have deprecated it, so the most common cases will continue to work.

You could refer new API [here](./price-scale.md).
You could refer to the new API [here](./price-scale.md).

Following are migration rules.

### Default behavior

Default behavior is not changed. If you do not specify price scale options, the chart will have right price scale visible and all the series will assign to it.
Default behavior is not changed. If you do not specify price scale options, the chart will have the right price scale visible and all the series will assign to it.

### Left price scale

If you need the price scale to be drawn on the left side, you should make following changes.
If you need the price scale to be drawn on the left side, you should make the following changes.
instead of

```javascript
Expand Down Expand Up @@ -64,7 +64,7 @@ const histSeries = chart.addHistogramSeries({
});
```

New version fully supports this case via old API, however this support will be removed in the future releases.
New version fully supports this case via the old API, however this support will be removed in the future releases.

### No price scale

Expand All @@ -91,7 +91,7 @@ const chart = LightweightCharts.createChart(container, {
});
```

New version fully supports this case via old API, however this support will be removed in the future releases.
New version fully supports this case via the old API, however this support will be removed in the future releases.

### Creating overlay

Expand All @@ -112,7 +112,7 @@ const histogramSeries = chart.addHistogramSeries({
});
```

New version fully supports this case via old API, however this support will be removed in the future releases.
New version fully supports this case via the old API, however this support will be removed in the future releases.

### Move price scale from right to left or vice versa

Expand Down Expand Up @@ -155,4 +155,4 @@ mainSeries.applyOptions({
});
```

New version does not support this case via old API, so, if you use it, you should migrate your code in order of keeping it working.
New version does not support this case via the old API, so, if you use it, you should migrate your code in order of keeping it working.
4 changes: 2 additions & 2 deletions docs/constants.md
Expand Up @@ -75,8 +75,8 @@ It has the following values:

It has the following values:

- `TickMarkType.Year` - the tick mark represents start of the year (e.g. it's the first tick mark in a year).
- `TickMarkType.Month` - the tick mark represents start of the month (e.g. it's the first tick mark in a month).
- `TickMarkType.Year` - the tick mark represents the start of the year (e.g. it's the first tick mark in a year).
- `TickMarkType.Month` - the tick mark represents the start of the month (e.g. it's the first tick mark in a month).
- `TickMarkType.DayOfMonth` - the tick mark represents a day of the month.
- `TickMarkType.Time` - the tick mark represents a time without seconds.
- `TickMarkType.TimeWithSeconds` - the tick mark represents a full time format.
24 changes: 12 additions & 12 deletions docs/price-scale.md
Expand Up @@ -3,8 +3,8 @@
Price Scale is an object that maps prices to coordinates and vice versa.
The rules of converting depend on price scale mod, visible height of chart and visible part of data.

Chart always has two predefined price scales: left and right, and unlimited number of overlay scales.
Left and right price scales could be visible, overlay price scales are always hidden, so the user cannot interact them directly.
Chart always has two predefined price scales: left and right, and an unlimited number of overlay scales.
Left and right price scales could be visible, overlay price scales are always hidden, so the user cannot interact with them directly.

## Autoscale

Expand All @@ -14,27 +14,27 @@ Overlay price scales are always autoscaled.

## PriceScale ID

Each price scale has corresponsing ID to refer it via API. Left and right price scales have predefined IDs `left` and `right`.
Each price scale has a corresponding ID to refer to it via API. Left and right price scales have predefined IDs `left` and `right`.
While creating a series, you could specify PriceScaleID.
If this id refers to already existing price scale, new series will share the price scale with already existing series.
If specified price scale does not exist, it will be implicitly created.
If this id refers to an already existing price scale, the new series will share the price scale with the already existing series.
If the specified price scale does not exist, it will be implicitly created.
So to create two series on the same overlay price scale just specify the same `priceScaleId` for them.
You could get `id` of the scale with `PriceScaleApi.id` method.
You could get the `id` of the scale with `PriceScaleApi.id` method.

## Percentage scales

Percentage mode of price scale allows relative comparing of series.
Percentage mode of price scale allows relative comparison of series.
All the serieses attached to the percentage scale are placed to have the first visible data item on the same point.
Percentage scales are always autoscaled.

## Logarithmic scales

The reason of having logarithmic scales is comparing relative change instead of absolute change.
On regular scale every candle with 100-points change has the same height.
On logarithmic scale every candle with 2% change has the same height.
Logarithmic scale cannot be percentage.
The reason for having logarithmic scales is comparing relative change instead of absolute change.
On a regular scale every candle with 100-points change has the same height.
On a logarithmic scale every candle with 2% change has the same height.
Logarithmic scale cannot be displayed as a percentage.

## Equality of price scales

Lightweight charts library does not guarantee to return the same instance of `PriceScaleApi` object while returning the same actual price scale.
So you should never compare objects of `PriceScaleApi`, comapre `PriceScaleApi.id()` values instead.
So you should never compare objects of `PriceScaleApi`, compare `PriceScaleApi.id()` values instead.
12 changes: 6 additions & 6 deletions docs/series-basics.md
Expand Up @@ -57,7 +57,7 @@ const lineSeries = chart.addLineSeries({

### Binding to price scale

When adding any series to a chart, you can specify if you want target series to be attached to a certain price axis - left or right.
When adding any series to a chart, you can specify if you want the target series to be attached to a certain price axis - left or right.
By default, series are attached to the right price axis.
This means one can scale the series with price axis. Note that price axis visible range depends on series values.

Expand All @@ -67,8 +67,8 @@ const lineSeries = chart.addLineSeries({
});
```

In contrast, overlay series just draws itself on a chart independent from the visible price axis.
To create overlay specify unique id as a `priceScaleId` or just keep is as empty string.
In contrast, an overlay series just draws itself on a chart independent from the visible price axis.
To create an overlay specify a unique id as a `priceScaleId` or just keep is as an empty string.

```javascript
const lineSeries = chart.addLineSeries({
Expand Down Expand Up @@ -143,7 +143,7 @@ chart.applyOptions({
### Overriding autoscale
By default, the chart scales data automatically based on visible data range. However, for some reasons one could need overriding this behavior.
By default, the chart scales data automatically based on visible data range. However, for some reasons one could require overriding this behavior.
There is an option called `autoscaleProvider` that allows overriding visible price range for series
```javascript
Expand Down Expand Up @@ -493,10 +493,10 @@ The returned value is an object with the following properties:
- `barsBefore` - a number of bars between the `from` index of the passed logical range and the first series' bar
- `barsAfter` - a number of bars between the `to` index of the passed logical range and the last series' bar
Positive value in `barsBefore` field means that there are some bars before (out of logical range from the left) the `from` logical index in the series.
Positive value in the `barsBefore` field means that there are some bars before (out of logical range from the left) the `from` logical index in the series.
Negative value means that the first series' bar is inside the passed logical range, and between the first series' bar and the `from` logical index are some bars.
Positive value in `barsAfter` field means that there are some bars after (out of logical range from the right) the `to` logical index in the series.
Positive value in the `barsAfter` field means that there are some bars after (out of logical range from the right) the `to` logical index in the series.
Negative value means that the last series' bar is inside the passed logical range, and between the last series' bar and the `to` logical index are some bars.
```javascript
Expand Down
8 changes: 4 additions & 4 deletions docs/time-scale.md
Expand Up @@ -147,7 +147,7 @@ chart.timeScale().fitContent();
### timeToCoordinate

Converts a time to local `x` coordinate.
The argument is [Time](./time.md) that needs to be converted to a coordinate.
The argument is [Time](./time.md) that needs to be converted into a coordinate.

Returns `x` coordinate of a bar with passed time or `null` if no bar found.

Expand All @@ -158,7 +158,7 @@ chart.timeScale().timeToCoordinate('1990-04-24');
### coordinateToTime

Converts `x` coordinate to [Time](./time.md).
The argument is `x` coordinate that needs to be converted to a time.
The argument is the `x` coordinate that needs to be converted into a time.

Returns [Time](./time.md) of a bar that is located on the passed coordinate or `null` if there are no bars on that coordinate.

Expand Down Expand Up @@ -248,9 +248,9 @@ Before that point all indexes are negative, starting from that point - positive.

Indexes might have fractional parts, for instance 4.2, due to the time-scale being continuous rather than discrete.

Integer part of logical index means index of the fully visible bar (see image below).
Integer part of the logical index means index of the fully visible bar (see image below).
Thus, if we have 5.2 as the last visible logical index (`to` field), that means that the last visible bar has index 5, but we also have partially visible (for 20%) 6th bar.
Half (e.g. 1.5, 3.5, 10.5) means exactly middle of the bar.
Half (e.g. 1.5, 3.5, 10.5) means exactly a middle of the bar.

![Logical range](./assets/logical-range.png "Logical range")

Expand Down

0 comments on commit ef8cfa4

Please sign in to comment.