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


Java LegendPosition类代码示例

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


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

示例1: onCreateView

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_pie, container, false);
    
    mChart = (PieChart) v.findViewById(R.id.pieChart1);
    mChart.setDescription("");
    
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
    
    mChart.setCenterTextTypeface(tf);
    mChart.setCenterText(generateCenterText());
    mChart.setCenterTextSize(10f);
    mChart.setCenterTextTypeface(tf);
     
    // radius of the center hole in percent of maximum radius
    mChart.setHoleRadius(45f);
    mChart.setTransparentCircleRadius(50f);
    
    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    
    mChart.setData(generatePieData());
    
    return v;
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:26,代码来源:PieChartFrag.java

示例2: onCreate

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的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("");

	// if more than 60 entries are displayed in the chart, no values will be
	// drawn
	mChart.setMaxVisibleValueCount(60);

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

	mChart.setDrawGridBackground(false);
	mChart.setDrawBarShadow(false);

	mChart.setDrawValueAboveBar(false);

	// change the position of the y-labels
	YAxis leftAxis = mChart.getAxisLeft();
	leftAxis.setValueFormatter(new MyYAxisValueFormatter());
	leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
	mChart.getAxisRight().setEnabled(false);

	XAxis xLabels = mChart.getXAxis();
	xLabels.setPosition(XAxisPosition.TOP);

	// mChart.setDrawXLabels(false);
	// mChart.setDrawYLabels(false);

	// setting data
	mSeekBarX.setProgress(12);
	mSeekBarY.setProgress(100);

	Legend l = mChart.getLegend();
	l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
	l.setFormSize(8f);
	l.setFormToTextSpace(4f);
	l.setXEntrySpace(6f);

	// mChart.setDrawLegend(false);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:57,代码来源:StackedBarActivity.java

示例3: onCreate

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的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);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);

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

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);

    mChart.setDescription("");

    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    mChart.setMaxVisibleValueCount(60);

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

    mChart.setDrawGridBackground(false);
    // mChart.setDrawYLabels(false);

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setSpaceBetweenLabels(2);

    YAxisValueFormatter custom = new MyYAxisValueFormatter();

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(8, false);
    leftAxis.setValueFormatter(custom);
    leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
    leftAxis.setSpaceTop(15f);
    leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setTypeface(mTf);
    rightAxis.setLabelCount(8, false);
    rightAxis.setValueFormatter(custom);
    rightAxis.setSpaceTop(15f);
    rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_LEFT);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);
    // l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
    // "def", "ghj", "ikl", "mno" });
    // l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
    // "def", "ghj", "ikl", "mno" });

    setData(12, 50);

    // setting data
    mSeekBarY.setProgress(50);
    mSeekBarX.setProgress(12);

    mSeekBarY.setOnSeekBarChangeListener(this);
    mSeekBarX.setOnSeekBarChangeListener(this);

    // mChart.setDrawLegend(false);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:80,代码来源:BarChartActivity.java

示例4: onCreate

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的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_sinus);
    
    mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(),"othersine.txt");

    tvX = (TextView) findViewById(R.id.tvValueCount);

    mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);

    mChart = (BarChart) findViewById(R.id.chart1);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);

    mChart.setDescription("");

    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    mChart.setMaxVisibleValueCount(60);

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

    // draw shadows for each bar that show the maximum value
    // mChart.setDrawBarShadow(true);

    // mChart.setDrawXLabels(false);

    mChart.setDrawGridBackground(false);
    // mChart.setDrawYLabels(false);

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setEnabled(false);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(6, false);
    leftAxis.setAxisMinValue(-2.5f);
    leftAxis.setAxisMaxValue(2.5f);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setTypeface(mTf);
    rightAxis.setLabelCount(6, false);
    rightAxis.setAxisMinValue(-2.5f);
    rightAxis.setAxisMaxValue(2.5f);

    mSeekBarX.setOnSeekBarChangeListener(this);
    mSeekBarX.setProgress(150); // set data

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_LEFT);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);

    mChart.animateXY(2000, 2000);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:69,代码来源:BarChartActivitySinus.java

示例5: onCreate

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

    setTitle("Age Distribution Austria");

    mChart = (HorizontalBarChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    mChart.setDescription("");

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

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);
    
    mChart.getAxisLeft().setEnabled(false);
    mChart.getAxisRight().setAxisMaxValue(25f);
    mChart.getAxisRight().setAxisMinValue(-25f);
    mChart.getAxisRight().setDrawGridLines(false);
    mChart.getAxisRight().setDrawZeroLine(true);
    mChart.getAxisRight().setLabelCount(7, false);
    mChart.getAxisRight().setValueFormatter(new CustomFormatter());
    mChart.getAxisRight().setTextSize(9f);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTH_SIDED);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setTextSize(9f);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
    l.setFormSize(8f);
    l.setFormToTextSpace(4f);
    l.setXEntrySpace(6f);

    // IMPORTANT: When using negative values in stacked bars, always make sure the negative values are in the array first
    ArrayList<BarEntry> yValues = new ArrayList<BarEntry>();
    yValues.add(new BarEntry(new float[]{ -10, 10 }, 0));
    yValues.add(new BarEntry(new float[]{ -12, 13 }, 1));
    yValues.add(new BarEntry(new float[]{ -15, 15 }, 2));
    yValues.add(new BarEntry(new float[]{ -17, 17 }, 3));
    yValues.add(new BarEntry(new float[]{ -19, 20 }, 4));
    yValues.add(new BarEntry(new float[]{ -19, 19 }, 5));
    yValues.add(new BarEntry(new float[]{ -16, 16 }, 6));
    yValues.add(new BarEntry(new float[]{ -13, 14 }, 7));
    yValues.add(new BarEntry(new float[]{ -10, 11 }, 8));
    yValues.add(new BarEntry(new float[]{ -5, 6 }, 9));
    yValues.add(new BarEntry(new float[]{ -1, 2 }, 10));

    BarDataSet set = new BarDataSet(yValues, "Age Distribution");
    set.setValueFormatter(new CustomFormatter());
    set.setValueTextSize(7f);
    set.setAxisDependency(YAxis.AxisDependency.RIGHT);
    set.setBarSpacePercent(40f);
    set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
    set.setStackLabels(new String[]{
            "Men", "Women"
    });

    String []xVals = new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100", "100+"};

    BarData data = new BarData(xVals, set);
    mChart.setData(data);
    mChart.invalidate();
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:72,代码来源:StackedBarActivityNegative.java

示例6: onCreate

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

示例7: onCreate

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

    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 = (ScatterChart) findViewById(R.id.chart1);
    mChart.setDescription("");

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

    mChart.setOnChartValueSelectedListener(this);

    mChart.setDrawGridBackground(false);

    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    mChart.setMaxVisibleValueCount(200);
    mChart.setPinchZoom(true);

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

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);

    YAxis yl = mChart.getAxisLeft();
    yl.setTypeface(tf);
    yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
    
    mChart.getAxisRight().setEnabled(false);

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(tf);
    xl.setDrawGridLines(false);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:52,代码来源:ScatterChartActivity.java

示例8: onCreate

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

    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 = (BubbleChart) findViewById(R.id.chart1);
    mChart.setDescription("");

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

    mChart.setOnChartValueSelectedListener(this);

    mChart.setDrawGridBackground(false);

    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    mChart.setMaxVisibleValueCount(200);
    mChart.setPinchZoom(true);

    mSeekBarX.setProgress(5);
    mSeekBarY.setProgress(50);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);

    YAxis yl = mChart.getAxisLeft();
    yl.setTypeface(tf);
    yl.setSpaceTop(30f);
    yl.setSpaceBottom(30f);
    yl.setDrawZeroLine(false);
    
    mChart.getAxisRight().setEnabled(false);

    XAxis xl = mChart.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setTypeface(tf);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:54,代码来源:BubbleChartActivity.java

示例9: onCreate

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

    mChart = (RadarChart) findViewById(R.id.chart1);

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

    mChart.setDescription("");

    mChart.setWebLineWidth(1.5f);
    mChart.setWebLineWidthInner(0.75f);
    mChart.setWebAlpha(100);

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

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

    setData();

    mChart.animateXY(
            1400, 1400,
            Easing.EasingOption.EaseInOutQuad,
            Easing.EasingOption.EaseInOutQuad);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setTypeface(tf);
    xAxis.setTextSize(9f);

    YAxis yAxis = mChart.getYAxis();
    yAxis.setTypeface(tf);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinValue(0f);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:48,代码来源:RadarChartActivitry.java

示例10: getView

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, Context c) {

    ViewHolder holder = null;

    if (convertView == null) {

        holder = new ViewHolder();

        convertView = LayoutInflater.from(c).inflate(
                R.layout.list_item_piechart, null);
        holder.chart = (PieChart) convertView.findViewById(R.id.chart);

        convertView.setTag(holder);

    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    // apply styling
    holder.chart.setDescription("");
    holder.chart.setHoleRadius(52f);
    holder.chart.setTransparentCircleRadius(57f);
    holder.chart.setCenterText(mCenterText);
    holder.chart.setCenterTextTypeface(mTf);
    holder.chart.setCenterTextSize(9f);
    holder.chart.setUsePercentValues(true);
    holder.chart.setExtraOffsets(5, 10, 50, 10);

    mChartData.setValueFormatter(new PercentFormatter());
    mChartData.setValueTypeface(mTf);
    mChartData.setValueTextSize(11f);
    mChartData.setValueTextColor(Color.WHITE);
    // set data
    holder.chart.setData((PieData) mChartData);

    Legend l = holder.chart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setYEntrySpace(0f);
    l.setYOffset(0f);

    // do not forget to refresh the chart
    // holder.chart.invalidate();
    holder.chart.animateY(900);

    return convertView;
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:48,代码来源:PieChartItem.java

示例11: onCreate

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

    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 = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    
    mChart.setDrawGridBackground(false);
    mChart.setDescription("");
    mChart.setDrawBorders(false);

    mChart.getAxisLeft().setDrawAxisLine(false);
    mChart.getAxisLeft().setDrawGridLines(false);
    mChart.getAxisRight().setDrawAxisLine(false);
    mChart.getAxisRight().setDrawGridLines(false);
    mChart.getXAxis().setDrawAxisLine(false);
    mChart.getXAxis().setDrawGridLines(false);

    // enable touch gestures
    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

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

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

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:47,代码来源:MultiLineChartActivity.java

示例12: onCreate

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

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

        mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
        mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);

        mChart = (HorizontalBarChart) findViewById(R.id.chart1);
        mChart.setOnChartValueSelectedListener(this);
        // mChart.setHighlightEnabled(false);

        mChart.setDrawBarShadow(false);

        mChart.setDrawValueAboveBar(true);

        mChart.setDescription("");

        // if more than 60 entries are displayed in the chart, no values will be
        // drawn
        mChart.setMaxVisibleValueCount(60);

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

        // draw shadows for each bar that show the maximum value
        // mChart.setDrawBarShadow(true);

        // mChart.setDrawXLabels(false);

        mChart.setDrawGridBackground(false);

        // mChart.setDrawYLabels(false);

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

        XAxis xl = mChart.getXAxis();
        xl.setPosition(XAxisPosition.BOTTOM);
        xl.setTypeface(tf);
        xl.setDrawAxisLine(true);
        xl.setDrawGridLines(true);
        xl.setGridLineWidth(0.3f);

        YAxis yl = mChart.getAxisLeft();
        yl.setTypeface(tf);
        yl.setDrawAxisLine(true);
        yl.setDrawGridLines(true);
        yl.setGridLineWidth(0.3f);
        yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
//        yl.setInverted(true);

        YAxis yr = mChart.getAxisRight();
        yr.setTypeface(tf);
        yr.setDrawAxisLine(true);
        yr.setDrawGridLines(false);
        yr.setAxisMinValue(0f); // this replaces setStartAtZero(true)
//        yr.setInverted(true);

        setData(12, 50);
        mChart.animateY(2500);

        // setting data
        mSeekBarY.setProgress(50);
        mSeekBarX.setProgress(12);

        mSeekBarY.setOnSeekBarChangeListener(this);
        mSeekBarX.setOnSeekBarChangeListener(this);

        Legend l = mChart.getLegend();
        l.setPosition(LegendPosition.BELOW_CHART_LEFT);
        l.setFormSize(8f);
        l.setXEntrySpace(4f);

        // mChart.setDrawLegend(false);
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:81,代码来源:HorizontalBarChartActivity.java

示例13: onCreate

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

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

    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);

    mSeekBarY.setProgress(10);

    mSeekBarX.setOnSeekBarChangeListener(this);
    mSeekBarY.setOnSeekBarChangeListener(this);

    mChart = (PieChart) findViewById(R.id.chart1);
    mChart.setUsePercentValues(true);
    mChart.setDescription("");
    mChart.setExtraOffsets(5, 10, 5, 5);

    mChart.setDragDecelerationFrictionCoef(0.95f);

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

    mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
    mChart.setCenterText(generateCenterSpannableText());

    mChart.setDrawHoleEnabled(true);
    mChart.setHoleColor(Color.WHITE);

    mChart.setTransparentCircleColor(Color.WHITE);
    mChart.setTransparentCircleAlpha(110);

    mChart.setHoleRadius(58f);
    mChart.setTransparentCircleRadius(61f);

    mChart.setDrawCenterText(true);

    mChart.setRotationAngle(0);
    // enable rotation of the chart by touch
    mChart.setRotationEnabled(true);
    mChart.setHighlightPerTapEnabled(true);

    // mChart.setUnit(" €");
    // mChart.setDrawUnitsInChart(true);

    // add a selection listener
    mChart.setOnChartValueSelectedListener(this);

    setData(3, 100);

    mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
    // mChart.spin(2000, 0, 360);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(0f);
    l.setYOffset(0f);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:64,代码来源:PieChartActivity.java

示例14: setLegend

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的package包/类
/**
 * More details about legend customization: https://github.com/PhilJay/MPAndroidChart/wiki/Legend
 */
@ReactProp(name = "legend")
public void setLegend(T chart, ReadableMap propMap) {
    Legend legend = chart.getLegend();

    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "enabled")) {
        legend.setEnabled(propMap.getBoolean("enabled"));
    }

    // Styling
    if (BridgeUtils.validate(propMap, ReadableType.String, "textColor")) {
        legend.setTextColor(Color.parseColor(propMap.getString("textColor")));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "textSize")) {
        legend.setTextSize((float) propMap.getDouble("textSize"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "fontFamily") ||
            BridgeUtils.validate(propMap, ReadableType.Number, "fontStyle")) {
        legend.setTypeface(BridgeUtils.parseTypeface(chart.getContext(), propMap, "fontStyle", "fontFamily"));
    }

    // Wrapping / clipping avoidance
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "wordWrapEnabled")) {
        legend.setWordWrapEnabled(propMap.getBoolean("wordWrapEnabled"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "maxSizePercent")) {
        legend.setMaxSizePercent((float) propMap.getDouble("maxSizePercent"));
    }

    // Customizing
    if (BridgeUtils.validate(propMap, ReadableType.String, "position")) {
        legend.setPosition(LegendPosition.valueOf(propMap.getString("position").toUpperCase()));
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "form")) {
        legend.setForm(LegendForm.valueOf(propMap.getString("form").toUpperCase()));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "formSize")) {
        legend.setFormSize((float) propMap.getDouble("formSize"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "xEntrySpace")) {
        legend.setXEntrySpace((float) propMap.getDouble("xEntrySpace"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "yEntrySpace")) {
        legend.setYEntrySpace((float) propMap.getDouble("yEntrySpace"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "formToTextSpace")) {
        legend.setFormToTextSpace((float) propMap.getDouble("formToTextSpace"));
    }

    // Custom labels & colors
    if (BridgeUtils.validate(propMap, ReadableType.Map, "custom")) {
        ReadableMap customMap = propMap.getMap("custom");
        if (BridgeUtils.validate(customMap, ReadableType.Array, "colors") &&
                BridgeUtils.validate(customMap, ReadableType.Array, "labels")) {

            ReadableArray colorsArray = customMap.getArray("colors");
            ReadableArray labelsArray = customMap.getArray("labels");

            if (colorsArray.size() == labelsArray.size()) {
                // TODO null label should start a group
                // TODO -2 color should avoid drawing a form
                String[] labels = BridgeUtils.convertToStringArray(labelsArray);
                String[] colors = BridgeUtils.convertToStringArray(colorsArray);

                int[] colorsParsed = new int[colors.length];
                for (int i = 0; i < colors.length; i++) {
                    colorsParsed[i] = Color.parseColor(colors[i]);
                }

                legend.setCustom(colorsParsed, labels);
            }
        }
    }

    // TODO resetCustom function
    // TODO extra

    chart.invalidate();     // TODO is this necessary? Looks like enabled is not refreshing without it
}
 
开发者ID:mskec,项目名称:react-native-mp-android-chart,代码行数:82,代码来源:ChartBaseManager.java

示例15: getView

import com.github.mikephil.charting.components.Legend.LegendPosition; //导入依赖的package包/类
@Override
    public View getView(int position, View convertView, Context c) {

        ViewHolder holder = null;

        if (convertView == null) {

            holder = new ViewHolder();

            convertView = LayoutInflater.from(c).inflate(
                    R.layout.list_item_piechart, null);
            holder.chart = (PieChart) convertView.findViewById(R.id.chart);

            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        // apply styling
        holder.chart.setDescription("");
        holder.chart.setHoleRadius(52f);
        holder.chart.setTransparentCircleRadius(57f);
//        holder.chart.setCenterText(mCenterText);
        holder.chart.setCenterTextSize(9f);
        holder.chart.setUsePercentValues(true);
        holder.chart.setExtraOffsets(5, 10, 50, 10);

        mChartData.setValueFormatter(new PercentFormatter());
        mChartData.setValueTextSize(11f);
        mChartData.setValueTextColor(Color.WHITE);
        // set data
        holder.chart.setData((PieData) mChartData);

        Legend l = holder.chart.getLegend();
        l.setPosition(LegendPosition.RIGHT_OF_CHART);
        l.setYEntrySpace(0f);
        l.setYOffset(0f);

        // do not forget to refresh the chart
        // holder.chart.invalidate();
        holder.chart.animateXY(900, 900);

        return convertView;
    }
 
开发者ID:thehyve,项目名称:transmart-android,代码行数:46,代码来源:PieChartItem.java


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