• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Description类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createPieChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void createPieChart(ArrayList<PieEntry> yEntrys, ArrayList<Integer> colors) {

        //create the data set
        PieDataSet pieDataSet = new PieDataSet(yEntrys, "");
        pieDataSet.setSliceSpace(2);
        pieDataSet.setValueTextSize(12);
        pieDataSet.setColors(colors);

        pieChart.setCenterText(start.toString() + "\n" + end.toString());
        pieChart.setCenterTextColor(Color.BLACK);
        pieChart.setCenterTextSize(20);

        pieChart.animateY(2000);
        pieChart.animateX(2000);
        pieChart.getLegend().setEnabled(true);

        Description description = new Description();
        description.setText("");
        pieChart.setDescription(description);

        //create pie data object
        PieData pieData = new PieData();
        pieData.addDataSet(pieDataSet);
        pieChart.setData(pieData);
        pieChart.invalidate();
    }
 
开发者ID:alewin,项目名称:moneytracking,代码行数:27,代码来源:ShowChartActivity.java


示例2: prepareLegend

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
 * Create a legend based on a dummy chart.  The legend
 * is used by all charts and is positioned
 * across the top of the screen.
 * @param data - CombinedData used to generate the legend
 */
private void prepareLegend(final CombinedData data){
  //The dummy chart is never shown, but it's legend is.
  final CombinedChart dummyChart = (CombinedChart) mRoot.findViewById(R.id.legend);
  dummyChart.getPaint(Chart.PAINT_DESCRIPTION).setTextAlign(Paint.Align.CENTER);
  dummyChart.getXAxis().setEnabled(false);
  dummyChart.getAxisRight().setEnabled(false);
  dummyChart.getAxisLeft().setEnabled(false);
  final Description description = new Description();
  description.setText("");
  description.setTextSize(10f);
  dummyChart.setDescription(description);
  dummyChart.setBackgroundColor(Color.WHITE);
  dummyChart.setDrawGridBackground(false);
  dummyChart.setData(data);

  final Legend l = dummyChart.getLegend();
  l.setEnabled(true);
  // The positioning of the legend effectively
  // hides the dummy chart from view.
  l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
  l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
  dummyChart.invalidate();
}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:30,代码来源:SummaryChartFragment.java


示例3: drawLatencyChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void drawLatencyChart(List<Entry> phoneEntriesShifted, List<Entry> waltEntries) {
    final ScatterDataSet dataSetWalt =
            new ScatterDataSet(waltEntries, "WALT Events");
    dataSetWalt.setColor(Color.BLUE);
    dataSetWalt.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
    dataSetWalt.setScatterShapeSize(8f);

    final ScatterDataSet dataSetPhoneShifted =
            new ScatterDataSet(phoneEntriesShifted, "Phone Events Shifted");
    dataSetPhoneShifted.setColor(Color.RED);
    dataSetPhoneShifted.setScatterShapeSize(10f);
    dataSetPhoneShifted.setScatterShape(ScatterChart.ScatterShape.X);

    final ScatterData scatterData = new ScatterData(dataSetWalt, dataSetPhoneShifted);
    final Description desc = new Description();
    desc.setText("");
    desc.setTextSize(12f);
    latencyChart.setDescription(desc);
    latencyChart.setData(scatterData);
    latencyChart.invalidate();
    latencyChartLayout.setVisibility(View.VISIBLE);
}
 
开发者ID:google,项目名称:walt,代码行数:23,代码来源:AccelerometerFragment.java


示例4: initializeChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
protected void initializeChart() {
  Description description = new Description();
  description.setText("");
  messagesChart.setDescription(description);
  messagesChart.setNoDataText(getIdleText());
  messagesChart.setTouchEnabled(false);
  messagesChart.setDragEnabled(false);
  messagesChart.setPinchZoom(false);
  messagesChart.getLegend().setEnabled(false);
  messagesChart.getAxisLeft().setAxisMinimum(0);
  messagesChart.getAxisLeft().setGranularity(1f);
  messagesChart.getAxisRight().setEnabled(false);
  messagesChart.getXAxis().setAxisMinimum(0);
  messagesChart.getXAxis().setGranularity(1f);
  messagesChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
  messagesChart.getXAxis().setValueFormatter(new DefaultAxisValueFormatter(0));

  LineData data = new LineData();
  data.setValueTextColor(Color.WHITE);
  messagesChart.setData(data);
}
 
开发者ID:tommus,项目名称:rabbitmq-management-android,代码行数:22,代码来源:MessagesIndicator.java


示例5: initBatteryChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void initBatteryChart() {
    mBatteryChart = findViewById(R.id.batteryPieChart);
    // configure pie chart
    mBatteryChart.setUsePercentValues(true);
    mBatteryChart.setDescription(new Description());
    // enable hole and configure
    mBatteryChart.setDrawHoleEnabled(true);
    Legend legend = mBatteryChart.getLegend();
    legend.setEnabled(false);
}
 
开发者ID:ponewheel,项目名称:android-ponewheel,代码行数:11,代码来源:MainActivity.java


示例6: setDescription

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
 * 设置描述信息
 *
 * @param str
 */
public void setDescription(String str) {
    Description description = new Description();
    description.setText(str);
    mBarChart.setDescription(description);
    mBarChart.invalidate();
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:12,代码来源:BarChartManager.java


示例7: showChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
 * Display the chart view
 */
private void showChart(){
  final String [] labels = mData.getDataSetLabels();
  String property = mData.getDataSetLabels()[labels.length -1];

  mChart.setData(mData);
  mChart.getAxisLeft().setInverted(true);
  mChart.getXAxis().setEnabled(true);
  mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);

  mChart.getXAxis().setAxisMinimum(mData.getXMin()-1);
  mChart.getXAxis().setAxisMaximum(mData.getXMax() + 1);
  mChart.getAxisRight().setEnabled(false);
  mChart.getAxisLeft().setDrawGridLines(true);
  mChart.setDrawGridBackground(true);
  final Description description = new Description();
  description.setText("");
  description.setTextSize(10f);
  mChart.setDescription(description);
  mChart.getLegend().setEnabled(false);

  mChart.invalidate();
  if (property.equalsIgnoreCase("TEMPERATURE")){
    property = property + " \u2103";
  }else if (property.equalsIgnoreCase("SALINITY")){
    property = property + " ppm";
  }else{
    property = property + " \u00b5" + "m/L";
  }
  mTxtXAxisTitle.setText(property);
}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:34,代码来源:ChartFragment.java


示例8: setupPie

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void setupPie(PieChart pieChart, int pos, float dados[], String labels[]) {


        List<PieEntry> entries = new ArrayList<>();
        int index = 0;
        for (float dado : dados) {
            entries.add(new PieEntry(dado, labels[index]));
            index++;
        }

        //entries.add(new PieEntry(24.0f, "Red"));
        //entries.add(new PieEntry(30.8f, "Blue"));

        PieDataSet set = new PieDataSet(entries, "");
        Description description = new Description();
        description.setText(" ");
        pieChart.setDescription(description);
        set.setColors(ColorTemplate.MATERIAL_COLORS);
        PieData data = new PieData(set);
        pieChart.setData(data);
        pieChart.invalidate();


        Legend l = pieChart.getLegend();
        l.setFormSize(15f); // set the size of the legend forms/shapes
        l.setForm(Legend.LegendForm.CIRCLE); // set what type of form/shape should be used
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
        l.setOrientation(Legend.LegendOrientation.VERTICAL);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
        l.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        l.setTextSize(18f);
        l.setTextColor(Color.BLACK);
        l.setXEntrySpace(5f); // set the space between the legend entries on the x-axis
        l.setYEntrySpace(5f);

        pieChart.animateXY(3000, 3000);

    }
 
开发者ID:ivoribeiro,项目名称:AndroidQuiz,代码行数:39,代码来源:AdapterEstatisticasGraph.java


示例9: drawLatencyGraph

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void drawLatencyGraph(double[] ft, double[] fy, double[] lt, double averageBestShift) {
    final ArrayList<Entry> touchEntries = new ArrayList<>();
    final ArrayList<Entry> laserEntries = new ArrayList<>();
    final double[] laserT = new double[lt.length];
    for (int i = 0; i < ft.length; i++) {
        touchEntries.add(new Entry((float) ft[i], (float) fy[i]));
    }
    for (int i = 0; i < lt.length; i++) {
        laserT[i] = lt[i] + averageBestShift;
    }
    final double[] laserY = Utils.interp(laserT, ft, fy);
    for (int i = 0; i < laserY.length; i++) {
        laserEntries.add(new Entry((float) laserT[i], (float) laserY[i]));
    }

    final ScatterDataSet dataSetTouch = new ScatterDataSet(touchEntries, "Touch Events");
    dataSetTouch.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
    dataSetTouch.setScatterShapeSize(8f);

    final ScatterDataSet dataSetLaser = new ScatterDataSet(laserEntries,
            String.format(Locale.US, "Laser Events  Latency=%.1f ms", averageBestShift));
    dataSetLaser.setColor(Color.RED);
    dataSetLaser.setScatterShapeSize(10f);
    dataSetLaser.setScatterShape(ScatterChart.ScatterShape.X);

    final ScatterData scatterData = new ScatterData(dataSetTouch, dataSetLaser);
    final Description desc = new Description();
    desc.setText("Y-Position [pixels] vs. Time [ms]");
    desc.setTextSize(12f);
    latencyChart.setDescription(desc);
    latencyChart.setData(scatterData);
    latencyChartLayout.setVisibility(View.VISIBLE);
}
 
开发者ID:google,项目名称:walt,代码行数:34,代码来源:DragLatencyFragment.java


示例10: drawBrightnessChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void drawBrightnessChart() {
    final String brightnessCurveString = brightnessCurveData.toString();
    List<Entry> entries = new ArrayList<>();

    // "u" marks the start of the brightness curve data
    int startIndex = brightnessCurveString.indexOf("u") + 1;
    int endIndex = brightnessCurveString.indexOf("end");
    if (endIndex == -1) endIndex = brightnessCurveString.length();

    String[] brightnessStrings =
            brightnessCurveString.substring(startIndex, endIndex).trim().split("\n");
    for (String str : brightnessStrings) {
        String[] arr = str.split(" ");
        final float timestampMs = Integer.parseInt(arr[0]) / 1000f;
        final float brightness = Integer.parseInt(arr[1]);
        entries.add(new Entry(timestampMs, brightness));
    }
    LineDataSet dataSet = new LineDataSet(entries, "Brightness");
    dataSet.setColor(Color.BLACK);
    dataSet.setValueTextColor(Color.BLACK);
    dataSet.setCircleColor(Color.BLACK);
    dataSet.setCircleRadius(1.5f);
    dataSet.setCircleColorHole(Color.DKGRAY);
    LineData lineData = new LineData(dataSet);
    brightnessChart.setData(lineData);
    final Description desc = new Description();
    desc.setText("Screen Brightness [digital level 0-1023] vs. Time [ms]");
    desc.setTextSize(12f);
    brightnessChart.setDescription(desc);
    brightnessChart.getLegend().setEnabled(false);
    brightnessChart.invalidate();
    brightnessChartLayout.setVisibility(View.VISIBLE);
}
 
开发者ID:google,项目名称:walt,代码行数:34,代码来源:ScreenResponseFragment.java


示例11: drawWaveformChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void drawWaveformChart() {
    final short[] wave = AudioTest.getRecordedWave();
    List<Entry> entries = new ArrayList<>();
    int frameRate = audioTest.getOptimalFrameRate();
    for (int i = 0; i < wave.length; i++) {
        float timeStamp = (float) i / frameRate * 1000f;
        entries.add(new Entry(timeStamp, (float) wave[i]));
    }
    LineDataSet dataSet = new LineDataSet(entries, "Waveform");
    dataSet.setColor(Color.BLACK);
    dataSet.setValueTextColor(Color.BLACK);
    dataSet.setCircleColor(ContextCompat.getColor(getContext(), R.color.DarkGreen));
    dataSet.setCircleRadius(1.5f);
    dataSet.setCircleColorHole(Color.DKGRAY);
    LineData lineData = new LineData(dataSet);
    chart.setData(lineData);

    LimitLine line = new LimitLine(audioTest.getThreshold(), "Threshold");
    line.setLineColor(Color.RED);
    line.setLabelPosition(LimitLine.LimitLabelPosition.LEFT_TOP);
    line.setLineWidth(2f);
    line.setTextColor(Color.DKGRAY);
    line.setTextSize(10f);
    chart.getAxisLeft().addLimitLine(line);

    final Description desc = new Description();
    desc.setText("Wave [digital level -32768 to +32767] vs. Time [ms]");
    desc.setTextSize(12f);
    chart.setDescription(desc);
    chart.getLegend().setEnabled(false);
    chart.invalidate();
    chartLayout.setVisibility(View.VISIBLE);
}
 
开发者ID:google,项目名称:walt,代码行数:34,代码来源:AudioFragment.java


示例12: initPlot

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
 * Create the plot.
 */
private void initPlot() {
    // enable touch gestures
    chart.setTouchEnabled(true);

    // enable scaling and dragging
    chart.setDragEnabled(true);
    chart.setScaleEnabled(true);
    chart.setDrawGridBackground(false);

    // if disabled, scaling can be done on x- and y-axis separately
    chart.setPinchZoom(true);

    // get the legend (only possible after setting data)
    Legend l = chart.getLegend();

    // modify the legend ...
    l.setForm(Legend.LegendForm.LINE);
    l.setTextColor(Color.GRAY);
    l.setWordWrapEnabled(true);

    Description description = chart.getDescription();
    description.setEnabled(false);

    XAxis xl = chart.getXAxis();
    xl.setTextColor(Color.GRAY);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(true);
    xl.setEnabled(true);

    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setTextColor(Color.GRAY);
    leftAxis.setDrawGridLines(true);

    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setEnabled(false);
}
 
开发者ID:KalebKE,项目名称:AccelerationExplorer,代码行数:40,代码来源:DynamicChart.java


示例13: setUI

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
public void setUI() {
        final Description des = new Description();
        des.setText(".");
        lineChart.setDescription(des);
        lineChart.setDrawGridBackground(false);
        lineChart.setExtraBottomOffset(-50);

        XAxis x = lineChart.getXAxis();
        x.setPosition(XAxis.XAxisPosition.TOP);
        x.setDrawGridLines(false);
        x.setDrawAxisLine(false);
        x.setDrawLabels(true);
        x.setYOffset(25);


        x.setLabelRotationAngle(270);
        x.setTextSize(12);
        x.setTextColor(Color.WHITE);
        x.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
//                Date dt = new Date((long) value);
//                Log.d(Const.TAG2, "sVF Next is "+dt.toString());
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
//                String newValue = simpleDateFormat.format(dt);
//                return Const.NO_BREAK + newValue;

                if(uHi==(int)value){
                    return "";
                }else {
                    uHi= (int) value;
                }

                Date d= new Date(dt[(int) value]);
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
                String newValue = simpleDateFormat.format(d);
                return Const.NO_BREAK + newValue;
            }
        });


        YAxis yLeft = lineChart.getAxis(YAxis.AxisDependency.LEFT);
        yLeft.setDrawGridLines(false);
        yLeft.setDrawAxisLine(false);
        yLeft.setDrawLabels(false);

        YAxis yRight = lineChart.getAxis(YAxis.AxisDependency.RIGHT);
        yRight.setDrawGridLines(false);
        yRight.setDrawAxisLine(false);
        yRight.setDrawLabels(false);

        lineChart.setDoubleTapToZoomEnabled(false);

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


示例14: onCreate

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quiz_mode_stats_page);

    Intent intent = getIntent();

    stats = intent.getParcelableExtra("STATS");
    category = intent.getStringExtra("CATEGORY");

    categoryLabel = (TextView) findViewById(R.id.categoryLabel);
    if (category.equals("Random")) {
        categoryLabel.setText("Category: All");
    } else {
        categoryLabel.setText("Category: " + category);
    }

    menuButton = (Button) findViewById(R.id.menuButton);

    noResultsLabel = (TextView) findViewById(R.id.noResultsLabel);

    pieChart = (PieChart) findViewById(R.id.pieChart);
    if (stats.getNumberCorrect() == 0 && stats.getNumberIncorrect() == 0 && stats.getNumberNotAnswered() == 0) {
        System.out.println("Test");
        noResultsLabel.setVisibility(View.VISIBLE);
    } else {
        Description desc = new Description();
        desc.setText("");
        pieChart.setDescription(desc);
        pieChart.setHoleColor(Color.TRANSPARENT);
        pieChart.setTransparentCircleRadius(0);
        pieChart.getLegend().setEnabled(false);

        List<PieEntry> entries = new ArrayList<PieEntry>();
        List<Integer> colors = new ArrayList<Integer>();

        if (stats.getNumberCorrect() > 0) {
            entries.add(new PieEntry(stats.getNumberCorrect(), "Correct"));
            colors.add(getResources().getColor(R.color.quizStatsCorrect));
        }
        if (stats.getNumberIncorrect() > 0) {
            entries.add(new PieEntry(stats.getNumberIncorrect(), "Incorrect"));
            colors.add(getResources().getColor(R.color.quizStatsIncorrect));
        }
        if (stats.getNumberNotAnswered() > 0) {
            entries.add(new PieEntry(stats.getNumberNotAnswered(), "Not Answered"));
            colors.add(getResources().getColor(R.color.quizStatsNotAnswered));
        }
        PieDataSet dataSet = new PieDataSet(entries, "");
        dataSet.setColors(colors);
        PieData pieData = new PieData(dataSet);
        pieData.setValueTextColor(Color.WHITE);
        pieData.setValueTextSize(16.0f);
        pieData.setValueFormatter(new QuizStatsFormatter());
        pieChart.setData(pieData);
        pieChart.setVisibility(View.VISIBLE);
        pieChart.invalidate();
    }
}
 
开发者ID:jakepolatty,项目名称:HighSchoolScienceBowlPractice-Android,代码行数:60,代码来源:QuizModeStatsPage.java


示例15: prepareGraphLayout

import com.github.mikephil.charting.components.Description; //导入依赖的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


示例16: updateGraph

import com.github.mikephil.charting.components.Description; //导入依赖的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


示例17: showFeedback

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
@Override
public void showFeedback(Feedback feedbackToShow) {

    final List<PieEntry> entries = new ArrayList<>();
    final List<Integer> colors = new ArrayList<>();
    if (feedbackToShow.getStar4() > 0) {
        entries.add(new PieEntry(feedbackToShow.getStar4(), "Super happy"));
        colors.add(ContextCompat.getColor(this, R.color.super_happy));
    }
    if (feedbackToShow.getStar3() > 0) {
        entries.add(new PieEntry(feedbackToShow.getStar3(), "Happy"));
        colors.add(ContextCompat.getColor(this, R.color.happy));
    }
    if (feedbackToShow.getStar2() > 0) {
        entries.add(new PieEntry(feedbackToShow.getStar2(), "Meh"));
        colors.add(ContextCompat.getColor(this, R.color.meh));
    }
    if (feedbackToShow.getStar1() > 0) {
        entries.add(new PieEntry(feedbackToShow.getStar1(), "Sad"));
        colors.add(ContextCompat.getColor(this, R.color.sad));
    }
    final PieDataSet pieDataSet = new PieDataSet(entries, null);
    pieDataSet.setValueTextSize(20f);
    pieDataSet.setColors(colors);
    final PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter(new PercentFormatter());
    pieData.setValueTextSize(16f);
    pieChart.setData(pieData);
    final Description description = new Description();
    description.setTextSize(16f);
    description.setText("Total votes: " + feedbackToShow.getTotal());
    pieChart.setDescription(description);
    pieChart.setCenterText(feedbackToShow.getQuestion().getText());
    pieChart.setCenterTextSize(20f);
    pieChart.setCenterTextRadiusPercent(90f);
    pieChart.setUsePercentValues(true);
    pieChart.setEntryLabelTextSize(16f);

    //Init entries:
    final Legend l = pieChart.getLegend();
    l.setEntries(Collections.emptyList());
    pieChart.invalidate();
}
 
开发者ID:ZelsinkiHackWeek,项目名称:howislife,代码行数:44,代码来源:StatisticsActivity.java


示例18: updateStockGraph

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
private void updateStockGraph(String historyBuilder) {
    List<Entry> entries = new ArrayList<>();
    String[] lines = historyBuilder.split("\\n");

    int linesLength = lines.length;
    final String[] dates = new String[linesLength];

    // Create a DateFormatter object for displaying date in specified format.
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy", Locale.US);

    // Create a calendar object that will convert the date and time value in milliseconds to date.
    Calendar calendar = Calendar.getInstance();

    for (int i = 0; i < linesLength; i++){
        // show the chart in the right order
        String[] dateAndPrice = lines[linesLength - i - 1].split(",");
        calendar.setTimeInMillis(Long.valueOf(dateAndPrice[0]));
        dates[i] = formatter.format(calendar.getTime());
        entries.add(new Entry(i, Float.valueOf(dateAndPrice[1])));
    }

    LineDataSet dataSet = new LineDataSet(entries, getString(R.string.chart_label));
    XAxis xAxis = lineChartView.getXAxis();

    // Set Colors
    dataSet.setValueTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
    LineData lineData = new LineData(dataSet);
    xAxis.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
    lineChartView.getAxisLeft().setTextColor(
            ContextCompat.getColor(getApplicationContext(), R.color.white));
    lineChartView.getAxisRight().setTextColor(
            ContextCompat.getColor(getApplicationContext(), R.color.white));
    lineChartView.getLegend().setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));

    // Set date labels for x-axis
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            // "value" represents the position of the label on the axis (x or y)
            return dates[(int) value];
        }

        /** this is only needed if numbers are returned, else return 0 */
        @Override
        public int getDecimalDigits() {
            return 0;
        }

    });

    Description description = new Description();
    description.setText(getString(R.string.chart_description));
    description.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
    lineChartView.setDescription(description);
    lineChartView.setData(lineData);

    /**
     * animate the chart only once when detail view first opened
     * animating it after each refresh kinda annoying for the user
     */
    if (!chartAnimated) {
        lineChartView.animateX(2000);
        chartAnimated = true;
    }
}
 
开发者ID:jkozh,项目名称:stockhawk,代码行数:67,代码来源:StockDetailActivity.java


示例19: HistogramChart

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
public HistogramChart(Context context, AttributeSet attrs) {
    super(context, attrs);
    inflate(getContext(), R.layout.histogram, this);

    barChart = (BarChart) findViewById(R.id.bar_chart);
    findViewById(R.id.button_close_bar_chart).setOnClickListener(this);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HistogramChart);
    final String descString;
    final int numDataSets;
    final float binWidth;
    try {
        descString = a.getString(R.styleable.HistogramChart_description);
        numDataSets = a.getInteger(R.styleable.HistogramChart_numDataSets, 1);
        binWidth = a.getFloat(R.styleable.HistogramChart_binWidth, 5f);
    } finally {
        a.recycle();
    }

    ArrayList<IBarDataSet> dataSets = new ArrayList<>(numDataSets);
    for (int i = 0; i < numDataSets; i++) {
        final BarDataSet dataSet = new BarDataSet(new ArrayList<BarEntry>(), "");
        dataSet.setColor(ColorTemplate.MATERIAL_COLORS[i]);
        dataSets.add(dataSet);
    }

    BarData barData = new BarData(dataSets);
    barData.setBarWidth((1f - GROUP_SPACE)/numDataSets);
    barChart.setData(barData);
    histogramData = new HistogramData(numDataSets, binWidth);
    groupBars(barData);
    final Description desc = new Description();
    desc.setText(descString);
    desc.setTextSize(12f);
    barChart.setDescription(desc);

    XAxis xAxis = barChart.getXAxis();
    xAxis.setGranularityEnabled(true);
    xAxis.setGranularity(1);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setValueFormatter(new IAxisValueFormatter() {
        DecimalFormat df = new DecimalFormat("#.##");

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return df.format(histogramData.getDisplayValue(value));
        }
    });

    barChart.setFitBars(true);
    barChart.invalidate();
}
 
开发者ID:google,项目名称:walt,代码行数:53,代码来源:HistogramChart.java


示例20: setDescription

import com.github.mikephil.charting.components.Description; //导入依赖的package包/类
/**
 * Sets a new Description object for the chart.
 *
 * @param desc
 */
public void setDescription(Description desc) {
    this.mDescription = desc;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Chart.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyInfo类代码示例发布时间:2022-05-21
下一篇:
Java StrokeBorder类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap