當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。