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


Java OnChartValueSelectedListener类代码示例

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


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

示例1: addDragListenerMarkerMaker

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
private void addDragListenerMarkerMaker(LineChart speedChart) {
    speedChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry entry, Highlight h) {
            Long entryX = (long) entry.getX();
            if (timeLocationMap.containsKey(entryX)) {
                clearAllMarkersFromMap();
                LatLng latLng = timeLocationMap.get(entryX);
                mapMarkers.add(googleMap.addMarker(new MarkerOptions().position(latLng)));
            }
        }

        @Override
        public void onNothingSelected() {
            clearAllMarkersFromMap();
        }
    });
}
 
开发者ID:ponewheel,项目名称:android-ponewheel,代码行数:19,代码来源:RideDetailActivity.java

示例2: onBindViewHolder

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder ) {
    final VerticalBarChartHolder barHolder = (VerticalBarChartHolder) holder;
    barHolder.title.setText(title);
    ChartHelper.setVerticalBarChart(context, barHolder.chart, getChartData(), typeface);
    barHolder.chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry e, Highlight h) {
            if (e == null){
                return;
            }
            barHolder.chart.setDrawMarkers(true);
        }

        @Override
        public void onNothingSelected() {

        }
    });
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:21,代码来源:VerticalBarChartItem.java

示例3: onBindViewHolder

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder ) {
    final LineChartHolder lineHolder = (LineChartHolder) holder;
    lineHolder.language.setText(title);
    ChartHelper.setLineChart(context, lineHolder.chart, getChartData(), month, typeface);
    lineHolder.chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry e, Highlight h) {
            if (e == null){
                return;
            }
            Timber.d("onValueSelected Selected:%s dataSet:%d", e.toString(), h.getDataSetIndex());
            lineHolder.chart.setDrawMarkers(true);
        }

        @Override
        public void onNothingSelected() {
            Timber.d("Nothing selected.");
        }
    });
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:22,代码来源:LineChartItem.java

示例4: updateChart

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
public void updateChart(){
    ArrayList<Entry> entries = new ArrayList<>();
    ArrayList<String> labels = new ArrayList<>();
    operationChartTitle.setText("Mes dernières interventions");
    chartDataDescription.setText(String.format(getResources().getString(R.string.chartDesciption), interventionListForGrid.get(0).getDescription()));
    chartDataCost.setText(String.format(getResources().getString(R.string.chartCost), (float) interventionListForGrid.get(0).getPrice()));
    chartDataDate.setText(GlobalContext.getFormattedSmallDate(interventionListForGrid.get(0).getDate()));
    for(int i=0; i< interventionListForChart.size(); i++) {
        entries.add(new Entry((float)interventionListForChart.get(i).getPrice(), i));
        labels.add(GlobalContext.getFormattedSmallDate(interventionListForChart.get(i).getDate()));
    }
    LineChartCustom lcc = new LineChartCustom(operationChart, entries, "Mes interventions", labels, null);
    lcc.getChart().setTouchEnabled(true);
    lcc.getChart().setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
            chartDataDescription.setText(String.format(getResources().getString(R.string.chartDesciption), interventionListForChart.get(e.getXIndex()).getDescription()));
            chartDataCost.setText(String.format(getResources().getString(R.string.chartCost), (float) e.getVal()));
            chartDataDate.setText(GlobalContext.getFormattedSmallDate(interventionListForChart.get(e.getXIndex()).getDate()));
        }

        @Override
        public void onNothingSelected() {
        }
    });
}
 
开发者ID:pfiorentino,项目名称:eCarNet,代码行数:27,代码来源:OperationsFragment.java

示例5: onBindViewHolder

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder ) {
    final BarChartHolder barHolder = (BarChartHolder)holder;
    barHolder.language.setText(language);
    ChartHelper.setGroupBarChart(context, barHolder.chart, getChartData(), typeface);
    // specify the width each bar should have
    barHolder.chart.getBarData().setBarWidth(barWidth);
    // restrict the x-axis range
    barHolder.chart.getXAxis().setAxisMinimum(start);
    // barData.getGroupWith(...) is a helper that calculates the width each group needs
    // based on the provided parameters
    barHolder.chart.getXAxis().setAxisMaximum(start + barHolder.chart.getBarData()
            .getGroupWidth(groupSpace, barSpace) * groupCount);
    barHolder.chart.groupBars(start, groupSpace, barSpace);
    barHolder.chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry e, Highlight h) {
            if (e == null){
                return;
            }
            barHolder.chart.setDrawMarkers(true);
        }

        @Override
        public void onNothingSelected() {
            Timber.d("Nothing selected.");
        }
    });
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:30,代码来源:GroupBarChartItem.java

示例6: getFormattedLineChart

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
/**
 * Formats a line chart in a standardized manner
 * @param c App context
 * @param chart LineChart to format
 * @param listener Listener to attach to chart
 * @param xLabels Labels to use for the x-axis
 * @param valueFormatter True if large value formatter should be used
 * @param skip Number of values to skip
 * @param legend True if show legend, false if hide legend
 * @return Formatted linechart
 */
public static LineChart getFormattedLineChart(Context c, LineChart chart, OnChartValueSelectedListener listener, List<String> xLabels, boolean valueFormatter, int skip, boolean legend) {
    Legend cLegend = chart.getLegend();
    cLegend.setEnabled(legend);

    XAxis xAxis = chart.getXAxis();
    xAxis.setGranularity(skip);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setValueFormatter(new XAxisLabelFormatter(xLabels));

    YAxis yAxisRight = chart.getAxisRight();
    yAxisRight.setEnabled(false);

    YAxis yAxisLeft = chart.getAxisLeft();
    if (valueFormatter) {
        yAxisLeft.setValueFormatter(new LargeNumberAxisFormatter(c));
    }

    if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
        int textColorNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
        cLegend.setTextColor(textColorNoir);
        xAxis.setTextColor(textColorNoir);
        yAxisLeft.setTextColor(textColorNoir);
    }

    chart.setDoubleTapToZoomEnabled(false);
    chart.setDescription(EMPTY_CHART_DESCRIPTION);
    chart.setDragEnabled(true);
    chart.setScaleYEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setOnChartValueSelectedListener(listener);

    return chart;
}
 
开发者ID:lloydtorres,项目名称:stately,代码行数:45,代码来源:RaraHelper.java

示例7: refreshFillUpCard

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
private void refreshFillUpCard() {
    final ArrayList<Intervention> lastFillUps = Intervention.findFillUpsByCar(currentCar.getId(), 10);

    if (lastFillUps.size() > 0) {
        ArrayList<Entry> chartData = getInterventionsAmounts(lastFillUps);
        ArrayList<String> chartLabels = getInterventionsChartLabels(lastFillUps, 0);

        fillUpChartDataKilometers.setText(String.format(getResources().getString(R.string.chartKilomters), lastFillUps.get(0).getKilometers()));
        fillUpChartDataCost.setText(String.format(getResources().getString(R.string.chartCost), (float) lastFillUps.get(0).getPrice()));
        fillUpChartDataDate.setText(GlobalContext.getFormattedSmallDate(lastFillUps.get(0).getDate()));

        LineChartCustom lcc = new LineChartCustom(this.fillUpChart, chartData, "", chartLabels, null);
        lcc.getChart().setTouchEnabled(true);
        lcc.getChart().setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
            @Override
            public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
                fillUpChartDataKilometers.setText(String.format(getResources().getString(R.string.chartKilomters), lastFillUps.get(e.getXIndex()).getKilometers()));
                fillUpChartDataCost.setText(String.format(getResources().getString(R.string.chartCost), (float) e.getVal()));
                fillUpChartDataDate.setText(GlobalContext.getFormattedSmallDate(lastFillUps.get(e.getXIndex()).getDate()));
            }

            @Override
            public void onNothingSelected() {
            }
        });

        Intervention lastFillUp = lastFillUps.get(lastFillUps.size() - 1);
        animateTextView(0, lastFillUp.getQuantity(), this.lastFillUpQtyTextView);
        animateTextView(0, lastFillUp.getPrice(), this.lastFillUpAmountTextView);

        this.fillUpCard.setVisibility(View.VISIBLE);
        this.noFillUpCard.setVisibility(View.GONE);
    } else {
        this.fillUpCard.setVisibility(View.GONE);
        this.noFillUpCard.setVisibility(View.VISIBLE);
    }

}
 
开发者ID:pfiorentino,项目名称:eCarNet,代码行数:39,代码来源:HomeFragment.java

示例8: onCreate

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

    pieChart = (PieChart) findViewById(R.id.idPieChart);
    pieChart.setRotationEnabled(true);
    pieChart.setHoleRadius(25f);
    pieChart.setTransparentCircleAlpha(0);
    pieChart.setCenterText("Төлөвлөгөө");
    pieChart.setCenterTextSize(10);
    pieChart.setDrawEntryLabels(true);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    addDataSet();

    pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry e, Highlight h) {
            Log.d(TAG, "onValueSelected: Value select from chart.");
            Log.d(TAG, "onValueSelected: " + e.toString());
            Log.d(TAG, "onValueSelected: " + h.toString());

            int pos1 = e.toString().indexOf("(sum): ");
            String sales = e.toString().substring(pos1 + 7);

            for(int i = 0; i < yData.length; i++){
                if(yData[i] == Float.parseFloat(sales)){
                    pos1 = i;
                    break;
                }
            }
            String employee = xData[pos1 + 1];
            Toast.makeText(GraphicActivity.this, "Employee " + employee + "\n" + "Sales: $" + sales + "K", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onNothingSelected() {

        }
    });

 }
 
开发者ID:tortuvshin,项目名称:yield,代码行数:46,代码来源:GraphicActivity.java

示例9: onBindViewHolder

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof ReportViewHolder) {
        ReportViewHolder reportHolder = (ReportViewHolder) holder;

        Report currentReport = categorizedExpenses.getReport(position - 1);
        Category currentCategory = categorizedExpenses.getCategory(position - 1);


        reportHolder.amountText.setText(NumberUtils.formatAmount(currentReport.getTotalAmount()));
        reportHolder.titleText.setText(currentCategory.getTitle());
        IconUtils.loadCategoryIcon(currentCategory.getIcon(), reportHolder.icon);
        reportHolder.progressLayout.setMaxProgress((int) (maxProgress * 10));
        reportHolder.progressLayout.setCurrentProgress(currentReport.getTotalAmount().multiply(new BigDecimal(10)).intValue());
        reportHolder.icon.setIconColor(currentCategory.getColor());
        reportHolder.reportContainer.setOnClickListener(v -> {
            if (onItemClickListener != null) {
                onItemClickListener.onItemClicked(currentCategory, currentReport);
            }
        });
        //reportHolder.progressLayout.setLoadedColor(currentReport.getColor());
    } else if (holder instanceof ChartViewHolder) {
        ChartViewHolder charViewHolder = (ChartViewHolder) holder;
        Context context = charViewHolder.chart.getContext();

        updateChartData(charViewHolder.chart);

        charViewHolder.prev.setImageDrawable(IconUtils.getToolbarIcon(context, MaterialDesignIconic.Icon.gmi_arrow_left));
        charViewHolder.next.setImageDrawable(IconUtils.getToolbarIcon(context, MaterialDesignIconic.Icon.gmi_arrow_right));

        if (charViewHolder.chart.isDrawEntryLabelsEnabled()) {
            charViewHolder.hideLabels.setImageDrawable(IconUtils.getToolbarIcon(context, MaterialDesignIconic.Icon.gmi_format_size));
        } else {
            charViewHolder.hideLabels.setImageDrawable(IconUtils.getToolbarIcon(context, MaterialDesignIconic.Icon.gmi_format_clear));
        }

        charViewHolder.hideLabels.setOnClickListener(view -> {
            charViewHolder.chart.setDrawEntryLabels(!charViewHolder.chart.isDrawEntryLabelsEnabled());
            if (charViewHolder.chart.isDrawEntryLabelsEnabled()) {
                charViewHolder.hideLabels.setImageDrawable(IconUtils.getToolbarIcon(context, MaterialDesignIconic.Icon.gmi_format_size));
            } else {
                charViewHolder.hideLabels.setImageDrawable(IconUtils.getToolbarIcon(context, MaterialDesignIconic.Icon.gmi_format_clear));
            }

            charViewHolder.chart.invalidate();
        });

        //charViewHolder.chart.animateY(1000, Easing.EasingOption.EaseInOutQuad);
        charViewHolder.chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
            @Override
            public void onValueSelected(Entry e, Highlight h) {
                if (onItemClickListener != null) {
                    //onItemClickListener.onItemClicked(reports.get(h.getXIndex()));
                }
            }

            @Override
            public void onNothingSelected() {
            }
        });
    }
}
 
开发者ID:bmelnychuk,项目名称:outlay,代码行数:63,代码来源:ReportAdapter.java

示例10: initializeChart

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
void initializeChart() {
    Resources r = getResources();
    int CgpaColor;
    if (Cgpa > 8.0f)
        CgpaColor = r.getColor(R.color.highAttend);
    else if (Cgpa > 6.0f && Cgpa < 8.0f)
        CgpaColor = r.getColor(R.color.midAttend);
    else
        CgpaColor = r.getColor(R.color.lowAttend);
    ArrayList<Entry> data = new ArrayList<>();
    ArrayList<Entry> CGPAentryList = new ArrayList<>();
    float maxGpa = 0.0f, minGpa = 10.0f;
    ArrayList<String> xVals = new ArrayList<>();
    for (int i = 0; i < semesterWiseGrades.size(); i++) {
        float gpa = (float) semesterWiseGrades.get(i).getGpa();
        xVals.add(getString(R.string.label_semester_no, i + 1));
        data.add(new Entry(gpa, i));
        if (gpa > maxGpa)
            maxGpa = gpa;
        if (gpa < minGpa)
            minGpa = gpa;
    }
    CGPAentryList.add(new Entry(Cgpa, 0));
    CGPAentryList.add(new Entry(Cgpa, data.size() - 1));
    LineDataSet dset = new LineDataSet(data, getString(R.string.label_grade_gpa));
    LineDataSet CGPAdset = new LineDataSet(CGPAentryList, "CGPA " + String.valueOf(Cgpa));
    CGPAdset.setDrawCircleHole(false);
    CGPAdset.setHighlightEnabled(false);
    CGPAdset.setDrawFilled(true);
    CGPAdset.setFillAlpha(80);
    CGPAdset.enableDashedLine(1.0f, 0.5f, 0.5f);
    CGPAdset.setDrawCircles(false);
    CGPAdset.setDrawValues(false);
    dset.setLineWidth(2.0f);
    CGPAdset.setLineWidth(1.0f);
    dset.setValueTextSize(10.0f);
    CGPAdset.setValueTextSize(10.0f);
    dset.setColor(r.getColor(R.color.colorPrimary));
    CGPAdset.setColor(CgpaColor);
    CGPAdset.setFillColor(CgpaColor);
    dset.setHighLightColor(r.getColor(R.color.colorPrimary));
    dset.setCircleColor(r.getColor(R.color.colorAccent));
    dset.setDrawCircleHole(false);
    LineData chartData = new LineData(xVals, Arrays.asList(dset, CGPAdset));
    YAxis leftaxis = chart.getAxisLeft();
    leftaxis.setStartAtZero(false);
    leftaxis.setAxisMinValue(minGpa - 0.1f);
    leftaxis.setAxisMaxValue(maxGpa + 0.1f);
    chart.setDescription("");
    YAxis rightAxis = chart.getAxisRight();
    leftaxis.setEnabled(false);
    rightAxis.setEnabled(false);
    chart.getXAxis().setEnabled(false);
    chart.setData(chartData);
    chart.setPinchZoom(false);
    chart.setDoubleTapToZoomEnabled(false);
    chart.highlightValue(0, 0);
    chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        @Override
        public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
            pager.setCurrentItem(e.getXIndex());
        }

        @Override
        public void onNothingSelected() {
            pager.setCurrentItem(0);
        }
    });
}
 
开发者ID:saurabhsjoshi,项目名称:VITacademics-for-Android,代码行数:70,代码来源:GradesFragment.java

示例11: setOnChartValueSelectedListener

import com.github.mikephil.charting.listener.OnChartValueSelectedListener; //导入依赖的package包/类
/**
 * set a selection listener for the chart
 *
 * @param l
 */
public void setOnChartValueSelectedListener(OnChartValueSelectedListener l) {
    this.mSelectionListener = l;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Chart.java


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