MPAndroidChart: Chart Not Displaying

放肆的年华 提交于 2019-12-06 11:37:57

So it turns out that the width and height were being set to 0, so I changed them both from "match_parent" to an explicit setting in units of dp's (400dp and 200dp, respecitively), and that resolved the problem.

You can use the following code to set the width according to the device wether it is mobile or a tablet. I have added only few parameters you can add widtth & height as well to make your code smarter.

Code-

 /* Start of setMyDevice() */
    public static void setMyDevice(int screen_density, XAxis xa) {

        Log.e("Logger:Utility", "setMyDevice() Called");
        // int screen_density = (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);

        if (screen_density == Configuration.SCREENLAYOUT_SIZE_LARGE || screen_density == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
            //The device is a tablet or at least has the screen density of a tablet
            xa.setLabelRotationAngle(-35);
            xa.setDrawLabels(true);
            xa.setTextSize(14);
            Log.e("Logger:Utility", "setMyDevice-IT IS A TABLET");
        } else {
            xa.setLabelRotationAngle(-55);
            xa.setTextSize(10);
            Log.e("Logger:Utility", "setMyDevice-IT IS A MOBILE");
        }

    }
    /* End  of setMyDevice() */
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!