當前位置: 首頁>>代碼示例>>Java>>正文


Java BarChart.setTouchEnabled方法代碼示例

本文整理匯總了Java中com.github.mikephil.charting.charts.BarChart.setTouchEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java BarChart.setTouchEnabled方法的具體用法?Java BarChart.setTouchEnabled怎麽用?Java BarChart.setTouchEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.mikephil.charting.charts.BarChart的用法示例。


在下文中一共展示了BarChart.setTouchEnabled方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupTemperatureChart

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
protected void setupTemperatureChart(){
    EnvStatistic temperature = mHDD.getSessionData().getCurrentStats().getTemperature();
    if(temperature!=null && temperature.isValid()){
        mTempChart = new BarChart(this);
        List<BarEntry> statVals = new ArrayList<>(3);

        statVals.add(new BarEntry((float) temperature.getMin(), 0));
        statVals.add(new BarEntry((float) temperature.getAvg(), 1));
        statVals.add(new BarEntry((float) temperature.getMax(), 2));

        BarDataSet summary = new BarDataSet(statVals,"Temperature");

        mTempChart.setData(new BarData(new String[]{"Min", "Avg", "Max"}, summary));
        mTempChart.setDescription("");
        mTempChart.animateY(2000);
        mTempChart.getAxisRight().setEnabled(false);
        mTempChart.setTouchEnabled(false);

        mTempChart.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        mTempChart.setMinimumHeight(STATISTIC_CHART_HEIGHT);
        mTempChartContainer.addView(mTempChart);
    }
    else{
        TextView noGraph = new TextView(this);
        noGraph.setText("No Temperature Statistics to Show");
        noGraph.setGravity(View.TEXT_ALIGNMENT_CENTER);
        mTempChartContainer.addView(noGraph);
    }
}
 
開發者ID:foxtrot94,項目名稱:DotHike,代碼行數:32,代碼來源:ResultsActivity.java

示例2: setupPressureChart

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
protected void setupPressureChart(){
    EnvStatistic pressure = mHDD.getSessionData().getCurrentStats().getPressure();
    if(pressure!=null && pressure.isValid()){
        mPressureChart = new BarChart(this);
        List<BarEntry> statVals = new ArrayList<>(3);

        statVals.add(new BarEntry((float) pressure.getMin(),0));
        statVals.add(new BarEntry((float) pressure.getAvg(), 1));
        statVals.add(new BarEntry((float) pressure.getMax(), 2));

        BarDataSet summary = new BarDataSet(statVals,"Pressure");

        mPressureChart.setData(new BarData(new String[]{"Min", "Avg", "Max"}, summary));
        mPressureChart.setDescription("");
        mPressureChart.animateY(2000);
        mPressureChart.getAxisRight().setEnabled(false);
        mPressureChart.setTouchEnabled(false);

        mPressureChart.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        mPressureChart.setMinimumHeight(STATISTIC_CHART_HEIGHT);
        mPressureChartContainer.addView(mPressureChart);
    }
    else{
        TextView noGraph = new TextView(this);
        noGraph.setText("No Pressure Statistics to Show");
        noGraph.setGravity(View.TEXT_ALIGNMENT_CENTER);
        mPressureChartContainer.addView(noGraph);
    }
}
 
開發者ID:foxtrot94,項目名稱:DotHike,代碼行數:32,代碼來源:ResultsActivity.java

示例3: setupHumidityChart

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
protected void setupHumidityChart(){
    EnvStatistic humidity = mHDD.getSessionData().getCurrentStats().getHumidity();
    if(humidity!=null && humidity.isValid()){
        mHumidityChart = new BarChart(this);
        List<BarEntry> statVals = new ArrayList<>(3);

        statVals.add(new BarEntry((float) humidity.getMin(), 0));
        statVals.add(new BarEntry((float) humidity.getAvg(), 1));
        statVals.add(new BarEntry((float) humidity.getMax(), 2));

        BarDataSet summary = new BarDataSet(statVals,"Humidity");

        mHumidityChart.setData(new BarData(new String[]{"Min", "Avg", "Max"}, summary));
        mHumidityChart.setDescription("");
        mHumidityChart.animateY(2000);
        mHumidityChart.getAxisRight().setEnabled(false);
        mHumidityChart.setTouchEnabled(false);

        mHumidityChart.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        mHumidityChart.setMinimumHeight(STATISTIC_CHART_HEIGHT);
        mHumidityChartContainer.addView(mHumidityChart);
    }
    else{
        TextView noGraph = new TextView(this);
        noGraph.setText("No Humidity Statistics to Show");
        noGraph.setGravity(View.TEXT_ALIGNMENT_CENTER);
        mHumidityChartContainer.addView(noGraph);
    }
}
 
開發者ID:foxtrot94,項目名稱:DotHike,代碼行數:32,代碼來源:ResultsActivity.java

示例4: populateUserStatsChart

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
/**
 * Show user stats graph
 */
private void populateUserStatsChart() {
    final String[] userStatsChartXAxisLabel = getActivity().getResources().getStringArray(R.array.user_stats_x_axis_labels);
    final BarChart chart = getActivity().findViewById(R.id.user_stats_chart);
    chart.setTouchEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setGranularity(1);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setValueFormatter(new IAxisValueFormatter() {
        /**
         * Format the value
         * @param value - value to fit to the axis
         * @param axis - the axis to fit to
         * @return Returns the formatted value
         */
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            int v = (int) value;
            return userStatsChartXAxisLabel[v];
        }
    });
    xAxis.setDrawGridLines(false);
    xAxis.setTextSize(11f);
    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setEnabled(false);
    chart.getAxisLeft().setGranularity(1);
    chart.getDescription().setEnabled(false);

    if (mUser != null) {
        int[] colors = getActivity().getResources().getIntArray(R.array.user_stats_chart_colors);
        List<BarEntry> entries = new ArrayList<>();
        entries.add(new BarEntry(0f, mUser.getPlantsAdded()));
        entries.add(new BarEntry(1f, mUser.getPlantsDeleted()));
        entries.add(new BarEntry(2f, mUser.getWaterCount()));
        entries.add(new BarEntry(3f, mUser.getMeasureCount()));
        entries.add(new BarEntry(4f, mUser.getPhotoCount()));

        BarDataSet barDataSet = new BarDataSet(entries, "Plant Operations");
        barDataSet.setColors(ColorTemplate.createColors(colors));
        barDataSet.setValueTextSize(11f);

        BarData data = new BarData(barDataSet);
        data.setBarWidth(0.9f); // set custom bar width
        chart.setData(data);
        chart.invalidate(); // refresh
    }
}
 
開發者ID:iskandergaba,項目名稱:Botanist,代碼行數:50,代碼來源:AccountController.java

示例5: onCreate

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);

    cacheFiles = (TextView)findViewById(R.id.cache_files);
    dataFiles = (TextView)findViewById(R.id.data_files);
    systemFiles = (TextView)findViewById(R.id.system_files);

    cacheTitle = (TextView)findViewById(R.id.cache_title);
    dataTitle = (TextView)findViewById(R.id.data_title);
    systemTitle = (TextView)findViewById(R.id.system_title);

    mParts.add("Cache");
    mParts.add("Data");
    mParts.add("System");

    mPieParts.add("RR");
    mPieParts.add("RW");
    mPieParts.add("SR");
    mPieParts.add("SW");


    graphData = new GraphData();
    btnParse = (Button)findViewById(R.id.bt_parse);
    btnParse.setOnClickListener(this);

    progressDialog = new ProgressDialog(this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setCancelable(false);

    partBartChart = (BarChart)findViewById(R.id.part_bar_chart);
    partBartChart.setDrawGridBackground(false);
    partBartChart.setDescription("");
    // I don't want handle touch event
    partBartChart.setTouchEnabled(false);

    Legend l = partBartChart.getLegend();
    l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE);
    l.setYOffset(0f);
    l.setYEntrySpace(0f);
    l.setTextSize(8f);

    XAxis xl = partBartChart.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis leftAxis = partBartChart.getAxisLeft();
    leftAxis.setDrawGridLines(false);
    leftAxis.setSpaceTop(30f);
    leftAxis.setAxisMinValue(0);
    leftAxis.setValueFormatter(new LargeValueFormatter());
    partBartChart.getAxisRight().setEnabled(false);

    BarData barData = new BarData();
    barData.addXValue(mParts.get(0));
    barData.addXValue(mParts.get(1));
    barData.addXValue(mParts.get(2));
    partBartChart.setData(barData);
    partBartChart.invalidate();

    ioPercentChart = (PieChart)findViewById(R.id.io_percent);
    ioPercentChart.setUsePercentValues(true);
    ioPercentChart.setDescription("");
    ioPercentChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
    ioPercentChart.setRotationAngle(0);
    // enable rotation of the chart by touch
    ioPercentChart.setRotationEnabled(true);
    ioPercentChart.setHighlightPerTapEnabled(true);

    Legend pieL = ioPercentChart.getLegend();
    pieL.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
    pieL.setXEntrySpace(7f);
    pieL.setYEntrySpace(0f);
    pieL.setYOffset(0f);

}
 
開發者ID:cumtsmart,項目名稱:MostTool,代碼行數:77,代碼來源:GraphActivity.java

示例6: initializeViews

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
private void initializeViews() {
    titleTextView = (TextView) findViewById(R.id.view_chart_bar_title);
    titleTextView.setText(titleText);
    titleTextView.setTextColor(titleTextColor);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
    titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));

    expand = (ImageView) findViewById(R.id.view_chart_line_expand);
    if (expandTintColor != 0) {
        Drawable drawable = expand.getDrawable();
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, expandTintColor);
        expand.setImageDrawable(drawable);
    }

    chart = (BarChart) findViewById(R.id.view_chart_bar);
    chart.getLegend().setEnabled(false);
    chart.setDescription("");
    chart.setDrawBorders(false);
    chart.setDrawValueAboveBar(false);
    chart.setDrawGridBackground(false);
    chart.setDrawBarShadow(false);
    chart.setDrawHighlightArrow(false);
    chart.setPinchZoom(false);
    chart.setExtraLeftOffset(0);
    chart.setExtraRightOffset(0);
    chart.setExtraBottomOffset(8);
    chart.setExtraTopOffset(0);
    chart.setTouchEnabled(true);
    chart.setDragEnabled(true);

    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawAxisLine(false);
    xAxis.setYOffset(16);
    xAxis.setDrawGridLines(false);
    xAxis.setLabelsToSkip(0);
    xAxis.setTextSize(chartXAxisTextSize);
    xAxis.setTextColor(chartXAxisTextColor);
    xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL));

    YAxis yAxisLeft = chart.getAxisLeft();
    yAxisLeft.setDrawAxisLine(false);
    yAxisLeft.setDrawGridLines(false);
    yAxisLeft.setDrawZeroLine(false);
    yAxisLeft.setDrawLabels(false);

    YAxis yAxisRight = chart.getAxisRight();
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawZeroLine(false);
    yAxisRight.setDrawLabels(false);
}
 
開發者ID:ResearchStack,項目名稱:ResearchStack,代碼行數:54,代碼來源:BarChartCard.java

示例7: onCreateView

import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if(view == null) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_measurement_spectrum, container, false);
        BarChart sChart = (BarChart) view.findViewById(R.id.spectrumChart);
        sChart.setDrawBarShadow(false);
        sChart.setDescription("");
        sChart.getLegend().setEnabled(false);
        sChart.setTouchEnabled(false);
        sChart.setPinchZoom(false);
        sChart.setDrawGridBackground(false);
        sChart.setMaxVisibleValueCount(0);
        sChart.setHorizontalScrollBarEnabled(false);
        sChart.setVerticalScrollBarEnabled(false);
        sChart.setNoDataTextDescription(getText(R.string.no_data_text_description).toString());
        // XAxis parameters:
        XAxis xls = sChart.getXAxis();
        xls.setPosition(XAxis.XAxisPosition.BOTTOM);
        xls.setDrawAxisLine(true);
        xls.setDrawGridLines(false);
        xls.setDrawLabels(true);
        xls.setTextColor(Color.WHITE);
        xls.setAvoidFirstLastClipping(false);
        // YAxis parameters (left): main axis for dB values representation
        YAxis yls = sChart.getAxisLeft();
        yls.setDrawAxisLine(true);
        yls.setDrawGridLines(true);
        yls.setAxisMaxValue(100.f);
        yls.setAxisMinValue(0f);
        yls.setTextColor(Color.WHITE);
        yls.setGridColor(Color.WHITE);
        yls.setSpaceBottom(0);
        yls.setSpaceTop(0);
        yls.setValueFormatter(new SPLValueFormatter());
        // YAxis parameters (right): no axis, hide all
        YAxis yrs = sChart.getAxisRight();
        yrs.setEnabled(false);
    }
    return view;
}
 
開發者ID:Ifsttar,項目名稱:NoiseCapture,代碼行數:43,代碼來源:MeasurementSpectrumFragment.java


注:本文中的com.github.mikephil.charting.charts.BarChart.setTouchEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。