Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hoanghiephui/lightweight-charts
https://github.com/hoanghiephui/lightweight-charts
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hoanghiephui/lightweight-charts
- Owner: hoanghiephui
- License: apache-2.0
- Created: 2023-07-10T03:41:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-30T06:37:02.000Z (11 months ago)
- Last Synced: 2024-04-17T23:55:54.310Z (8 months ago)
- Language: Kotlin
- Size: 292 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lightweight-charts-android
The Android Lightweight Charts is an Android wrapper of the [TradingView Lightweight Charts](https://github.com/tradingview/lightweight-charts) library.
## Requirements
- minSdkVersion 21
- Installed WebView with support of ES6## How to use
In `/build.gradle`
```groovy
allprojects {
repositories {
google()
mavenCentral()
}
}
```In `/gradle_module/build.gradle`
```groovy
dependencies {
//...
implementation 'com.tradingview:lightweightcharts:3.8.0'
}
```Add view to the layout.
```xml
```
Configure the chart layout.
```kotlin
charts_view.api.applyOptions {
layout = layoutOptions {
backgroundColor = Color.LTGRAY.toIntColor()
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)
```## License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at LICENSE file. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This software incorporates several parts of tslib (https://github.com/Microsoft/tslib, (c) Microsoft Corporation) that are covered by the Apache License, Version 2.0.
This license requires specifying TradingView as the product creator. You shall add the "attribution notice" from the NOTICE file and a link to https://www.tradingview.com/ to the page of your website or mobile application that is available to your users. As thanks for creating this product, we'd be grateful if you add it in a prominent place.