调用notifyDataSetChanged()时,MPAndroidChart不是动画的

时间:2016-07-14 06:18:07

标签: android mpandroidchart

当我有一组更新的数据值,然后使用这些值更新图表并在MPAndroidChart中调用chart.notifyDataSetChanged时,是否应该有动画?

我认为效果类似于长度增长或相应长度减少的条形,但它只是略微达到了值。

代码:

                        if (m_chartHourlySales.getData() != null &&
                                m_chartHourlySales.getData().getDataSetCount() > 0)
                        {
                            set1 = (BarDataSet)m_chartHourlySales.getData().getDataSetByIndex(0);
                            set1.setValues(values.value);
                            m_chartHourlySales.getData().notifyDataChanged();
                            m_chartHourlySales.notifyDataSetChanged();
                        } else {
                            set1 = new BarDataSet(values.value, getResources().getString(R.string.total_sales_figures_for_each_hour));
                            set1.setValueFormatter(new ValueFormatter() {
                                @Override public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler)
                                {    
                                    return NumberFormat.getCurrencyInstance(Locale.getDefault()).format(value);
                                }
                            });
                            set1.setValueTextColor(Color.WHITE);

                            ArrayList<IBarDataSet> dataSets = new ArrayList<>();
                            dataSets.add(set1);

                            BarData data = new BarData(dataSets);
                            data.setValueTextSize(10f);
                            data.setBarWidth(barWidth.value);

                            m_chartHourlySales.moveViewToX(0);
                            m_chartHourlySales.setData(data);

                            m_chartHourlySales.setVisibleXRangeMaximum(17*20);
                            m_chartHourlySales.setVisibleXRangeMinimum(17*6);

                            m_chartHourlySales.moveViewToX(0);
                        }
                        m_chartHourlySales.invalidate();
                        m_chartHourlySales.refreshDrawableState();

0 个答案:

没有答案