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


Java LineChart.notifyDataSetChanged方法代码示例

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


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

示例1: refreshTemperatureChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
public void refreshTemperatureChart(LineChart temperatureChart, MarsI2cControl i2cControl) {
    int[] c = {0,0,0,0};
    float[] tempValues = {i2cControl.getT1(), i2cControl.getT2(), i2cControl.getT3(), i2cControl.getGlobalTemp()};

    for (int i=0;i<4;i++) {

        c[i] = temperatureChart.getLineData().getDataSetByIndex(i).getEntryCount();
        temperatureChart.getLineData().getDataSetByIndex(i).removeFirst();
        temperatureChart.getLineData().getDataSetByIndex(i).addEntry(new Entry(c[i]++ + auxForTemperatureBuffer[i], tempValues[i]));
        auxForTemperatureBuffer[i]++;
    }

    temperatureChart.getLineData().notifyDataChanged();
    temperatureChart.notifyDataSetChanged();
    temperatureChart.invalidate();

}
 
开发者ID:bregydoc,项目名称:MarsWeatherSimulator,代码行数:18,代码来源:ChartsControl.java

示例2: refreshGasesChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
public void refreshGasesChart(LineChart gasesChart, MarsI2cControl i2cControl) {
    int[] c = {0,0};
    float[] tempValues = {i2cControl.getO2(), i2cControl.getCo2()};

    for (int i=0;i<2;i++) {

        c[i] = gasesChart.getLineData().getDataSetByIndex(i).getEntryCount();
        gasesChart.getLineData().getDataSetByIndex(i).removeFirst();
        gasesChart.getLineData().getDataSetByIndex(i).addEntry(new Entry(c[i]++ + auxForGasesBuffer[i], tempValues[i]));
        auxForGasesBuffer[i]++;
    }

    gasesChart.getLineData().notifyDataChanged();
    gasesChart.notifyDataSetChanged();
    gasesChart.invalidate();
}
 
开发者ID:bregydoc,项目名称:MarsWeatherSimulator,代码行数:17,代码来源:ChartsControl.java

示例3: setupChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void setupChart(LineChart chart, LineData data, int color) {
    ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setTouchEnabled(false);
    chart.setDragEnabled(false);
    chart.setScaleEnabled(true);
    chart.setPinchZoom(false);
    chart.setBackgroundColor(color);
    chart.setViewPortOffsets(0, 23, 0, 0);
    chart.setData(data);
    Legend l = chart.getLegend();
    l.setEnabled(false);

    chart.getAxisLeft().setEnabled(true);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getAxisLeft().setDrawAxisLine(false);
    chart.getAxisLeft().setSpaceTop(10);
    chart.getAxisLeft().setSpaceBottom(30);
    chart.getAxisLeft().setAxisLineColor(0xFFFFFF);
    chart.getAxisLeft().setTextColor(0xFFFFFF);
    chart.getAxisLeft().setDrawTopYLabelEntry(true);
    chart.getAxisLeft().setLabelCount(10);

    chart.getXAxis().setEnabled(true);
    chart.getXAxis().setDrawGridLines(false);
    chart.getXAxis().setDrawAxisLine(false);
    chart.getXAxis().setAxisLineColor(0xFFFFFF);
    chart.getXAxis().setTextColor(0xFFFFFF);

    Typeface tf = Typeface.DEFAULT;

    // X Axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setTypeface(tf);
    xAxis.removeAllLimitLines();

    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    xAxis.setTextColor(Color.argb(150, 255, 255, 255));

    if (displayType == 1 || displayType == 2) // Week and Month
        xAxis.setValueFormatter(new WeekXFormatter());
    else if (displayType == 0) //  Day
        xAxis.setValueFormatter(new HourXFormatter());
    else
        xAxis.setValueFormatter(new YearXFormatter()); // Year

    // Y Axis
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.removeAllLimitLines();
    leftAxis.setTypeface(tf);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    leftAxis.setTextColor(Color.argb(150, 255, 255, 255));
    leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd));
    chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines

    chart.animateX(1300);
    chart.notifyDataSetChanged();
}
 
开发者ID:manuelsc,项目名称:Lunary-Ethereum-Wallet,代码行数:61,代码来源:FragmentPrice.java

示例4: setChart1Value

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
/**
 * Used to display the value from the measure list into the chart
 * @param measures The list of the measure we want to display
 * @param labelName The label we want to display for each value under the graph
 */
private void setChart1Value(List<Measure> measures, String labelName,String dateFormat, CustomRules rule) {


    chart=(LineChart) view.findViewById(R.id.chart_measure);
    if (measures.size()==0)
        return;
    //data for the entry
    List<Entry> dataEntries=new ArrayList<>();

    //get the data based on measure
    for (int k=0;k<measures.size();k++)
    {   //add the entry
        dataEntries.add(new Entry(k,measures.get(k).getValue1().floatValue()));
        //enter the fix value related to the rule
    }
    //add label instead of number in the axis
    chart.notifyDataSetChanged();

    //sort otherwise we will trigger an error
    Collections.sort(dataEntries, new EntryXComparator());
    //add the entry to a data set (data that belong together), it's a line
    LineDataSet dataSet=new LineDataSet(dataEntries,labelName);
    dataSet.setColor(Color.BLUE);
    dataSet.setValueTextColor(Color.BLACK);
    //create a data set for each line

    LineData lineData=new LineData(dataSet);
    chart.setData(lineData);
    //refresh view
    IAxisValueFormatter formatter =new XaxValueFormater(measures,dateFormat);
    //set the gape between value in x axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setGranularity(1f); // minimum axis-step (interval) is 1
    //set the label instead of numner
    xAxis.setValueFormatter(formatter);
    dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);


    dataSet.setDrawFilled(true);
    dataSet.setFillColor(Color.BLUE);
    //draw the limite of the allowed value
    setLimites(rule);
    chart.getDescription().setEnabled(false);
    chart.invalidate();

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:52,代码来源:Fragment_display_measures.java

示例5: updateLastScanChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
public void updateLastScanChart() {

        SharedPreferences sharedPrefs = PreferenceManager
                .getDefaultSharedPreferences(this.getApplicationContext());

        ImageView iv_unit;
        iv_unit = (ImageView)findViewById(R.id.iv_unit);


        if(sharedPrefs.getString("pref_unit", "mg/dl").equals("mg/dl")) {
            iv_unit.setImageResource(R.drawable.unit_mgdl);
        }else{
            iv_unit.setImageResource(R.drawable.unit_mmoll);
        }

        LineChart cv_LastScan = (LineChart) findViewById(R.id.cv_LastScan);

        if(sharedPrefs.getBoolean("pref_nightmode", false)) {
            cv_LastScan.setBackgroundColor(getResources().getColor(R.color.colorBackgroundDark));
        }else{
            cv_LastScan.setBackgroundColor(getResources().getColor(R.color.colorBackgroundLight));
        }

        LineData getData = cv_LastScan.getData();
        if(getData != null) {
            YAxis yAxisLeft = cv_LastScan.getAxisLeft();

            yAxisLeft.removeAllLimitLines();
            yAxisLeft.setDrawLimitLinesBehindData(true);
            yAxisLeft.resetAxisMaxValue();

            if (cv_LastScan.getData() != null && !sharedPrefs.getString("pref_default_range", "0.0").equals("")) {
                if (cv_LastScan.getData().getDataSets().get(0).getYMax() < Float.valueOf(sharedPrefs.getString("pref_default_range", "0.0"))) { //Todo: platz für highlight
                    yAxisLeft.setAxisMaxValue(Float.valueOf(sharedPrefs.getString("pref_default_range", "0.0")));
                }
            }

            LimitLine ll_max = new LimitLine(Float.valueOf(sharedPrefs.getString("pref_zb_max", "-100.0")), getResources().getString(R.string.pref_zb_max));
            ll_max.setLineWidth(4f);
            ll_max.setTextSize(12f);

            LimitLine ll_min = new LimitLine(Float.valueOf(sharedPrefs.getString("pref_zb_min", "-100.0")), getResources().getString(R.string.pref_zb_min));
            ll_min.setLineWidth(4f);
            ll_min.setTextSize(12f);

            ll_min.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);

            Legend legend = cv_LastScan.getLegend();
            legend.setEnabled(false);

            // set an alternative background color
            if (sharedPrefs.getBoolean("pref_nightmode", false)) {
                ll_max.setLineColor(getResources().getColor(R.color.colorZielbereichDark));
                ll_max.setTextColor(getResources().getColor(R.color.colorZielbereichDark));

                ll_min.setLineColor(getResources().getColor(R.color.colorZielbereichDark));
                ll_min.setTextColor(getResources().getColor(R.color.colorZielbereichDark));
            } else {
                ll_max.setLineColor(getResources().getColor(R.color.colorZielbereichLight));
                ll_max.setTextColor(getResources().getColor(R.color.colorZielbereichLight));

                ll_min.setLineColor(getResources().getColor(R.color.colorZielbereichLight));
                ll_min.setTextColor(getResources().getColor(R.color.colorZielbereichLight));
            }

            yAxisLeft.addLimitLine(ll_max);
            yAxisLeft.addLimitLine(ll_min);

            cv_LastScan.notifyDataSetChanged();
            cv_LastScan.invalidate();
        }

    }
 
开发者ID:CMKlug,项目名称:Liapp,代码行数:74,代码来源:MainActivity.java


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