Skip to content

Commit

Permalink
version 4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SlicedSilver committed Jul 26, 2024
1 parent 2ce43a3 commit 23c42eb
Show file tree
Hide file tree
Showing 32 changed files with 3,528 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ module.exports = [
{
name: 'CJS',
path: 'dist/lightweight-charts.production.cjs',
limit: '49.28 KB',
limit: '49.29 KB',
},
{
name: 'ESM',
path: 'dist/lightweight-charts.production.mjs',
limit: '49.21 KB',
limit: '49.22 KB',
},
{
name: 'Standalone-ESM',
path: 'dist/lightweight-charts.standalone.production.mjs',
limit: '50.93 KB',
limit: '50.94 KB',
},
{
name: 'Standalone',
path: 'dist/lightweight-charts.standalone.production.js',
limit: '50.97 KB',
limit: '50.98 KB',
},
];
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "4.1.8",
"version": "4.2.0",
"name": "lightweight-charts",
"author": "TradingView, Inc.",
"license": "Apache-2.0",
Expand Down
10 changes: 10 additions & 0 deletions website/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ sidebar_position: 8

<!-- markdownlint-disable no-emphasis-as-heading -->
<!-- ^ using emphasis as headings so we don't have duplicate headers -->
## 4.2.0

**Enhancements**

- Added new [`attributionLogo`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/LayoutOptions#attributionLogo) option to `LayoutOptions`. This feature displays the TradingView attribution logo on the main chart pane by default, helping users meet the library's licensing requirements for attribution.
- The TradingView attribution logo can be easily hidden by setting the `attributionLogo` option to `false` in the chart's `layout` option.
- Improved data validation for `OhlcData` and `SingleValueData`. Introduced `isFulfilledBarData` for `OhlcData` and `isFulfilledLineData` for `SingleValueData`, ensuring more accurate validation of data types. Contributed by [@mozeryansky](https://github.com/mozeryansky) (PR [#1579](https://github.com/tradingview/lightweight-charts/pull/1579), fixes [#1526](https://github.com/tradingview/lightweight-charts/issues/1526)).

[Changes since the last published version](https://github.com/tradingview/lightweight-charts/compare/v4.1.7..v4.2.0).

## 4.1.7

**Enhancements**
Expand Down
3 changes: 2 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"@types/react": "^17.0",
"cross-env": "~7.0.3",
"docusaurus-plugin-typedoc": "0.18.0",
"lightweight-charts": "~4.1.0",
"lightweight-charts": "~4.2.0",
"lightweight-charts-local": "file:..",
"lightweight-charts-3.8": "npm:lightweight-charts@~3.8.0",
"lightweight-charts-4.0": "npm:lightweight-charts@~4.0.1",
"lightweight-charts-4.1": "npm:lightweight-charts@~4.1.7",
"lightweight-charts-4.2": "npm:lightweight-charts@~4.2.0",
"prism-react-renderer": "~1.3.5",
"raw-loader": "~4.0.2",
"react": "^17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import type { Version } from '../../../../versions';
export type LightweightChartsApi38 = typeof import('lightweight-charts-3.8');
export type LightweightChartsApi40 = typeof import('lightweight-charts-4.0');
export type LightweightChartsApi41 = typeof import('lightweight-charts-4.1');
export type LightweightChartsApi42 = typeof import('lightweight-charts-4.2');
export type LightweightChartsApiCurrent = typeof import('../../../../..');

export interface LightweightChartsApiTypeMap {
'3.8': LightweightChartsApi38;
'4.0': LightweightChartsApi40;
'4.1': LightweightChartsApi41;
'4.2': LightweightChartsApi42;
current: LightweightChartsApiCurrent;
}

export interface LightweightChartsCreateChartTypeMap {
'3.8': LightweightChartsApi38['createChart'];
'4.0': LightweightChartsApi40['createChart'];
'4.1': LightweightChartsApi41['createChart'];
'4.2': LightweightChartsApi42['createChart'];
current: LightweightChartsApiCurrent['createChart'];
}

Expand All @@ -25,7 +28,7 @@ export type LightweightChartsVersion = Version | 'current';
export interface LightweightChartsApiGetterResult<T extends keyof LightweightChartsApiTypeMap> {
module: LightweightChartsApiTypeMap[T];
createChart: LightweightChartsApiTypeMap[T]['createChart'];
createChartEx: T extends '4.1' | 'current' ? LightweightChartsApiTypeMap[T]['createChartEx'] : undefined;
createChartEx: T extends '4.2' | '4.1' | 'current' ? LightweightChartsApiTypeMap[T]['createChartEx'] : undefined;
}

export type LightweightChartsApiGetters = {
Expand Down Expand Up @@ -81,6 +84,23 @@ export const importLightweightChartsVersion: LightweightChartsApiGetters = {

return { module, createChart, createChartEx: createChartEx as typeof module.createChartEx };
},
4.2: async (window: Window) => {
const module = await import('lightweight-charts-4.2');

const createChart: typeof module.createChart = (container: string | HTMLElement, options?: Parameters<typeof module.createChart>[1]) => {
const result = module.createChart(container, options);
addResizeHandler(window, container as HTMLElement, result.resize.bind(result));
return result;
};

const createChartEx = (container: string | HTMLElement, behaviour: Parameters<typeof module.createChartEx>[1], options?: Parameters<typeof module.createChartEx>[2]) => {
const result = module.createChartEx(container, behaviour, options);
addResizeHandler(window, container as HTMLElement, result.resize.bind(result));
return result;
};

return { module, createChart, createChartEx: createChartEx as typeof module.createChartEx };
},
current: async () => {
const module = await import('../../../../..');

Expand Down
125 changes: 125 additions & 0 deletions website/versioned_docs/version-4.2/android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
id: android
description: You can use Lightweight Charts™ inside an Android application. To use Lightweight Charts™ in that context, you can use our Android wrapper, which will allow you to interact with Lightweight Charts™ library, which will be rendered in a web view.
keywords:
- charts
- android
- canvas
- charting library
- charting
- html5 charts
- financial charting library
sidebar_position: 7
---

# Android wrapper

:::note
You can find the source code of the Lightweight Charts™ Android wrapper in [this repository](https://github.com/tradingview/lightweight-charts-android).
:::

:::info

This wrapper is currently still using `v3.8.0`. This will be updated to `v4.0.0` in the near future.

:::

You can use Lightweight Charts™ inside an Android application. To use Lightweight Charts™ in that context, you can use our Android wrapper, which will allow you to interact with Lightweight Charts™ library, which will be rendered in a web view.

## Installation

:::info
Requires minSdkVersion 21, and installed WebView with support of ES6
:::

In `/build.gradle`

```groovy
allprojects {
repositories {
google()
mavenCentral()
}
}
```

In `/gradle_module/build.gradle`

```groovy
dependencies {
//...
implementation 'com.tradingview:lightweightcharts:3.8.0'
}
```

## Usage

Add view to the layout.

```xml
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.tradingview.lightweightcharts.view.ChartsView
android:id="@+id/charts_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
```

Configure the chart layout.

```kotlin
charts_view.api.applyOptions {
layout = layoutOptions {
background = SolidColor(Color.LTGRAY)
textColor = Color.BLACK.toIntColor()
}
localization = localizationOptions {
locale = "ru-RU"
priceFormatter = PriceFormatter(template = "{price:#2:#3}$")
timeFormatter = TimeFormatter(
locale = "ru-RU",
dateTimeFormat = DateTimeFormat.DATE_TIME
)
}
}
```

Add any series to the chart and store a reference to it.

```kotlin
lateinit var histogramSeries: SeriesApi
charts_view.api.addHistogramSeries(
onSeriesCreated = { series ->
histogramSeries = series
}
)
```

Add data to the series.

```kotlin
val data = listOf(
HistogramData(Time.BusinessDay(2019, 6, 11), 40.01f),
HistogramData(Time.BusinessDay(2019, 6, 12), 52.38f),
HistogramData(Time.BusinessDay(2019, 6, 13), 36.30f),
HistogramData(Time.BusinessDay(2019, 6, 14), 34.48f),
WhitespaceData(Time.BusinessDay(2019, 6, 15)),
WhitespaceData(Time.BusinessDay(2019, 6, 16)),
HistogramData(Time.BusinessDay(2019, 6, 17), 41.50f),
HistogramData(Time.BusinessDay(2019, 6, 18), 34.82f)
)
histogramSeries.setData(data)
```

## How to run the provided example

The [GitHub repository](https://github.com/tradingview/lightweight-charts-android) for lightweight-charts-android contains an example of the library in action.
You can run the example (LighweightCharts.app) by cloning the repository and opening it in Android Studio. You will need to have [NodeJS/NPM](https://nodejs.org/) installed.
Loading

0 comments on commit 23c42eb

Please sign in to comment.