Giter Site home page Giter Site logo

Comments (4)

PhilJay avatar PhilJay commented on May 6, 2024

Ok, so you need the following two things:

  • a stacked barchart / different values in one bar
  • a combination of line- and barchart (because of your "limit" line)

I am currently working on implementing those features, but I cannot tell when exactly I will have the time to finish the implementation.

In the meantime, I suggest the following approach:
You can use multiple DataSets, each representing one color.

Example
Your limits are 10 and 20, and the colors representing the limits are red (below 10), yellow (below 20) and green (everything above 20).

The values you want to represent in the chart are 5, 25, and 15 on x-axis index 0, 1 and 2.

Now, you create a DataSetthat is represented by the color green, and contains all values above 20. In this example case, that would be the values 0, 25, and 0 (everything below 25 is 0).

As a next step, you create a DataSet that represents the color yellow, and contains all values between 10 and 20. In this example, that would be the values 0, 20 and 15.

Last but not least, you create the DataSet representing the color red. It will contain the values 5, 10 and 10. If you now combine these DataSets and add them to the chart, everything below 10 should be red, between 10 and 20 yellow, and above 20 green.

For your limit line in the chart, I suggest you modify the BarLineChartBase class of the library by adding the following code inside the onDraw(...) method: (between drawData() and drawHighlights())

        drawData();

        // draws a horizontal line through the whole chart at value 10
        float[] pts = new float[] { 0f, 10f, mDeltaX, 10f };
        transformPointArray(pts);

        mDrawCanvas.drawLine(pts[0], pts[1], pts[2], pts[3], yourDesiredPaintObject);

        drawHighlights();
        // ...

from mpandroidchart.

vijaykarora avatar vijaykarora commented on May 6, 2024

Thank you so much.

from mpandroidchart.

PhilJay avatar PhilJay commented on May 6, 2024

Update: The latest commit now features LimitLines that can be set to the data object that is handed to the chart.

LineData ld = new LineData(...);

LimitLine ll = new LimitLine(100f); // limit at 100
ll.set(...); // additional styling...
ld.addLimitLine(ll);

mLineChart.setData(ld);

from mpandroidchart.

SantoshDawanse avatar SantoshDawanse commented on May 6, 2024

@amagine @PhilJay I have the same issue as @amagine but I cannot understand what you guys are saying. Can you show me a simple example.

from mpandroidchart.

Related Issues (20)

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.