Giter Site home page Giter Site logo

philjay / mpandroidchart Goto Github PK

View Code? Open in Web Editor NEW
37.2K 1.1K 9.0K 21.21 MB

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

License: Other

Java 100.00%
java chart graph android mpandroidchart

mpandroidchart's People

Contributors

aint avatar almic avatar almilli avatar angelofmors avatar christiandeange avatar corycharlton avatar ctncardoso avatar danielgindi avatar dexterbg avatar duchampdev avatar emmaguy avatar farfromrefug avatar jitpack-io avatar maheshgaya avatar maximpestryakov avatar mesropd avatar mikedream89 avatar mikemonteith avatar oatrice avatar pagrzybe avatar ph1lb4 avatar philjay avatar redwarp avatar robertschmid-ast avatar robertzagorski avatar thadeubatista avatar tonypatino-monoclesociety avatar vpop avatar wajdichamakhi avatar wilder 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  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

mpandroidchart's Issues

Data Filtering

An algorithm needs to be developed with which data filtering (data reduction) can be done automatically. The degree of filtering (tolerance) should depend on the number of values in the chart, and the current scale/zoom level on both x- and y-axis.

Draw Line chart with labels on x axis labels bottom side with time stamp

Hi I am trying to make a simple smooth line chart which show the x axis as date-time on bottom and ya axis as normal left side. I just started using your api and you example app in git. In the example Lice chart I am not able to find option to change x axis labels to show on bottom instead of top as show currently.
Just like: http://maxcdn.webappers.com/img/2012/02/javascript-chart.png
Also is there a way to handle date-time data for x axis values ?

Please reply soon as I need to implement the chart urgently.

Horizontal scrolling on LineChart (not drag), Popup on click

Hi PhilJay, your library is too great. But i think it will perfect I think it still lack of some features to be perfect. I suggest that you implement 2 features:

  • We can scroll the chart in horizontal orientation, dragging is too slow.
  • When we click on a point, it can popup a mini balloon to show the value.

What do you think about them?

Bug when turning off the screen

In your example, open a line plot, zoom in and turn off the screen. When tuning the screen on again, it will recalculate the zoom offset, jumping to a new location. For example if you show Y values 30-70, next time you turn the screen on it will display 60-100, turn off and on the screen it will display 90-130 etc. The bug is only when zoomed in.

Setting background color has no effect

hi,

setting the background color doesn't do anything. It just stays white by default in your examples. I am not getting any errors otherwise I could tell you more on that. Appreciate any feedback.
By the way, charts are awesome. keep up the work.

ArrayList<LineDataSet> issue.....

I am declaring ArrayList globally and when I do system.out.println() I see the values I added.
Now what I am doing is based on these values I am making comparison to another LineDataSet ..and guess what happens. The .equals() condition or .indexof() to LineDataSet doesn't return true even though the same values exist. So how is it that same values exist in these two LineDataSet and yet returns false at the end when comparison is made?

By the way, in one instance I am adding LineDataSet during oncreate and another through add button..but it does add to it and I see it in the graph but comparison returns false anyway.

Thanks.

Not only a Library-Project also as Jar-File

Thanks for your great chart library! It is realy awesome!

Would it be possible to put the xml based resources in code and pack the project as jar file?
In my opinion it would make your library much easier to integrate into other projects.

Chart font size

Is there anyway to set the font size that's used when the chart is being drawn?

It's frequently changing when I try it on different devices (some devices, it appears extremely small, on others it's extremely large).

Thanks

Circle colors order

I'm using the new feature to define the colors of the circles of my line chart, but the order of the colors in the graph is different of the defined in program.

My code (is a simple example):

ArrayList<Entry> valsComp2 = new ArrayList<Entry>();
Entry c2e1 = new Entry(20, 0);
valsComp2.add(c2e1);
Entry c2e2 = new Entry(30, 1);
valsComp2.add(c2e2);
Entry c2e3 = new Entry(0, 2);
valsComp2.add(c2e3);
Entry c2e4 = new Entry(30, 3);
valsComp2.add(c2e4);
Entry c2e5 = new Entry(20, 4);
valsComp2.add(c2e5);
LineDataSet setComp2 = new LineDataSet(valsComp2, "10.10.1.3");
setComp2.setColor(getResources().getColor(R.color.verde));
int[] colors = new int[] {R.color.red,R.color.green,R.color.grey,R.color.blue,R.color.purple};
setComp2.setCircleColors(colors, getApplicationContext());

My XML colors:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#F00</color>
    <color name="green">#0F0</color>
    <color name="grey">#EEE</color>
    <color name="blue">#00F</color>
    <color name="purple">#F0F</color>
</resources>

How show in the device:
screenshot_2014-08-22-13-58-02

I'm doing something wrong?

Candlestick chart

I do have strong intention to use this wonderful charting library in a stock market app : https://play.google.com/store/apps/details?id=org.yccheok.jstock.gui&hl=en

I was wondering, is there any plan to add candlestick chart - http://en.wikipedia.org/wiki/Candlestick_chart in this library

I had came across some wonderful candlestick chart in different language/platform. I'm not sure whether we can further enhance this library, by referring code from the below open source project.

https://github.com/ecomfe/echarts (JavaScript)
http://www.jfree.org/jfreechart/ (Java)

Thank you very much!

MarkerView not working

Due to the latest code changes / improvements, the marker-view that can be displayed when selecting values is currently not working.

The smooth curve not accurate using mDrawCubic = true

A big issue I am facing is that I need the line chart to be smooth, hence I changed your library code: protected boolean mDrawCubic = true; in LineChart.java.
Now the chart looks smooth but has some incorrect positions. You can see the popup coming above the graph in http://i60.tinypic.com/2mpig3r.jpg also in this you can see some of the Y axis values above or below the curve, http://i62.tinypic.com/21mcbw5.png . How can I resolve this Phil ?

MulitLineChart coloring lines problem.

After last update with chart animations, I can not make multiline chart with diffrent color for each dataset.
According to your examples code part that set the color should look like this:

            LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
            d.setLineWidth(2.5f);
            d.setCircleSize(4f);

            int color = getResources().getColor(mColors[z % mColors.length]);
            d.setColor(color);
            d.setCircleColor(color);
            dataSets.add(d);

I use:

LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
            d.setLineWidth(2.5f);
            d.setDrawCircles(false);

            int color = app.getColors()[z];
            d.setColor(color);
            dataSets.add(d);

where app.getColors() returns colors:

colors = new int[finalLabels.size()];
        for(int i = 0; i < finalLabels.size(); i++) {
            colors[i] = getResources().getIdentifier("color_" + finalLabels.get(i).toLowerCase(), "color", getPackageName());
        }

When I set this up as above all lines are black.

I am pretty sure that is not my colors side problem as they work in other chart types and if I set colors like this:

d.setColors(app.getColors(), this);

I am getting 'rainbow lines' (check images). Morelikely it's library sided, I think.

screenshot_2014-08-19-12-39-25
screenshot_2014-08-19-12-36-08

btw.: If I am writing anyway, I havent researched well but barChart.setDrawHighlightArrow(true); is not working for me anymore.

scaling issue

is there a way to set the x scale of the graph so that it's not zoomed out all the time..

from this ....

view5_fotor

to this....

view6_fotor

thanks

Bar color and limit issue

Thank you for providing a very good library. I need your help to complete my requirement. I tried to findout solution on stackoverflow but didn't found any conversation about this topic. Actually i am working on Bar chart and i want to set particular bar color with every bar like if my value is less than 10 then i need to show different color otherwise different.

My another issue is to draw horizontal line at 10 values in a bar chart like it will look like a limit.

Thanks in advance
Regards
Vijay Kumar

Stacked BarChart

Title says it all. A stacking feature for the BarChart, where bars on the same x-index stack up would be awesome.

Horizontal scrolling

Hello PhilJay, thank you for your library is too great.
I would like to know if your library allows horizontal scrolling ?
I changed the layout but it's not worked :

capture d ecran 2014-08-22 a 12 10 15

Thank you

Legends

It would be great to have legends for the charts.
Either next to the chart (below, top, left, right side) or within the chart area would help.

x axis value

this is what's happending when I am displaying date values in line chart..
how to set margins..so it stays inside..
thanks

view

use of Barchart in with viewpager fragments

I am almost new to android. I am using your library at master branch. Your project looks very interesting for me.
I have some dummy values in array-
String[] valArray = new String[] { "23.5", "20.3", "23.5", "44" };
(where min-0 and max value=100 lets say)
I want to show a bar chart on a fragment page like below with same color bars with value on it and animation on draw up to height.
screenshot_2014-08-24-23-55-07

My main activity class is having a ViewPager. ViewPager is holding no of screens. here is the activity code-

       public class MainActivity extends FragmentActivity {
        ViewPager viewPager;
         PagerAdapter adapter;
         public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
          setContentView(R.layout.viewpager_main);
    initialisePaging();
            }
           private void initialisePaging() {

    //Loading screens
    List<Fragment> screens = new Vector<Fragment>();
    screens.add(Fragment.instantiate(this,Basic1.class.getName()));


    adapter =new ViewPagerAdapter(this.getSupportFragmentManager(),screens,);

    // Binds the Adapter to the ViewPager
    viewPager.setAdapter(adapter);
          }
          }

my adapter class -

    public class ViewPagerAdapter extends FragmentPagerAdapter {

     private List<Fragment> screens;

    public ViewPagerAdapter(FragmentManager fm, List<Fragment> fragments ) {
    super(fm);
            this.screens = fragments;
  }
@Override
public Fragment getItem(int arg0) {
    // TODO Auto-generated method stub
    return this.screens.get(arg0);
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return this.screens.size();
}
 }

Here is the fragment class where I want to draw the Barchart programmecally not from layout.-

     public class Basic1 extends Fragment {
Context mContext;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    if (container == null) {
        return null;
    }
           mContext = container.getContext();  
           String[] valArray = new String[] { "23.5", "20.3", "23.5", "44" };              
    View viewObj=inflater.inflate(R.layout.viewpager_item,
            container, false);
         return viewObj;
       }}

Here I want to draw the Animated BarChart.
a. I want to use the dataset from valArray in the class to draw the bars with animation.
b. When I swipe to another screen. It will disappire so that every this bargraph animation loads when this screens loads
c. Please let me know if I have to extend or implements in Basic1 Fragment

If you can help me I would be really appreciated. Since I am new to this. I am not able to understand properly and your example app in playstore.
Regards
Biswajit

Dynamically adding DataSets and Entries

Is there a way to add datasets dynamically? meaning..I have one dataset to begin with then add more as I retrieve more data..this is referring to multiple bar chart activity example

thanks

Legend does not fit on a screen (Legend wrapping?)

I'm working with library for couple of days now, but I can not figure out if there is a way to wrap legend somehow so it will fit on the screen?
My device has relative small screen resolution which is 480x800, and I can not put 8 legend records under the chart in vertical view in way that I would see all of them.

I do not know if I could'n find a feature, like line wrapping for legend, or this do not exist.

h_view
v_view

On screens you can see how Sport label was cut in vertical view, while it was visible in horizontal.

Question:why mXVals.size() < =1

I like this project.And Thank your work;
But when I use the PieChar,My data'size is 1.
So PieChar can't show ,beacuse isValid() return false.
Code:ChartData.class
public boolean isValid() {
if (mXVals == null || mXVals.size() < =1)
return false;

    if (mDataSets == null || mDataSets.size() < 1)
        return false;

    return true;
} 

Negative values

The legend on the y-axis sometimes has problems adjusting correctly to negative values in the chart. This issue only occurs when the legend is rounded.

How to add this library to my project?

Hey ,PhilJay. I want to develop an application with a chart functionality. So I found MPAndroidChart on github, I really like this project. But because I'm just starting out with github, so I do not know how to apply some of the features of this project to my application. I would be very appreciate if you could tell me the the way to apply it to my application!

NPE when lable is null

stacktrace print

08-02 09:50:21.170  27172-27172/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NullPointerException
            at com.github.mikephil.charting.data.ChartData.alreadyCounted(ChartData.java:165)
            at com.github.mikephil.charting.data.ChartData.calcTypes(ChartData.java:124)
            at com.github.mikephil.charting.data.ChartData.init(ChartData.java:79)
            at com.github.mikephil.charting.data.ChartData.<init>(ChartData.java:43)
            at com.xxmassdeveloper.mpchartexample.fragments.SimpleFragment.getComplexity(SimpleFragment.java:85)
            at com.xxmassdeveloper.mpchartexample.fragments.LineChartFrag.onCreateView(LineChartFrag.java:53)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
            at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
            at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
            at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
            at android.view.View.measure(View.java:15551)
            at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
            at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
            at android.view.View.measure(View.java:15551)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at android.view.View.measure(View.java:15551)
            at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            at android.view.View.measure(View.java:15551)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2177)
            at android.view.View.measure(View.java:15551)
            at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1887)
            at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1102)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1278)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1002)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4400)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
            at android.view.Choreographer.doCallbacks(Choreographer.java:562)
            at android.view.Choreographer.doFrame(Choreographer.java:532)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
            at android.os.Handler.handleCallback(Handler.java:725)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
            at dalvik.system.NativeStart.main(Native Method)

in CharData.java

    private boolean alreadyCounted(ArrayList<String> countedLabels, String label) {
        for (int i = 0; i < countedLabels.size(); i++) {
            if (countedLabels.get(i).equals(label))
                return true;
        }

        return false;
    }

mChart.setUnit("unit") display

is the set unit able to do display only once at the top of y bar instead of adding at every y bar interval..

thanks..

LineChart : different colors

Hello,

First of all, thanks a lot for this awesome chart library : it is very complete and customizable + the API seems to be very clear.

I just have one question about colors template. For the LineChart, it is possible to show different colors : one for each line, but is it possible to show different colors for the same line ? I would like to draw different colors for circles, lines and also for the background under the line when the 'filled' option is enabled. I see that I can redefine the Paint object for the circles and change their color, but I can't do the same for lines and filled background, am I wrong ?

Thanks in advance for your answer :)

Difficulties properly importing

I imported this module to Android Studio and gradle finishes without problem but it isn't actually done right. None of things get properly imported and I can't even call for a LineChart. None of the classes can be found on layout.

Is there a special way to import this to Android Studio?

Thanks

Viewport implementation

Hi Phil,
Thanks for the library. I have a chart with more than 100 values on X-Axis. So i tried using setScalaMinima to a particular value to zoom in. But is it possible to move the end of the chart ? Since its a timeline chart, i would like to show the user the latest entries first and the user can scroll left for more entries. Basically my requirement to show only particular no. of entries(like a viewport) and rest can be viewed by dragging the chart left.

Setting y-axis range

The setting of the y-axis range works in theory. Nevertheless, a clear structure needs to be implemented that can be understood easily by all library users. Furthermore, the range setting functionality still has issues concerning free-hand drawing.

Multiple bar chart datasets x axis

Can you have two sets of values for x axis..where one is date..which I can represent just fine but other is like names associated with the dataset..is there a way to show that?

thanks

Different line styles

It would be great, if you could support different line styles such as dashed or dotted lines for the LineChart.

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.