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


Java BarChart.setMarkerView方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.charts.BarChart.setMarkerView方法的典型用法代码示例。如果您正苦于以下问题:Java BarChart.setMarkerView方法的具体用法?Java BarChart.setMarkerView怎么用?Java BarChart.setMarkerView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.charts.BarChart的用法示例。


在下文中一共展示了BarChart.setMarkerView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
    
    // create a new chart object
    mChart = new BarChart(getActivity());
    mChart.setDescription("");
    mChart.setOnChartGestureListener(this);
    
    MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);

    mChart.setMarkerView(mv);

    mChart.setDrawGridBackground(false);
    mChart.setDrawBarShadow(false);
    
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
    
    mChart.setData(generateBarData(1, 20000, 12));
    
    Legend l = mChart.getLegend();
    l.setTypeface(tf);
    
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(tf);
    leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

    mChart.getAxisRight().setEnabled(false);
    
    XAxis xAxis = mChart.getXAxis();
    xAxis.setEnabled(false);
    
    // programatically add the chart
    FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout);
    parent.addView(mChart);
    
    return v;
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:39,代码来源:BarChartFrag.java

示例2: onCreate

import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_barchart);

        tvX = (TextView) findViewById(R.id.tvXMax);
        tvY = (TextView) findViewById(R.id.tvYMax);

        mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
        mSeekBarX.setOnSeekBarChangeListener(this);

        mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
        mSeekBarY.setOnSeekBarChangeListener(this);

        mChart = (BarChart) findViewById(R.id.chart1);
        mChart.setOnChartValueSelectedListener(this);
        mChart.setDescription("");

//        mChart.setDrawBorders(true);
        
        // scaling can now only be done on x- and y-axis separately
        mChart.setPinchZoom(false);

        mChart.setDrawBarShadow(false);

        mChart.setDrawGridBackground(false);

        // create a custom MarkerView (extend MarkerView) and specify the layout
        // to use for it
        MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);

        // define an offset to change the original position of the marker
        // (optional)
        // mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());

        // set the marker to the chart
        mChart.setMarkerView(mv);

        mSeekBarX.setProgress(10);
        mSeekBarY.setProgress(100);

        tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

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

        XAxis xl = mChart.getXAxis();
        xl.setTypeface(tf);

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setTypeface(tf);
        leftAxis.setValueFormatter(new LargeValueFormatter());
        leftAxis.setDrawGridLines(false);
        leftAxis.setSpaceTop(30f);
        leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

        mChart.getAxisRight().setEnabled(false);
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:65,代码来源:BarChartActivityMultiDataset.java

示例3: onCreateView

import com.github.mikephil.charting.charts.BarChart; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.charts_fragment, container, false);

    TextView month = (TextView) v.findViewById(R.id.current_month);
    long ts = getArguments().getLong(DB.TIMESTAMP);
    month.setText(SDF_MONTH.format(new Date(ts * 1000)));

    // отображение статистики за текущий месяц
    BarChart barChart = (BarChart) v.findViewById(R.id.bar_chart);
    barChart.setDescription("");

    Paint mInfoPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mInfoPaint.setColor(getResources().getColor(R.color.primary));
    mInfoPaint.setTextAlign(Paint.Align.CENTER);
    mInfoPaint.setTextSize(com.github.mikephil.charting.utils.Utils.convertDpToPixel(16f));
    barChart.setPaint(mInfoPaint, Chart.PAINT_INFO);
    barChart.setNoDataText(getString(R.string.charts_no_data));

    barChart.setDrawBarShadow(false);
    barChart.setDrawGridBackground(false);
    barChart.setDrawValueAboveBar(false);

    barChart.setPinchZoom(false);
    barChart.setScaleEnabled(false);
    barChart.setDoubleTapToZoomEnabled(false);

    barChart.getXAxis().disableGridDashedLine();
    barChart.getXAxis().setDrawGridLines(false);
    barChart.getXAxis().setEnabled(false);

    barChart.getAxisLeft().setDrawGridLines(false);
    barChart.getAxisLeft().setEnabled(false);

    barChart.getAxisRight().setDrawGridLines(false);
    barChart.getAxisRight().removeAllLimitLines();
    barChart.getAxisRight().setValueFormatter(new FinanceFormatter());

    barChart.getLegend().setEnabled(false);
    barChart.setData(generateMonthlyData());
    // если данных нет, не показывать ось
    barChart.getAxisRight().setEnabled(!barChart.isEmpty());

    MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
    mv.setX(mv.getMeasuredWidth());
    barChart.setMarkerView(mv);


    Utils.log("getYMin = " + barChart.getBarData().getYMin());
    Utils.log("getYMax = " + barChart.getBarData().getYMax());

    barChart.animateY(ANIMATION_TIME);
    return v;
}
 
开发者ID:Sash0k,项目名称:Thrift-box,代码行数:55,代码来源:ChartsFragment.java


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