当前位置: 首页>>代码示例>>Java>>正文


Java LineData.addXValue方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.data.LineData.addXValue方法的典型用法代码示例。如果您正苦于以下问题:Java LineData.addXValue方法的具体用法?Java LineData.addXValue怎么用?Java LineData.addXValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.data.LineData的用法示例。


在下文中一共展示了LineData.addXValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addEntry

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {

        LineData data = mChart.getData();
        
        if(data != null) {

            ILineDataSet set = data.getDataSetByIndex(0);
            // set.addEntry(...); // can be called as well

            if (set == null) {
                set = createSet();
                data.addDataSet(set);
            }

            // add a new x-value first
            data.addXValue(set.getEntryCount() + "");
            
            // choose a random dataSet
            int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
            
            data.addEntry(new Entry((float) (Math.random() * 10) + 50f, set.getEntryCount()), randomDataSetIndex);

            // let the chart know it's data has changed
            mChart.notifyDataSetChanged();
            
            mChart.setVisibleXRangeMaximum(6);
            mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
//            
//            // this automatically refreshes the chart (calls invalidate())
            mChart.moveViewTo(data.getXValCount()-7, 50f, AxisDependency.LEFT);
        }
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:33,代码来源:DynamicalAddingActivity.java

示例2: addDataSet

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addDataSet() {

        LineData data = mChart.getData();
        
        if(data != null) {

            int count = (data.getDataSetCount() + 1);

            // create 10 y-vals
            ArrayList<Entry> yVals = new ArrayList<Entry>();
            
            if(data.getXValCount() == 0) {
                // add 10 x-entries
                for (int i = 0; i < 10; i++) {
                    data.addXValue("" + (i+1));
                }
            }

            for (int i = 0; i < data.getXValCount(); i++) {
                yVals.add(new Entry((float) (Math.random() * 50f) + 50f * count, i));
            }

            LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
            set.setLineWidth(2.5f);
            set.setCircleRadius(4.5f);

            int color = mColors[count % mColors.length];

            set.setColor(color);
            set.setCircleColor(color);
            set.setHighLightColor(color);
            set.setValueTextSize(10f);
            set.setValueTextColor(color);

            data.addDataSet(set);
            mChart.notifyDataSetChanged();
            mChart.invalidate();   
        }
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:40,代码来源:DynamicalAddingActivity.java

示例3: addEntry

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry() {

        LineData data = mChart.getData();

        if (data != null) {

            ILineDataSet set = data.getDataSetByIndex(0);
            // set.addEntry(...); // can be called as well

            if (set == null) {
                set = createSet();
                data.addDataSet(set);
            }

            // add a new x-value first
            data.addXValue(mMonths[data.getXValCount() % 12] + " "
                    + (year + data.getXValCount() / 12));
            data.addEntry(new Entry((float) (Math.random() * 40) + 30f, set.getEntryCount()), 0);


            // let the chart know it's data has changed
            mChart.notifyDataSetChanged();

            // limit the number of visible entries
            mChart.setVisibleXRangeMaximum(120);
            // mChart.setVisibleYRange(30, AxisDependency.LEFT);

            // move to the latest entry
            mChart.moveViewToX(data.getXValCount() - 121);

            // this automatically refreshes the chart (calls invalidate())
            // mChart.moveViewTo(data.getXValCount()-7, 55f,
            // AxisDependency.LEFT);
        }
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:36,代码来源:RealtimeLineChartActivity.java

示例4: addEntry

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry(float entry) {

        LineData data = lchScope.getData();

        if (data != null) {

            ILineDataSet set = data.getDataSetByIndex(0);
            // set.addEntry(...); // can be called as well

            if (set == null) {
                set = createSet();
                data.addDataSet(set);
            }

            Long tsLong = (System.currentTimeMillis() - relTime) / 1000;
            // if(tsLong != curTime) {
            data.addXValue(tsLong.toString());
            curTime = tsLong;
            //}

            data.addEntry(new Entry(entry, set.getEntryCount()), 0);

            lchScope.notifyDataSetChanged();
            lchScope.setVisibleXRangeMaximum(60);

            lchScope.moveViewToX(data.getXValCount() - 61);
        }
    }
 
开发者ID:MarcProe,项目名称:lp2go,代码行数:29,代码来源:ViewControllerScope.java

示例5: refreshData

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void refreshData() {
    LineData data = lineChart.getData();
    if (data != null) {
        LineDataSet set = (LineDataSet) data.getDataSetByIndex(0);
        if (set == null) {
            set = createSet();
            data.addDataSet(set);
        }

        if (set.getEntryCount() == timeframe) {
            data.removeXValue(0);
            set.removeEntry(0);
            for (Entry entry : set.getYVals()) {
                entry.setXIndex(entry.getXIndex() - 1);
            }
        }

        // add x-value
        Date date = new Date();
        Calendar calendar = GregorianCalendar.getInstance();
        calendar.setTime(date);
        int inthours = calendar.get(Calendar.HOUR_OF_DAY);
        int intminute = calendar.get(Calendar.MINUTE);
        String hourString = String.format("%02d:", inthours);
        String minuteString = String.format("%02d", intminute);
        XAxisTimeValue.add(hourString + minuteString);
        data.addXValue(XAxisTimeValue.get(data.getXValCount()));

        // choose a dataSet
        //RealmResults<BGdata> results = realm.allObjects(BGdata.class);
        //RealmLineDataSet(RealmResults<T> results, "calculated_value")
        //RealmLineDataSet<BGdata> dataSet = new RealmLineDataSet<BGdata>(results, "calculated_value");
        //RealmLineData dataset = new RealmLineData(results, "calculated_value", (List<ILineDataSet>) data);

        //lineChart.setData(dataset);


        data.addEntry(new Entry((float) calculated_value, set.getEntryCount()), 0);
        lineChart.notifyDataSetChanged();

        lineChart.setVisibleYRangeMaximum((float) calculated_value, YAxis.AxisDependency.LEFT);
        // this automatically refreshes the chart (calls invalidate())
        lineChart.moveViewTo(data.getXValCount(), (float) calculated_value, YAxis.AxisDependency.LEFT);
    }
}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:46,代码来源:wearDripWatchFace.java


注:本文中的com.github.mikephil.charting.data.LineData.addXValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。