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


Java IValueFormatter类代码示例

本文整理汇总了Java中com.github.mikephil.charting.formatter.IValueFormatter的典型用法代码示例。如果您正苦于以下问题:Java IValueFormatter类的具体用法?Java IValueFormatter怎么用?Java IValueFormatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
@Override
public void setValueFormatter(IValueFormatter f) {

    if (f == null)
        return;
    else
        mValueFormatter = f;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:BaseDataSet.java

示例2: setValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
/**
 * Sets a custom IValueFormatter for all DataSets this data object contains.
 *
 * @param f
 */
public void setValueFormatter(IValueFormatter f) {
    if (f == null)
        return;
    else {
        for (IDataSet set : mDataSets) {
            set.setValueFormatter(f);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ChartData.java

示例3: setData

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
private void setData() {
    List<Entry> entries = data.getList();

    for(Entry e: entries){
        Date d= new Date((long) e.getX());
        Log.d(Const.TAG2, "Next Entry is "+d.toString()+" , "+e.getY());
    }

    LineDataSet dataSet = new LineDataSet(entries, "Hourly Weather report");
    dataSet.setColor(Color.rgb(184, 235, 161));
    dataSet.setDrawCircleHole(false);
    dataSet.setCircleColor(Color.CYAN);
    dataSet.setValueTextColor(Color.WHITE);
    dataSet.setValueTextSize(15);
    dataSet.setDrawFilled(true);
    dataSet.setFillColor(Color.LTGRAY);
    dataSet.setDrawValues(true);
    dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    dataSet.setValueFormatter(new IValueFormatter() {
        @Override
        public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
            int newValue = (int) value;
            return newValue + Const.DEGREE;
        }
    });

    LineData lineData = new LineData(dataSet);

    lineChart.setData(lineData);
    lineChart.invalidate();//refresh
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:32,代码来源:WeatherGraph.java

示例4: TestCaseRunner

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
TestCaseRunner(int iterations, BarChart chart, String title, int color, IValueFormatter valueFormatter) {
    mIterations = iterations;
    mChart = chart;
    mEntries = new LinkedList<>();
    mDataSet = new BarDataSet(mEntries, title);
    mDataSet.setValueFormatter(valueFormatter);
    mDataSet.setColor(color);
}
 
开发者ID:jasonwyatt,项目名称:SQLite-Performance,代码行数:9,代码来源:TestCaseRunner.java

示例5: generateBarData

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
private BarData generateBarData(float index, float dis) {

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


        for (int i = 0; i < count; i++) {
            float a = new Random().nextInt(40) / 100f + 0.1f;
            float b = new Random().nextInt(40) / 100f + 0.1f;
            entries.add(new BarEntry(index, new float[]{a, b, 1 - a - b}));
            index += dis;
        }

        BarDataSet set = new BarDataSet(entries, "hello");
        set.setStackLabels(new String[]{"1", "2"});
        set.setColors(new int[]{Color.rgb(154, 209, 253), Color.rgb(254, 206, 121), Color.rgb(253, 136, 95)});
        set.setValueTextColor(Color.rgb(61, 165, 255));
        set.setValueTextSize(10f);
        set.setAxisDependency(YAxis.AxisDependency.LEFT);


        ArrayList<IBarDataSet> threebardata = new ArrayList<>();

        BarData d = new BarData(threebardata);
        d.setBarWidth(0.4f);
        d.setDrawValues(true);

        d.addDataSet(set);

        d.setValueFormatter(new IValueFormatter() {
            @Override
            public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
                return toPercentDecimalStr(value);
            }
        });
        return d;
    }
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:37,代码来源:MainActivity.java

示例6: getValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
@Override
public IValueFormatter getValueFormatter() {
    if (needsFormatter())
        return Utils.getDefaultValueFormatter();
    return mValueFormatter;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:BaseDataSet.java

示例7: generateDefaultValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
private static IValueFormatter generateDefaultValueFormatter() {
    final DefaultValueFormatter formatter = new DefaultValueFormatter(1);
    return formatter;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:Utils.java

示例8: getDefaultValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
public static IValueFormatter getDefaultValueFormatter()
{
    return mDefaultValueFormatter;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:Utils.java

示例9: prepareGraphLayout

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
private void prepareGraphLayout() {
        loadingLayout.setVisibility(View.GONE);
        errorLayout.setVisibility(View.GONE);
        swipeRefreshLayout.setVisibility(View.VISIBLE);

        swipeRefreshLayout.setRefreshing(false);

        if (results.getCounted() > 0f) {
            pieChart.setVisibility(View.VISIBLE);
            emptyChart.setVisibility(View.GONE);

            ArrayList<PieEntry> entries = new ArrayList<>();
            entries.add(new PieEntry(results.getInvalid(), StringsManager.getString("graph_invalid")));
            entries.add(new PieEntry(results.getBlank(), StringsManager.getString("graph_blank")));
            entries.add(new PieEntry(results.getNo(), StringsManager.getString("graph_no")));
            entries.add(new PieEntry(results.getYes(), StringsManager.getString("graph_yes")));
            PieDataSet set = new PieDataSet(entries, "");
            set.setColors(Color.parseColor("#43474e"), Color.parseColor("#7f7f7f"), Color.parseColor("#fc543d"), Color.parseColor("#65c258"));
//            set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
//            set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
//            set.setSliceSpace(2f);
            set.setValueTextSize(16f);
            set.setValueTextColor(Color.WHITE);
            PieData data = new PieData(set);
            data.setValueFormatter(new IValueFormatter() {

                @Override
                public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
                    // write your logic here
                    return new DecimalFormat("##0.0").format(value) + "%"; // e.g. append a dollar-sign
                }
            });
            pieChart.setData(data);
            pieChart.getLegend().setEnabled(false);
            pieChart.setUsePercentValues(true);
            pieChart.setEntryLabelColor(Color.WHITE);
            pieChart.setEntryLabelTextSize(16f);
            pieChart.setRotationEnabled(false);
            Description description = new Description();
            description.setText("");
            pieChart.setDescription(description);

            pieChart.invalidate();
        } else {
            pieChart.setVisibility(View.GONE);
            emptyChart.setVisibility(View.VISIBLE);
        }

        counted.setText(new DecimalFormat("##0.0").format(results.getCounted()) + "%");
        countedBar.setProgress((int) (results.getCounted() * 10));
        participation.setText(new DecimalFormat("##0.0").format(results.getParticipation()) + "%");
        participationBar.setProgress((int) (results.getParticipation() * 10));

        countedBar.getProgressDrawable().setColorFilter(
                ResourcesCompat.getColor(getResources(), R.color.grey_dark, getContext().getTheme()), android.graphics.PorterDuff.Mode.SRC_IN);
        participationBar.getProgressDrawable().setColorFilter(
                ResourcesCompat.getColor(getResources(), R.color.red, getContext().getTheme()), android.graphics.PorterDuff.Mode.SRC_IN);

        if (TextUtils.isEmpty(results.getMessage())) {
            message.setVisibility(View.GONE);
        } else {
            message.setVisibility(View.VISIBLE);
            message.setText(results.getMessage());
        }
    }
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:66,代码来源:ResultsFragment.java

示例10: updateGraph

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
public void updateGraph(){

        List<Entry> entries = new ArrayList<>();
        Last7Days newDays = AxisFormatter.reverseLast7Days(last7Days);
        int i = 0;
        for(long dataEntry : get7Days(newDays)){
            entries.add(new Entry((float)i,(float)dataEntry));
            i++;
        }
        LineDataSet dataSet = new LineDataSet(entries,context.getString(R.string.main_scores));
        dataSet.setColor(ContextCompat.getColor(context,R.color.greenDark));
        dataSet.setValueTextSize(14f);
        dataSet.setValueFormatter(new IValueFormatter() {
            @Override
            public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
                return String.valueOf((int) value);
            }
        });
        dataSet.setCircleColor(ContextCompat.getColor(context,R.color.greenPrimary));
        dataSet.setLineWidth(3f);
        dataSet.setCircleRadius(10f);
        dataSet.setDrawValues(false);
        dataSet.setHighlightEnabled(true);
        LineData lineData = new LineData(dataSet);
        graph.setData(lineData);
        Description description = new Description();
        description.setEnabled(false);
        description.setText("");
        graph.setDescription(description);
        graph.setNoDataText(context.getString(R.string.main_connecting));
        graph.setNoDataTextColor(ContextCompat.getColor(context,R.color.greenDark));
        graph.setDrawGridBackground(false);
        graph.setDrawBorders(false);
        YAxis leftAxis = graph.getAxisLeft();
        leftAxis.setEnabled(false);
        leftAxis.setAxisMinimum(0);
        YAxis rightAxis = graph.getAxisRight();
        rightAxis.setEnabled(false);
        XAxis xAxis = graph.getXAxis();
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(System.currentTimeMillis());
        ArrayList<Date> dateArrayList = new ArrayList<>();
        for(int count = 0;count<7;count++){
            Date date = c.getTime();
            dateArrayList.add(date);
            c.setTimeInMillis(c.getTimeInMillis() - ((long) 1000 * 60 * 60 * 24 ));
        }
        Collections.reverse(dateArrayList);
        xAxis.setValueFormatter(new AxisFormatter(context,dateArrayList,dateFormatPattern));
        xAxis.setTextSize(10f);
        graph.setTouchEnabled(false);
        graph.setDragEnabled(false);
        graph.setScaleEnabled(false);
        graph.setScaleXEnabled(false);
        graph.setScaleYEnabled(false);
        graph.setPinchZoom(false);
        graph.setDoubleTapToZoomEnabled(false);
        Legend legend = graph.getLegend();
        legend.setEnabled(false);
        graph.invalidate();

    }
 
开发者ID:gincos,项目名称:BeHealthy,代码行数:63,代码来源:MainFragment.java

示例11: getDefaultValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
/**
 * Returns the default IValueFormatter that has been determined by the chart
 * considering the provided minimum and maximum values.
 *
 * @return
 */
public IValueFormatter getDefaultValueFormatter() {
    return mDefaultValueFormatter;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:Chart.java

示例12: drawValue

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
/**
 * Draws the value of the given entry by using the provided IValueFormatter.
 *
 * @param c            canvas
 * @param formatter    formatter for custom value-formatting
 * @param value        the value to be drawn
 * @param entry        the entry the value belongs to
 * @param dataSetIndex the index of the DataSet the drawn Entry belongs to
 * @param x            position
 * @param y            position
 * @param color
 */
public void drawValue(Canvas c, IValueFormatter formatter, float value, Entry entry, int dataSetIndex, float x, float y, int color) {
    mValuePaint.setColor(color);
    c.drawText(formatter.getFormattedValue(value, entry, dataSetIndex, mViewPortHandler), x, y, mValuePaint);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DataRenderer.java

示例13: setValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
/**
 * Sets the formatter to be used for drawing the values inside the chart. If
 * no formatter is set, the chart will automatically determine a reasonable
 * formatting (concerning decimals) for all the values that are drawn inside
 * the chart. Use chart.getDefaultValueFormatter() to use the formatter
 * calculated by the chart.
 *
 * @param f
 */
void setValueFormatter(IValueFormatter f);
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:IDataSet.java

示例14: getValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
/**
 * Returns the formatter used for drawing the values inside the chart.
 *
 * @return
 */
IValueFormatter getValueFormatter();
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:IDataSet.java

示例15: getDefaultValueFormatter

import com.github.mikephil.charting.formatter.IValueFormatter; //导入依赖的package包/类
IValueFormatter getDefaultValueFormatter(); 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:2,代码来源:ChartInterface.java


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