Coder Social home page Coder Social logo

pfuster12 / livechart Goto Github PK

View Code? Open in Web Editor NEW
129.0 129.0 16.0 3.28 MB

Android library to draw beautiful and rich line charts.

Home Page: https://pfuster12.github.io/LiveChart/livechart/index.html

License: MIT License

Kotlin 100.00%
android android-development android-library charts data-science data-visualization drawing finance fintech graphs jitpack line-chart mobile mobile-app

livechart's People

Contributors

insanusmokrassar avatar pfuster12 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

livechart's Issues

Style Horizontal Drag Overlay

Is your feature request related to a problem? Please describe.
The horizontal drag overlay style is hardcoded.

Describe the solution you'd like
Allow for styling of overlay with object similar to LiveChartView.

Version
1.2.0-alpha

Draw X axis support

Description
Draw the X Axis with text data points at key steps.

Version
1.0.0

Current behavior
No support for X axis

Set Styling with XML attributes

Is your feature request related to a problem? Please describe.
Color can only be set programmatically through styling.

Describe the solution you'd like
Add XML attribute to set directly in layouts

Version
1.0.0

Additional context

Feature Request moveable (upper BaseLine/LastPointLabel) or overlay moves Horizontally

Is your feature request related to a problem?.
NO
**Describe **
Is it possible to make the upper baseline moves?
or maybe we can make the overlay moves in Horizontal way rather than Vertical one?.
in this case we will have multi points the line will intersect with, so I don't know if we can choose of theme some points show, or for now we might show them all!
Describe the solution you'd like
I'm still reading your code to better understanding, but I post my question so that you might give me some ideas to apply
Thanks Pablo.

Draw current DataPoint on horizontal finger drag

Is your feature request related to a problem? Please describe.
Not an issue.

Describe the solution you'd like
When you trigger the onTouch callback, draw the current DataPoint your finger is closest to and display the Y axis value in a text tag next to it. As the finger drags across horizontally the DataPoint is drawn to match the current value.

A vertical line drawn across from the x axis can be added to help root the DataPoint to the axis.

Version
1.0.0

Current behavior
No support.

Additional context
See Trading 212, Yahoo FInance for similar feature.

Hide Last DataPoint tag

Is your feature request related to a problem? Please describe.
Last data point tag always shown if Y axis is drawn.

Describe the solution you'd like
Public method to toggle draw tag drawLastDataPointTag()

Version
1.0.0

[BUG] No lines drawn on chart if all the y coordinates are the same value

Describe the bug
If the Dataset contains data that doesn't vary the y coordinate the chart doesn't draw anything. Looking at the source code of the library it's probably caused because the lowerBound and upperBound for the Dataset both are the same value and the LiveChartView subtracts those values(result is zero) and then uses that value for various division and multiplication. The problem persists even if a second dataset is passed to the LiveChart with .setSecondDataset() method.

To Reproduce
Steps to reproduce the behavior:

  1. Create a dataset with all points having the same y coordinates
  2. pass the dataset as the argument to liveChart.setDataset()
  3. Call liveChart.drawDataset()
  4. See error

Expected behavior
The chart should display a line at the bottom of the chart.

Smartphone (please complete the following information):

  • Device: Google Pixel 5
  • OS: Android 12
  • Version [e.g. 1.3.6]

Visual bugs and data misrepresentation due to smoothing [BUG]

Describe the bug
Great lib, love the simple designs.

It's however possible with certain datasets and configurations to get some quite strange looking graphs.

As an example take (over-exaggerated) dataset:

Dataset(
     mutableListOf(
         DataPoint(0f, 0f),
         DataPoint(1f, 3.7f),
         DataPoint(2f, 3.6f),
         DataPoint(3f, 3.5f),
         DataPoint(4f, 0f),
         DataPoint(5f, 3.2f),
         DataPoint(6f, 0f),
         DataPoint(7f, 3.3f),
         DataPoint(8f, 0f)
     )
)

With XML

    <com.yabu.livechart.view.LiveChart
        android:id="@+id/dimensions_live_chart"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_marginStart="36dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="36dp"
        android:layout_marginBottom="32dp"
        app:layout_constraintBottom_toBottomOf="..."
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="..." />

And code

        holder.dimensionsLiveChart.setDataset(it)
                .drawSmoothPath()
                .drawFill(false)
                .drawHorizontalGuidelines(steps = 3)
                .drawBaselineConditionalColor()
                .setBaselineManually(3f)
                .setOnTouchCallbackListener(object : LiveChart.OnTouchCallback {
                    @SuppressLint("SetTextI18n")
                    override fun onTouchCallback(point: DataPoint) {
                        //ommited
                    }

                    override fun onTouchFinished() {
                        //omitted
                    }
                })
                .drawDataset()
        }

This results in:

Screenshot from 2021-01-20 14-18-44

The bugs I discovered:

  • Due to line smoothing, datapoints can incorrectly return values that are higher or lower than the min/max values that were provided in the dataset. For example: using the provided dataset above you can retrieve data point 3.88 which is a point provided by smoothing but not a real value. As smoothing is a pure "visual" feature, I find it strange that datapoints are not accurately returned in this case.
  • It appears line smoothing does not work in conjunctions with the fill color in extreme cases, as fill color is not smoothed. As you can see in the screenshot, "pyramid shapes" are formed of the fill color.
  • I'm having problems where the lines are cropped off above or below the chart. This is especially clear when using smoothing, as the large bend artificially makes the graph bigger. I'm wondering how I can fix this, as including padding in XML breaks the graph even further and is clearly not supported.

[Feature] Draw chart guidelines

Describe the solution you'd like
Draw background vertical and horizontal n number of guidelines.
Public api:
drawVerticalGuidelines(steps=4)
drawHorizontalGuidelines(steps=4)

where steps is the number of guidelines evenly distributed in the chart.

Version
1.2.3

Additional context
Allow for styling of guidelines too.

Is this available for java users too?

Am using java for android dev and trying to access LiveChart and other classes but none of them are accessible even after adding dependencies of it. Does this only work kotlin?

[BUG] Touch tracking does not match position of finger

Describe the bug
Touch tracking does not match the position of finger.
This is happening because the tracking uses the x-coordinate of the finger to map to the length of the path, instead of mapping to the same x-coordinate of the path.

To Reproduce
Steps to reproduce the behavior:
2. Tap and move on a LiveChart
3.See tracking dot not on finger position

Expected behavior
Dot matches finger pos exactly

Dataset points mutability

Hello. I am not pretty sure that it is good idea to use MutableList in Dataset. My point is that we could use private val points: List<DataPoint> instead. The reason of my suggestion in fact that it is not good when everybody knows that the list inside of Dataset is mutable.

[BUG] Fill Path brakes if dataset doesn't start at x=0 coordinate

Describe the bug
The Fill path for datasets always start at x=0 coordinate, even if dataset doesn't.

To Reproduce
Steps to reproduce the behavior:

  1. Draw a dataset starting at x>0
  2. flag drawFill()
  3. Fill path starts at x=0

Expected behavior
Fill path start at dataset start.

Option to fill until the manual defined baseline

Hello,

That would be great to have the possibllity to set an option to fill until the baseline.

For ex: I can have a baseline at 10f and gradient will only fill the area between the path and the baseline. So when path is above the baseline it wont fill below the baseline and when the baseline is below the baseline it wont fill above the baseline for that area.

Best

Add onTouchEnd callback in onTouch interface

Is your feature request related to a problem? Please describe.
Callback when Touch event stops.

Describe the solution you'd like
A second interface function in LiveChart.OnTouchCallback to override when the touch event has ended in the LiveChart.

Version
1.2.0

[BUG] App crash with non changing data and gradient fill

Steps to reproduce the behavior:
When using these datasets:

generateDataSet 1: Dataset(points=[DataPoint(x=0.0, y=0.4446), DataPoint(x=1.0, y=0.4446), DataPoint(x=2.0, y=0.4446), DataPoint(x=3.0, y=0.4446), DataPoint(x=4.0, y=0.4446), DataPoint(x=5.0, y=0.4446), DataPoint(x=6.0, y=0.4446), DataPoint(x=7.0, y=0.4446), DataPoint(x=8.0, y=0.4446), DataPoint(x=9.0, y=0.4446), DataPoint(x=10.0, y=0.4446), DataPoint(x=11.0, y=0.4446), DataPoint(x=12.0, y=0.4446), DataPoint(x=13.0, y=0.4446), DataPoint(x=14.0, y=0.4446), DataPoint(x=15.0, y=0.4446), DataPoint(x=16.0, y=0.4446), DataPoint(x=17.0, y=0.4446), DataPoint(x=18.0, y=0.4446), DataPoint(x=19.0, y=0.4446), DataPoint(x=20.0, y=0.4446), DataPoint(x=21.0, y=0.4446), DataPoint(x=22.0, y=0.4446), DataPoint(x=23.0, y=0.4446), DataPoint(x=24.0, y=0.4446), DataPoint(x=25.0, y=0.4446)])

generateDataSet 2: Dataset(points=[DataPoint(x=26.0, y=0.4446), DataPoint(x=27.0, y=0.4446)])

This will crash the app if you want to show gradient fill.
I think this happens in case of dataset 2 having same Y values as last dataset1 y value.
I have managed to create a quickfix with this code:

   .drawFill(withGradient = !isAllSame())

    private fun isAllSame(): Boolean {
        val pointY = dataSet2.points[0].y
        return dataSet2.points.all { it.y == pointY }
    }

Customize Fill - Color, Solid support

Is your feature request related to a problem? Please describe.
Fill can only be a gradient

Describe the solution you'd like
Support different fills and colors

Version
1.0.0

Set path thickness

Is your feature request related to a problem? Please describe.
Path defaults to one thickness

Describe the solution you'd like
Public method to set path thickness: setThickness(value: Float)

Version
1.0.0

Draw list of datasets

Is your feature request related to a problem? Please describe.
Currently the chart allows to draw two datasets explicitly set.

Describe the solution you'd like
Draw datasets from a list, to allow for as many as needed: setDatasets(sets: List<Datasets>)
Allow setting colours setDatasetsColors(colors: List<Int>), otherwise a random assortment of colors are assigned.

Version
1.0.0

Draw n number of Y axis text labels

Is your feature request related to a problem? Please describe.
The Y axis text labels are hardcoded at 4.

Describe the solution you'd like
Draw n number with a public api like drawYAxisLabels(steps: Int)

Version
1.3.4

Moving circular button position without touch

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

@Pfuster12 Hi Pablo, thanks for new version, this is very useful and beautiful livecharts!

Describe the solution you'd like
A clear and concise description of what you want to happen.

If the .drawTouchOverlayAlways() option is turned on, is it possible that its position is not always in the middle of the chart?
I mean, is it possible to set the position of the circular button programmatically?

Version
1.3.5
Additional context
Add any other context or screenshots about the feature request here.

Toggle Y Axis gravity (start or end)

Describe the solution you'd like
Draw Y Axis and labels at the start or end of the chart.
Toggle by passing a Gravity.START or Gravity.END enum to the existing public API
drawYBounds(gravity: Gravity)

Version
1.3.3

Disable baseline conditional color change

Is your feature request related to a problem? Please describe.
Chart changes color when positive/negative from baseline.

Describe the solution you'd like
Flag to disable this feature and keep graph as color set always.
Something like disableBaselineConditionalColor()

Version
1.0.0

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.