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


Java LineData.addDataSet方法代码示例

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


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

示例1: generateLineData

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

        LineData d = new LineData();

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new Entry(index + 0.5f, getRandom(15, 5)));

        LineDataSet set = new LineDataSet(entries, "Line DataSet");
        set.setColor(Color.rgb(240, 238, 70));
        set.setLineWidth(2.5f);
        set.setCircleColor(Color.rgb(240, 238, 70));
        set.setCircleRadius(5f);
        set.setFillColor(Color.rgb(240, 238, 70));
        set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
        set.setDrawValues(true);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.rgb(240, 238, 70));

        set.setAxisDependency(YAxis.AxisDependency.LEFT);
        d.addDataSet(set);

        return d;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:CombinedChartActivity.java

示例2: addEntry

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private void addEntry(String label, int value) {
    LineData data = chart.getData();
    if (data != null) {
        int index;
        if (label.equals(pm1Label)) {
            index = 0;
        } else if (label.equals(pm25Label)) {
            index = 1;
        } else {
            index = 2;
        }
        ILineDataSet set = data.getDataSetByIndex(index);

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

        data.addEntry(new Entry(set.getEntryCount(), value), index);
    }
}
 
开发者ID:rjaros87,项目名称:pm-home-station,代码行数:22,代码来源:ChartFragment.java

示例3: addMainDataSets

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
/**
 * Adds the main data set for all times and the data set for the progression of record best
 * times among all times. The progression of best times are marked in a different color to the
 * main line of all time using circles lined with a dashed line. This will appear to connect
 * the lowest troughs along the main line of all times.
 *
 * @param chartData The chart data to which to add the new data sets.
 * @param allLabel  The label of the all-times line.
 * @param allColor  The color of the all-times line.
 * @param bestLabel The label of the best-times line.
 * @param bestColor The color of the best-times line.
 */
private void addMainDataSets(LineData chartData, String allLabel, int allColor,
                             String bestLabel, int bestColor) {
    // Main data set for all solve times.
    chartData.addDataSet(createDataSet(allLabel, allColor));

    // Data set to show the progression of best times along the main line of all times.
    final LineDataSet bestDataSet = createDataSet(bestLabel, bestColor);

    bestDataSet.enableDashedLine(3f, 6f, 0f);

    bestDataSet.setDrawCircles(true);
    bestDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
    bestDataSet.setCircleColor(bestColor);

    bestDataSet.setDrawValues(false);
    bestDataSet.setValueTextColor(bestColor);
    bestDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
    bestDataSet.setValueFormatter(new TimeChartValueFormatter());

    chartData.addDataSet(bestDataSet);
}
 
开发者ID:aricneto,项目名称:TwistyTimer,代码行数:34,代码来源:ChartStatistics.java

示例4: addAoNDataSets

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
/**
     * Adds the data set for the average-of-N (AoN) times and the corresponding data set for the
     * single best average time for that value of "N". The best AoN times are not shown as a
     * progression; only one time is shown and it superimposed on its main AoN line, rendered in
     * the same color as a circle and with the value drawn on the chart.
     *
     * @param chartData The chart data to which to add the new data sets.
     * @param label     The label of the AoN line and best AoN time marker.
     * @param color     The color of the AoN line and best AoN time marker.
     */
    private void addAoNDataSets(LineData chartData, String label, int color) {
        // Main AoN data set for all AoN times for one value of "N".
        chartData.addDataSet(createDataSet(label, color));

        // Data set for the single best AoN time for this "N".
        final LineDataSet bestAoNDataSet = createDataSet(label, color);

        bestAoNDataSet.setDrawCircles(true);
        bestAoNDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP);
        bestAoNDataSet.setCircleColor(color);

        // Drawing the value of the best AoN time for each "N" seems like it would be a good idea,
        // but the values are really hard because they appear over other chart lines and sometimes
        // over the values drawn for the best time progression. Disabling them is no great loss,
        // as the statistics table shows the same values, anyway. Just showing a circle to mark
        // the best AoN time looks well enough on its own.
        bestAoNDataSet.setDrawValues(false);
//        bestAoNDataSet.setValueTextColor(color);
//        bestAoNDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP);
//        bestAoNDataSet.setValueFormatter(new TimeChartValueFormatter());

        chartData.addDataSet(bestAoNDataSet);
    }
 
开发者ID:aricneto,项目名称:TwistyTimer,代码行数:34,代码来源:ChartStatistics.java

示例5: addEntry

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

        LineData data = mLineChart.getData();

        if (data != null) {

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

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

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

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

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

            // move to the latest entry
            mLineChart.moveViewToX(data.getEntryCount());

        }
    }
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:30,代码来源:RecordDBFragment.java

示例6: generateLineData

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
/**
 * 曲线
 */
private LineData generateLineData() {
    LineData lineData = new LineData();
    ArrayList<Entry> entries = new ArrayList<>();
    for (int index = 0; index < items.size(); index++) {
        entries.add(new Entry(index + 1f, (float) items.get(index).sub_data.getData()));
    }
    LineDataSet lineDataSet = new LineDataSet(entries, "对比数据");
    lineDataSet.setValues(entries);
    lineDataSet.setDrawValues(false);//是否在线上显示值
    lineDataSet.setColor(ContextCompat.getColor(mContext, R.color.co3));
    lineDataSet.setLineWidth(2.5f);
    lineDataSet.setCircleColor(ContextCompat.getColor(mContext, R.color.co3));
    lineDataSet.setCircleRadius(5f);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);//设置线条类型
    //set.setDrawHorizontalHighlightIndicator(false);//隐藏选中线
    //set.setDrawVerticalHighlightIndicator(false);//隐藏选中线条
    lineDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineDataSet.setHighlightEnabled(false);
    lineData.setHighlightEnabled(false);
    lineData.addDataSet(lineDataSet);
    return lineData;
}
 
开发者ID:jay16,项目名称:shengyiplus-android,代码行数:27,代码来源:HomeTricsActivity.java

示例7: generateLineData

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

        LineData d = new LineData();

        ArrayList<Entry> entries = new ArrayList<Entry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new Entry(getRandom(15, 10), index));

        LineDataSet set = new LineDataSet(entries, "Line DataSet");
        set.setColor(Color.rgb(240, 238, 70));
        set.setLineWidth(2.5f);
        set.setCircleColor(Color.rgb(240, 238, 70));
        set.setCircleRadius(5f);
        set.setFillColor(Color.rgb(240, 238, 70));
        set.setDrawCubic(true);
        set.setDrawValues(true);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.rgb(240, 238, 70));

        set.setAxisDependency(YAxis.AxisDependency.LEFT);

        d.addDataSet(set);

        return d;
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:27,代码来源:CombinedChartActivity.java

示例8: updateChart

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
public void updateChart(float value, int index) {
  LineData data = messagesChart.getData();
  ILineDataSet set = data.getDataSetByIndex(index);

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

  data.addEntry(new Entry(set.getEntryCount(), value), index);
  data.notifyDataChanged();

  messagesChart.notifyDataSetChanged();
  messagesChart.setVisibleXRangeMaximum(getVisibleRange().getRange());
  messagesChart.moveViewToX(data.getEntryCount());
}
 
开发者ID:tommus,项目名称:rabbitmq-management-android,代码行数:17,代码来源:MessagesIndicator.java

示例9: generateLineData

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

    ArrayList<Entry> entries = new ArrayList<Entry>();

    for (int index = 0; index < 3; index++)
        entries.add(new Entry(index + 0.5f, UtilsRG.getRandomNumberInRange(0, 1)));

    LineDataSet set = new LineDataSet(entries, "Line DataSet");
    set.setColor(R.color.colorPrimaryLight);
    set.setLineWidth(2.5f);
    set.setCircleColor(R.color.colorPrimaryLight);
    set.setCircleRadius(5f);
    set.setFillColor(R.color.colorPrimaryLight);
    set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    set.setDrawValues(true);
    set.setValueTextSize(10f);
    set.setValueTextColor(R.color.colorPrimaryLight);

    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    d.addDataSet(set);

    return d;
}
 
开发者ID:lidox,项目名称:reaction-test,代码行数:25,代码来源:BarChartView.java

示例10: addEntry

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

        LineData data = mChart.getData();

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

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

        // choose a random dataSet
        int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
        float yValue = (float) (Math.random() * 10) + 50f;

        data.addEntry(new Entry(data.getDataSetByIndex(randomDataSetIndex).getEntryCount(), yValue), randomDataSetIndex);
        data.notifyDataChanged();

        // 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.getEntryCount() - 7, 50f, AxisDependency.LEFT);

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:DynamicalAddingActivity.java

示例11: addDataSet

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

        LineData data = mChart.getData();

        if (data != null) {

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

            ArrayList<Entry> yVals = new ArrayList<Entry>();

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

            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);
            data.notifyDataChanged();
            mChart.notifyDataSetChanged();
            mChart.invalidate();
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:DynamicalAddingActivity.java

示例12: 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);
            }

            data.addEntry(new Entry(set.getEntryCount(), (float) (Math.random() * 40) + 30f), 0);
            data.notifyDataChanged();

            // 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.getEntryCount());

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

示例13: generateActivityLineData

import com.github.mikephil.charting.data.LineData; //导入方法依赖的package包/类
private LineData generateActivityLineData() {
    LineData lineData = new LineData();
    List<Map<String, Integer>> pairList = stats.getProjectPairList();
    Map<String, List<Entry>> projectsData = transformProjectData(pairList);

    int index = 0;
    for (Map.Entry<String, List<Entry>> entries : projectsData.entrySet()) {
        LineDataSet set = new LineDataSet(entries.getValue(), entries.getKey());
        formatLineDataSet(set, chartColors[index++], 3);
        lineData.addDataSet(set);
    }
    return lineData;
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:14,代码来源:DashboardFragment.java

示例14: 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

示例15: 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


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