tradingview / lightweight-charts-android Goto Github PK
View Code? Open in Web Editor NEWAndroid wrapper for lightweight-charts library
License: Apache License 2.0
Android wrapper for lightweight-charts library
License: Apache License 2.0
Can see the white frames while switching between black charts on black layouts
We can use the default API of webview to make screenshots
java.lang.IllegalStateException: Error: Cannot update oldest data, last time=1633647540, new time=1633564800
at jsCode.DataLayer._internal_updateSeriesData(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:10536)
at jsCode.ChartApi._internal_updateData(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:11477)
at jsCode.SeriesApi.update(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:10889)
at jsCode.SeriesFunctionManager.findSeries(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:11925)
at jsCode.Object.functionRef(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:11896)
at jsCode.FunctionManager.call(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:11644)
at jsCode.MessagePort.port.onmessage(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:12398)
Caused by: java.lang.IllegalStateException
please, consider don't throw exception, just warning
We have some classes and methods which are not intended to be public. So we should hide those components by making them internal
There is no way to reset color to default state. Gson can not override behaviour of nulls.
Hi Team,
The application is getting crashed because of the following error "java.lang.IllegalStateException: Cannot update oldest data, last time=1626696600, new time=1626696300"
is there any Check or way to avoid the crash
Hi everyone, I have an issue - when clicking on histogram serries I receive the last HistogramData and current point on the screen. Is this an issue or intended behavior? I expect to return a HistogramData which I click.
If I long click on HistogramData and after a simple click then HistogramData is right, which I clicked.
My setup:
lateinit var histogramSeries: SeriesApi
chart.api.applyOptions {
layout = layoutOptions {
crosshair = CrosshairOptions(
vertLine = CrosshairLineOptions(visible = false, labelVisible = false),
horzLine = CrosshairLineOptions(visible = false, labelVisible = false)
)
leftPriceScale = PriceScaleOptions(visible = false)
rightPriceScale = PriceScaleOptions(visible = false)
handleScale = HandleScaleOptions(
mouseWheel = false,
pinch = false,
axisPressedMouseMove = AxisPressedMouseMoveOptions(time = false, price = false),
axisFloatClickReset = false)
timeScale = TimeScaleOptions(
borderVisible = false,
fixLeftEdge = true,
fixRightEdge = true,
visible = false
)
handleScroll = HandleScrollOptions(
mouseWheel = false,
pressedMouseMove = false,
horzTouchDrag = false,
vertTouchDrag = false
)
grid = gridOptions {
vertLines = GridLineOptions(visible = false)
horzLines = GridLineOptions(visible = false)
}
}
}
chart.api.addHistogramSeries(
options = HistogramSeriesOptions(priceLineVisible = false),
onSeriesCreated = { series ->
histogramSeries = series
}
)
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)
chart.api.timeScale.fitContent()
chart.api.subscribeClick {
Log.w("", it.toString())
}
}
Current state of price formatters in Kotlin code is unusable
Good day!
How can I add and update bars from an Android app programmatically? What me need send in webView.evaluateJavascript(...)
?
I am use Technical Analysis Charts.
Hi team,
Iโm using lightweight chart inside CollapsingToolbarLayout, because of which CrossHairLine vertical drag is messing with CollapsingToolbarLayout Scroll, is there any solution for this Or Is there any Callbacks available through which we can detect that crosshair is on or off. So I can disable and enable the CollapsingToolbarLayout Scroll.
Thanks
onBackpress after adding this.series.forEach(charts_view.api::removeSeries) app is crashing
please find below the code
private fun observeViewModelData() {
viewModel.seriesData.observe(viewLifecycleOwner, { data ->
createSeriesWithData(data, PriceScaleId.RIGHT, charts_view.api) { series ->
this.series.forEach(charts_view.api::removeSeries)
this.series.clear()
this.series.add(series)
}
})
}
Hi Team,
we are showing the Area and candle chart with the click of the switch button. if we Switch fast between these 2 chart we get this error on the below code lines
Process: com.divum.MoneyControl.debug, PID: 5168
java.lang.IllegalStateException: seriesName is not defined
at com.tradingview.lightweightcharts.runtime.controller.WebMessageController.onMessage(WebMessageController.kt:124)
at com.tradingview.lightweightcharts.runtime.WebMessageChannel$1.onMessage(WebMessageChannel.kt:26)
fun chartOptions(width: Int, height: Int): ChartOptions {
return ChartOptions(
width = width,
height = height,
timeScale = timeScaleOptions(),
localization = LocalizationOptions(
locale = "de-AT",
priceFormatter = "function (price) { return price + 'k'; }",
timeFormatter = "function (time) { return time + 'k'; }",
dateFormat = DateFormat.FORMAT_2
)
)
}
I'm trying to format the date on X-axis By using the above code. But it is showing the same date for all the DateFormat
We used viewPager.
Add ChartsView to our fragment.
Add tabLayout.
After click tab we go next page.
After click tab where we added ChartsView.
Result: not correct view ChartsView
You clearWebMessageChannel from onDetachedFromWindow but not use webMessageController.setWebMessageChannel(channel) for onAttachedToWindow
Can you help?
Im trying to use "firstChartApi.timeScale.fitContent()" in the sample app after setting the data but it is not working on 1st time on 2nd time it working properly could you please provide a sample on how to use it with a dynamic chart
My sample code:-
private fun createSeriesWithData(
data: Data,
priceScale: PriceScaleId,
chartApi: ChartApi,
onSeriesCreated: (SeriesApi) -> Unit) {
when (data.type) {
SeriesDataType.LINE -> chartApi.addLineSeries(
options = LineSeriesOptions(
priceScaleId = priceScale
),
onSeriesCreated = { api ->
api.setData(data.list)
onSeriesCreated(api)
}
)
SeriesDataType.CANDLESTICK -> {
chartApi.addCandlestickSeries(
options = CandlestickSeriesOptions(
priceScaleId = priceScale
),
onSeriesCreated = { api ->
api.setData(data.list)
onSeriesCreated(api)
}
)
chartApi.timeScale.fitContent()
}
}
firstChartApi.timeScale.fitContent()
}
hello.
i use 3.6.1 version.
from time to time the application gets an error:
java.lang.IllegalStateException: Error: Subscriber:subscribeVisibleTimeRangeChange with uuid:73bdee82-05a3-40c8-8767-c3122287ab80 is not found
this error is not handled in any way but causes the application crash.
I also did not find a way to handle this error in the library.
However, this error does not look like serious enough to cause critical crash the application.
can u please provide information on what causes this error and please consider processing it
2021-10-01 10:58:19.500 17510-17510/com.investpro.app E/[LIGHTWEIGHT_CHARTS]: Subscribe cancellation is failed. Key null is not found
2021-10-01 10:58:19.946 17510-17510/com.investpro.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.investpro.app, PID: 17510
java.lang.IllegalStateException: Error: Subscriber:subscribeVisibleTimeRangeChange with uuid:73bdee82-05a3-40c8-8767-c3122287ab80 is not found
at jsCode.FunctionManager.unsubscribe(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:11694)
at jsCode.MessagePort.port.onmessage(file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js:12404)
Caused by: java.lang.IllegalStateException
Hello.
I want to show the price information for the last 2 months.
But unlike Javascript, it was not applied in Android kotlin.
//chartData has 365 days of information
val fromT = Time.StringTime((chartData.get(chartData.length() - 60) as JSONObject).getString("time")) // 2021-08-15
val nowT = Time.StringTime((chartData.get(chartData.length() - 1) as JSONObject).getString("time")) // 2021-10-15
chartsView.api.timeScale.setVisibleRange(TimeRange(fromT, nowT))
However, the results always show the widest range of data that can be displayed on the screen.
How can I apply it to get the results I want?
Thank you so much.
We need to update the kotlin version. Also remove deprecated kotlin-android-extensions plugin
The latest lightweight-charts library is v3.1.5.
As a new Android library, i see current SDK is using v2, some features are not available.
Is it possible to start with latest js version ?
Thanks.
When I add dependencies at gradle, I have error:
Failed to resolve: com.tradingview:lightweightcharts:1.0.0-beta
Also we should check implementation of screenshot method in api delegate
I have tried to format the date in the latest version no. 3.2.0-rc1
Not possible to change the time format from (1611122880) epoch on the x-Axis
Example for 1 day -- 9:30 AM, 11:05 AM ...
for 1 week -- 19 Jan, 18 Jan, 15 Jan ...
for 1 Month -- Jan20, Dec19 , Nov19 , ...
for 1 year -- Feb2020 , May2020 , Jul2020 ...
for 5 year -- 2020, 2019, 2018 ....
Kindly Suggest
Hello,
I have 0 knowledge about Kotlin and I want to ask whether there is a documentation for Java developer?
With kind regards
MuemmelMann456
Native code should be marked as caused instead of js
We are facing lots of crashes due to the above error in our crash log and we are unable to reproduce at our end. Please let us know the reason for this crash.
Hi team,
We are facing white screen issue in place of ChartsView while taking screenshot programmatically.
Also whenever new data is rendered or when we change duration, the white screen is visible for fraction of seconds then chart is loaded(i.e from 1d to 5d > first white screen gets loads then old graph and new graph gets rendered)
I'm using the below code for removing the current series from the sample app
leftSeries.forEach(firstChartApi::removeSeries)
leftSeries.clear()
getting below error
Type inference failed: inline fun Iterable.forEach(action: (T) -> Unit): Unit
cannot be applied to
receiver: MutableList arguments: (KFunction2<@ParameterName SeriesApi, @ParameterName(name = "onSeriesDeleted") () -> Unit, Unit>)
Please suggest
Hi team,
we are facing the same issue in the latest version(v3.5.0)
Previously reported issue link below
#57
issue details:-
white screen issue over chart view when replacing a fragment on the back press and navigating to the previous chart fragment.
Sharing code snippets which have been used for fragment transaction which is shared in the sample app, here we only added backStack line .addToBackStack("tag"), also shared a video reference.
private fun startFragment(fragmentClass: Class) { supportFragmentManager .beginTransaction() .replace( R.id.fragment_container_fl, FragmentFactory.getInstance(fragmentClass) ) .addToBackStack("tag") .commit() }
How to disable the crosshair ?
It's working with SDK Version 28 and higher, but it's not working below that.
W/zygote: Attempt to remove non-JNI local reference, dumping thread
I/chromium: [INFO:CONSOLE(3802)] "Uncaught SyntaxError: Failed to execute 'addColorStop' on 'CanvasGradient': The value provided ('#2962ff4c') could not be parsed as a color.", source: file:///android_asset/com/tradingview/lightweightcharts/scripts/app/main.js (3802)
It's just keeps crashing and sometimes showing a black screen.
Screenshot: https://imgur.com/a/u9b5qgx
Hi team, we are facing white screen issue over chart view when replacing a fragment on back press and navigating to the previous chart fragment.
Sharing code snippet which have been used for fragment transaction which is shared in sample app, here we only added backStack line .addToBackStack("tag")
, also shared a video reference.
private fun <T : Fragment> startFragment(fragmentClass: Class<T>) { supportFragmentManager .beginTransaction() .replace( R.id.fragment_container_fl, FragmentFactory.getInstance(fragmentClass) ) .addToBackStack("tag") .commit() }
Hi!
I want to make something like this (floating tooltip which follows cursor) https://jsfiddle.net/TradingView/p6f5svr4/
Is there any way to determine logical width of webView or plot? Or can I init or change this logical width?
MouseEventParams returns X coordinate in inner logical size and I can't to make floating tooltip without width of view.
Found this
where is used innerWidth\innerHeight, but I can't to find it in api.For priceScale i can determine width by this code and it's in similar units as MouseEventParams:
chart.api.priceScale(PriceScaleId.RIGHT).width {
priceScaleWidth = it
}
coordinateToPrice not working
price not receiving in onPriceReceived.
seriesAPI.coordinateToPrice(0f,onPriceReceived)
priceToCoordinate seems working
Hi team
Currently, crosshair lines get activated on long press and deactivated on click
we want crosshair lines should get activated on the long press and deactivated on the removed of finger from chart
WebView's method setBackgroundColor
is using the backend provider interface. And the default value is white color. So we unable to use xml value "background"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.