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


Java Chart.invalidate方法代码示例

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


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

示例1: setData

import com.github.mikephil.charting.charts.Chart; //导入方法依赖的package包/类
/**
 *
 * Dataset config details: https://github.com/PhilJay/MPAndroidChart/wiki/DataSet-classes-in-detail
 */
@ReactProp(name = "data")
public void setData(Chart chart, ReadableMap propMap) {
    if (!BridgeUtils.validate(propMap, ReadableType.Array, "datasets")) {
        return;
    }

    String[] xValues = new String[0];
    if (BridgeUtils.validate(propMap, ReadableType.Array, "xValues")) {
        xValues = BridgeUtils.convertToStringArray(propMap.getArray("xValues"));
    }

    ChartData<IDataSet<U>> chartData = createData(xValues);

    ReadableArray datasets = propMap.getArray("datasets");
    for (int i = 0; i < datasets.size(); i++) {
        ReadableMap dataset = datasets.getMap(i);

        // TODO validation
        ReadableArray yValues = dataset.getArray("yValues");
        String label = dataset.getString("label");

        ArrayList<U> entries = createEntries(yValues);

        IDataSet<U> lineDataSet = createDataSet(entries, label);

        if (BridgeUtils.validate(dataset, ReadableType.Map, "config")) {
            dataSetConfig(lineDataSet, dataset.getMap("config"));
        }

        chartData.addDataSet(lineDataSet);
    }

    chart.setData(chartData);
    chart.invalidate();
}
 
开发者ID:mskec,项目名称:react-native-mp-android-chart,代码行数:40,代码来源:ChartBaseManager.java

示例2: processParams

import com.github.mikephil.charting.charts.Chart; //导入方法依赖的package包/类
@Override
public void processParams(View view, Object... params) {

    Realm realm = Realm.getDefaultInstance();
    Chart chart = (Chart) view;

    LocalDate startDate = (LocalDate) params[0];
    LocalDate endDate = (LocalDate) params[1];

    Date iDate = startDate.toDateTimeAtStartOfDay().toDate();
    Date fDate = endDate.toDateTimeAtStartOfDay().toDate();

    boolean hasRegistries = (realm.where(Despesa.class).between("dataPaga", iDate, fDate)
            .count() + realm.where(Receita.class).between("dataPaga", iDate, fDate).count()) > 0;

    if (hasRegistries) {

        ArrayList<String> xVals = new ArrayList<>();
        ArrayList<LineDataSet> sets = new ArrayList<>();

        int xIndex = 0;

        List<Entry> valuesIncome = new ArrayList<>();
        List<Entry> valuesExpenditure = new ArrayList<>();
        List<Entry> valuesBalance = new ArrayList<>();

        for (LocalDate date = startDate; date.isBefore(endDate); date = date.plusDays(1)) {
            Date dateToCompare = date.toDateTimeAtStartOfDay().toDate();
            double expenditure = realm.where(Despesa.class).equalTo("dataPaga", dateToCompare).sumDouble
                    ("valorPago");
            double income = realm.where(Receita.class).equalTo("dataPaga", dateToCompare).sumDouble("valorPago");
            valuesIncome.add(new Entry((float) income, xIndex));
            valuesExpenditure.add(new Entry((float) expenditure, xIndex));
            valuesBalance.add(new Entry((float) (income - expenditure), xIndex));
            xIndex++;
            xVals.add(SimpleDateFormat.getDateInstance().format(dateToCompare));
        }

        LineDataSet ldsIncome = UtilPanel.buildLineDataSet(valuesIncome, chart.getContext()
                .getString(R
                        .string.incomes), Color.BLUE);
        LineDataSet ldsExpenditure = UtilPanel.buildLineDataSet(valuesExpenditure, chart.getContext().getString(R
                .string.expenses), Color.RED);
        LineDataSet ldsBalance = UtilPanel.buildLineDataSet(valuesBalance, chart.getContext()
                .getString(R.string.final_value), Color.GREEN);

        sets.add(ldsIncome);
        sets.add(ldsExpenditure);
        sets.add(ldsBalance);

        LineData lineData = new LineData(xVals, sets);
        chart.setData(lineData);
        chart.invalidate();
        chart.notifyDataSetChanged();
    }

    realm.close();

}
 
开发者ID:Tiraza,项目名称:easy-finance,代码行数:60,代码来源:PanelChartBalance.java


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