Giter Site home page Giter Site logo

Comments (2)

dlesniakdev avatar dlesniakdev commented on May 5, 2024

I tried it like this now, what is exacly like in your project.
ss 2014-08-19 at 01 31 35

What I noticed, you set these colors to your chart:
ss 2014-08-19 at 01 33 48

and none of them working. Your example chart is has 1 color for all charts, and it is not from the array, it is set by DataSet constructor:

public DataSet(ArrayList<Entry> yVals, String label)
        // default colors
//        mColors.add(Color.rgb(192, 255, 140));
//        mColors.add(Color.rgb(255, 247, 140));
        mColors.add(Color.rgb(140, 234, 255));

from mpandroidchart.

PhilJay avatar PhilJay commented on May 5, 2024

Alright, try it like this:

LineDataSet d = new LineDataSet(values, "DataSet ");
d.setColor(Color.RED);

If then, your data set is in color red, the library is working, and you are making a mistake resolving the color from the resources. As you already mentioned, the example project is working, which makes it highly likely that the issue is on your end.

You should use:

int color = getResources().getIdentifier("color_" + finalLabels.get(i).toLowerCase(), "color", getPackageName()); // get the color resource id

// resolve the resource id
d.setColor(getResources().getColor(color));

because getResources().getIdentifier(...) only provides the resource ID, and will not resolve the color correctly like getResources().getColor(...) does. This piece of quite complicated code has nothing to do with the library, it's more of an Android issue/complication.

Concerning the highlight arrow:
This feature is currently disabled, but you can easily enable it again by putting this code snipped into the BarChart class inside the drawHighlights() method. Around line 200.

                if (mDrawHighlightArrow) {

                     // distance between highlight arrow and bar
                     float offsetY = mDeltaY * 0.04f;
                     float y = e.getSum();
                     mHighlightPaint.setAlpha(200);

                     Path arrow = new Path();
                     arrow.moveTo(index + 0.5f, y + offsetY * 0.3f);
                     arrow.lineTo(index + 0.2f, y + offsetY);
                     arrow.lineTo(index + 0.8f, y + offsetY);

                     transformPath(arrow);
                     mDrawCanvas.drawPath(arrow, mHighlightPaint);
                }

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.