Giter VIP home page Giter VIP logo

lightweight-charts-android's People

Contributors

klee0kai avatar makedonsky94 avatar ootaisoo avatar timocov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightweight-charts-android's Issues

Cannot update oldest data

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

Hide non public API

We have some classes and methods which are not intended to be public. So we should hide those components by making them internal

Click on chart bar returns last item but not clicked one.

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())
            }
}

Default browser style

Hello, has issue in sizing of chart because browser has default margin
image

Proposal: Reset default browser style for body

Add Exampels

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.

CallBack event for Crosshair

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

App crashes on Back press after adding remove series

@timocov

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)
}
})
}

seriesName is not defined

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

  1. firstChartApi!!.removeSeries(it)

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)

How to Format the date on X axis ?

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

Bug does not restore the state view

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?

fitContent() not working first time

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()
}

IllegalStateException

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

setVisibleRange() is not working

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.

Update kotlin version

We need to update the kotlin version. Also remove deprecated kotlin-android-extensions plugin

Upgrade the lightweight-charts to 3.0

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.

Gradle error

When I add dependencies at gradle, I have error:
Failed to resolve: com.tradingview:lightweightcharts:1.0.0-beta

Not Able to Format Date in different format in the latest version

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

A lot of logs

When I use charts with subscribe to visible range and use real time update from ws or rest has a lot of logs
image
Proposal: Need option for disable logs

White screen on place of chart view while taking screenshot programmatically

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)

Facing issue for removing current series from chart

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

Showing white screen on back press of fragment transition In the latest version also (v3.5.0)

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() }

WhatsApp.Video.2021-08-09.at.4.36.13.PM.1.mp4

Experienced a lot of crashes

Light weight chart

We have experienced a lot of crashes in the chart. I have attached a screenshot of the log.
Could you rectify/assist us with this

Crash report

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

Showing white screen on back press of fragment transition

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() }

chart_blank_screen_issue.mp4

Inner width of view

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

coordinateToPrice not working

price not receiving in onPriceReceived.

seriesAPI.coordinateToPrice(0f,onPriceReceived)

priceToCoordinate seems working

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.