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


Java LineChart.getLegend方法代码示例

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


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

示例1: onCreate

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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_noseekbar);

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setGridBackgroundColor(mFillColor);
    mChart.setDrawGridBackground(true);

    mChart.setDrawBorders(true);

    // no description text
    mChart.getDescription().setEnabled(false);

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

    Legend l = mChart.getLegend();
    l.setEnabled(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setEnabled(false);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setAxisMaximum(900f);
    leftAxis.setAxisMinimum(-250f);
    leftAxis.setDrawAxisLine(false);
    leftAxis.setDrawZeroLine(false);
    leftAxis.setDrawGridLines(false);

    mChart.getAxisRight().setEnabled(false);

    // add data
    setData(100, 60);

    mChart.invalidate();
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:41,代码来源:FilledLineActivity.java

示例2: setLineChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
/**
 * Set the line chart pattern
 * @param lineChart chart
 * @param chartData pie chart data
 * @param month data
 * @param typeface Typeface font
 */
public static void setLineChart(Context context, LineChart lineChart, ChartData<?> chartData,
                                final String[] month, Typeface typeface) {
    // apply styling
    lineChart.getDescription().setEnabled(false);
    lineChart.setDrawGridBackground(false);
    // create a custom MarkerView (extend MarkerView) and specify the layout to use for it
    SalaryMarker marker = new SalaryMarker(context, R.layout.marker_salary_detail);
    marker.setChartView(lineChart); // For bounds control
    lineChart.setMarker(marker);
    //fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
    lineChart.setDrawMarkers(false);

    XAxis xAxis = lineChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTypeface(typeface);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(true);
    xAxis.setValueFormatter(new LineChartValueFormatter(month));
    xAxis.setLabelCount(month.length / 2, true);//xAxis label count

    YAxis leftAxis = lineChart.getAxisLeft();
    leftAxis.setTypeface(typeface);
    leftAxis.setLabelCount(9, false);
    leftAxis.setAxisMinimum(0f);
    YAxis rightAxis = lineChart.getAxisRight();
    rightAxis.setTypeface(typeface);
    rightAxis.setDrawGridLines(false);
    rightAxis.setAxisMinimum(0f);
    Legend l = lineChart.getLegend();
    l.setWordWrapEnabled(true);
    l.setTypeface(typeface);
    l.setFormSize(14f);
    l.setTextSize(9f);
    lineChart.setData((LineData) chartData);
    lineChart.animateX(DURATION_SHORT);

}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:45,代码来源:ChartHelper.java

示例3: initTemperatureChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void initTemperatureChart(LineChart mChart) {
//        mChart.setOnChartValueSelectedListener(this);
        mChart.setDescription("Skin Temperature");
        mChart.setNoDataTextDescription("You need to provide data for the chart.");
        mChart.setTouchEnabled(true);
        mChart.setDragDecelerationFrictionCoef(0.9f);
        mChart.setDragEnabled(true);
        mChart.setScaleEnabled(true);
        mChart.setDrawGridBackground(false);
        mChart.setHighlightPerDragEnabled(true);
        mChart.setPinchZoom(true);
        mChart.setBackgroundColor(getResources().getColor(R.color.blue_light_pressed));
        mChart.animateX(2500);

        Legend l = mChart.getLegend();
        l.setForm(Legend.LegendForm.LINE);
        l.setTypeface(BandApplication.INSTANCE.getTfLight());
        l.setTextSize(11f);
        l.setTextColor(Color.WHITE);
        l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);

        mChart.getXAxis().setEnabled(false);

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
        leftAxis.setTextColor(Color.RED);
        leftAxis.setDrawGridLines(true);
        leftAxis.setGranularityEnabled(true);

        YAxis rightAxis = mChart.getAxisRight();
        rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
        rightAxis.setTextColor(Color.RED);
        rightAxis.setDrawGridLines(false);
        rightAxis.setDrawZeroLine(false);
        rightAxis.setGranularityEnabled(false);
    }
 
开发者ID:qizhenghao,项目名称:Microsoft_Band,代码行数:37,代码来源:HeartRateFragment.java

示例4: initResistanceChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void initResistanceChart(LineChart mChart) {
    //        mChart.setOnChartValueSelectedListener(this);
    mChart.setDescription("Skin Resistance");
    mChart.setNoDataTextDescription("You need to provide data for the chart.");
    mChart.setTouchEnabled(true);
    mChart.setDragDecelerationFrictionCoef(0.9f);
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setDrawGridBackground(false);
    mChart.setHighlightPerDragEnabled(true);
    mChart.setPinchZoom(true);
    mChart.setBackgroundColor(getResources().getColor(R.color.green_pressed));
    mChart.animateX(2500);

    Legend l = mChart.getLegend();
    l.setForm(Legend.LegendForm.LINE);
    l.setTypeface(BandApplication.INSTANCE.getTfLight());
    l.setTextSize(11f);
    l.setTextColor(Color.WHITE);
    l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);

    mChart.getXAxis().setEnabled(false);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
    leftAxis.setTextColor(Color.RED);
    leftAxis.setDrawGridLines(true);
    leftAxis.setGranularityEnabled(true);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
    rightAxis.setTextColor(Color.RED);
    rightAxis.setDrawGridLines(false);
    rightAxis.setDrawZeroLine(false);
    rightAxis.setGranularityEnabled(false);
}
 
开发者ID:qizhenghao,项目名称:Microsoft_Band,代码行数:37,代码来源:HeartRateFragment.java

示例5: getFormattedLineChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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

示例6: initLine

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void initLine() {
    LineChart lineChart = getLineChart();
    if(lineChart == null) {
        return;
    }
    lineChart.setDescription("");

    lineChart.setDrawGridBackground(false);

    // enable scaling and dragging

    Legend l = lineChart.getLegend();
    l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
    l.setTextColor(Color.WHITE);

    YAxis yl = lineChart.getAxisLeft();
    yl.setTextColor(Color.WHITE);
    yl.setGridColor(Color.WHITE);
    lineChart.getAxisRight().setEnabled(false);

    XAxis xl = lineChart.getXAxis();
    xl.setDrawGridLines(false);
    xl.setTextColor(Color.WHITE);
    xl.setGridColor(Color.WHITE);
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setDrawAxisLine(true);
    xl.setLabelRotationAngle(-90);
    xl.setDrawLabels(true);
    xl.setLabelsToSkip(0);
}
 
开发者ID:Ifsttar,项目名称:NoiseCapture,代码行数:31,代码来源:CalibrationLinearityActivity.java

示例7: initChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
/**
 * 初始化图表
 *
 * @param chart 原始图表
 * @return 初始化后的图表
 */
public static LineChart initChart(LineChart chart) {
    // 不显示数据描述
    chart.getDescription().setEnabled(false);
    // 没有数据的时候,显示“暂无数据”
    chart.setNoDataText("暂无数据");
    // 不显示表格颜色
    chart.setDrawGridBackground(false);
    // 不可以缩放
    chart.setScaleEnabled(false);
    // 不显示y轴右边的值
    chart.getAxisRight().setEnabled(false);
    // 不显示图例
    Legend legend = chart.getLegend();
    legend.setEnabled(false);
    // 向左偏移15dp,抵消y轴向右偏移的30dp
    chart.setExtraLeftOffset(-15);

    XAxis xAxis = chart.getXAxis();
    // 不显示x轴
    xAxis.setDrawAxisLine(false);
    // 设置x轴数据的位置
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setTextSize(12);
    xAxis.setGridColor(Color.parseColor("#30FFFFFF"));
    // 设置x轴数据偏移量
    xAxis.setYOffset(-12);

    YAxis yAxis = chart.getAxisLeft();
    // 不显示y轴
    yAxis.setDrawAxisLine(false);
    // 设置y轴数据的位置
    yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
    // 不从y轴发出横向直线
    yAxis.setDrawGridLines(false);
    yAxis.setTextColor(Color.WHITE);
    yAxis.setTextSize(12);
    // 设置y轴数据偏移量
    yAxis.setXOffset(30);
    yAxis.setYOffset(-3);
    yAxis.setAxisMinimum(0);

    //Matrix matrix = new Matrix();
    // x轴缩放1.5倍
    //matrix.postScale(1.5f, 1f);
    // 在图表动画显示之前进行缩放
    //chart.getViewPortHandler().refresh(matrix, chart, false);
    // x轴执行动画
    //chart.animateX(2000);
    chart.invalidate();
    return chart;
}
 
开发者ID:alidili,项目名称:Demos,代码行数:59,代码来源:ChartUtils.java

示例8: setupChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void setupChart(LineChart chart, LineData data, int color) {

        ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);

        // no description text
        chart.getDescription().setEnabled(false);
        
        // mChart.setDrawHorizontalGrid(false);
        //
        // enable / disable grid background
        chart.setDrawGridBackground(false);
//        chart.getRenderer().getGridPaint().setGridColor(Color.WHITE & 0x70FFFFFF);

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

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

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

        chart.setBackgroundColor(color);
        
        // set custom chart offsets (automatic offset calculation is hereby disabled)
        chart.setViewPortOffsets(10, 0, 10, 0);

        // add data
        chart.setData(data);

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

        chart.getAxisLeft().setEnabled(false);
        chart.getAxisLeft().setSpaceTop(40);
        chart.getAxisLeft().setSpaceBottom(40);
        chart.getAxisRight().setEnabled(false);

        chart.getXAxis().setEnabled(false);

        // animate calls invalidate()...
        chart.animateX(2500);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:46,代码来源:LineChartActivityColored.java

示例9: onCreate

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

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

    // enable description text
    mChart.getDescription().setEnabled(true);

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

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

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

    // set an alternative background color
    mChart.setBackgroundColor(Color.LTGRAY);

    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mChart.setData(data);

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

    // modify the legend ...
    l.setForm(LegendForm.LINE);
    l.setTypeface(mTfLight);
    l.setTextColor(Color.WHITE);

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(mTfLight);
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(true);
    xl.setEnabled(true);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTfLight);
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setAxisMaximum(100f);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setDrawGridLines(true);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:60,代码来源:RealtimeLineChartActivity.java

示例10: onCreate

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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_time);

    tvX = (TextView) findViewById(R.id.tvXMax);
    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarX.setProgress(100);
    tvX.setText("100");

    mSeekBarX.setOnSeekBarChangeListener(this);

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

    // no description text
    mChart.getDescription().setEnabled(false);

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

    mChart.setDragDecelerationFrictionCoef(0.9f);

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

    // set an alternative background color
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setViewPortOffsets(0f, 0f, 0f, 0f);

    // add data
    setData(100, 30);
    mChart.invalidate();

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE);
    xAxis.setTypeface(mTfLight);
    xAxis.setTextSize(10f);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(true);
    xAxis.setTextColor(Color.rgb(255, 192, 56));
    xAxis.setCenterAxisLabels(true);
    xAxis.setGranularity(1f); // one hour
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        private SimpleDateFormat mFormat = new SimpleDateFormat("dd MMM HH:mm");

        @Override
        public String getFormattedValue(float value, AxisBase axis) {

            long millis = TimeUnit.HOURS.toMillis((long) value);
            return mFormat.format(new Date(millis));
        }
    });

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    leftAxis.setTypeface(mTfLight);
    leftAxis.setTextColor(ColorTemplate.getHoloBlue());
    leftAxis.setDrawGridLines(true);
    leftAxis.setGranularityEnabled(true);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setAxisMaximum(170f);
    leftAxis.setYOffset(-9f);
    leftAxis.setTextColor(Color.rgb(255, 192, 56));

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:LineChartTime.java

示例11: onCreate

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

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

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

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    
    // no description text
    mChart.getDescription().setEnabled(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(true);

    // set an alternative background color
    // mChart.setBackgroundColor(Color.GRAY);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
    mv.setChartView(mChart); // For bounds control
    mChart.setMarker(mv); // Set the marker to the chart
    
    XAxis xl = mChart.getXAxis();
    xl.setAvoidFirstLastClipping(true);
    xl.setAxisMinimum(0f);
    
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setInverted(true);
    leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
    
    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);

    // add data
    setData(25, 50);

    // // restrain the maximum scale-out factor
    // mChart.setScaleMinima(3f, 3f);
    //
    // // center the view to a specific position inside the chart
    // mChart.centerViewPort(10, 50);

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

    // modify the legend ...
    l.setForm(LegendForm.LINE);

    // dont forget to refresh the drawing
    mChart.invalidate();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:75,代码来源:InvertedLineChartActivity.java

示例12: onCreate

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的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.getDescription().setEnabled(false);
    mChart.setDrawBorders(false);

    mChart.getAxisLeft().setEnabled(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.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
    l.setDrawInside(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:49,代码来源:MultiLineChartActivity.java

示例13: setupChart

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
private void setupChart(LineChart chart, LineData data, int color) {
    ((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setTouchEnabled(false);
    chart.setDragEnabled(false);
    chart.setScaleEnabled(true);
    chart.setPinchZoom(false);
    chart.setBackgroundColor(color);
    chart.setViewPortOffsets(0, 23, 0, 0);
    chart.setData(data);
    Legend l = chart.getLegend();
    l.setEnabled(false);

    chart.getAxisLeft().setEnabled(true);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getAxisLeft().setDrawAxisLine(false);
    chart.getAxisLeft().setSpaceTop(10);
    chart.getAxisLeft().setSpaceBottom(30);
    chart.getAxisLeft().setAxisLineColor(0xFFFFFF);
    chart.getAxisLeft().setTextColor(0xFFFFFF);
    chart.getAxisLeft().setDrawTopYLabelEntry(true);
    chart.getAxisLeft().setLabelCount(10);

    chart.getXAxis().setEnabled(true);
    chart.getXAxis().setDrawGridLines(false);
    chart.getXAxis().setDrawAxisLine(false);
    chart.getXAxis().setAxisLineColor(0xFFFFFF);
    chart.getXAxis().setTextColor(0xFFFFFF);

    Typeface tf = Typeface.DEFAULT;

    // X Axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setTypeface(tf);
    xAxis.removeAllLimitLines();

    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);

    xAxis.setTextColor(Color.argb(150, 255, 255, 255));

    if (displayType == 1 || displayType == 2) // Week and Month
        xAxis.setValueFormatter(new WeekXFormatter());
    else if (displayType == 0) //  Day
        xAxis.setValueFormatter(new HourXFormatter());
    else
        xAxis.setValueFormatter(new YearXFormatter()); // Year

    // Y Axis
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.removeAllLimitLines();
    leftAxis.setTypeface(tf);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    leftAxis.setTextColor(Color.argb(150, 255, 255, 255));
    leftAxis.setValueFormatter(new DontShowNegativeFormatter(displayInUsd));
    chart.getAxisRight().setEnabled(false); // Deactivates horizontal lines

    chart.animateX(1300);
    chart.notifyDataSetChanged();
}
 
开发者ID:manuelsc,项目名称:Lunary-Ethereum-Wallet,代码行数:61,代码来源:FragmentPrice.java

示例14: onCreateView

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

    mDBTextView = (TextView) view.findViewById(R.id.record_db_fragment_db_tv);

    mDurationTimeView = (TextView) view.findViewById(R.id.record_db_fragment_duration_tv);

    mAverageTextView = (TextView) view.findViewById(R.id.record_db_fragment_average_tv);

    mMaxTextView = (TextView) view.findViewById(R.id.record_db_fragment_max_tv);

    mBtn = (Button) view.findViewById(R.id.record_db_fragment_switch_btn);
    mBtn.setOnClickListener(this);

    mLineChart = (LineChart) view.findViewById(R.id.record_db_fragment_info_lc);
    mLineChart.setOnChartValueSelectedListener(this);
    // 设置表描述为不可见
    mLineChart.getDescription().setEnabled(false);
    // 设置表描述可见,颜色值以及显示的文本
    // mLineChart.getDescription().setEnabled(true);
    // mLineChart.getDescription().setText(getString(R.string.db));
    // mLineChart.getDescription().setTextColor(Color.WHITE);
    // enable touch gestures
    mLineChart.setTouchEnabled(true);
    // enable scaling and dragging
    mLineChart.setDragEnabled(true);
    mLineChart.setScaleEnabled(true);
    mLineChart.setDrawGridBackground(false);
    // if disabled, scaling can be done on x- and y-axis separately
    mLineChart.setPinchZoom(true);
    // set an alternative background color
    mLineChart.setBackgroundColor(Color.parseColor("#6A1B9A") );
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mLineChart.setData(data);

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

    // modify the legend ...
    l.setForm(Legend.LegendForm.LINE);
    //l.setTypeface(mTfLight);
    l.setTextColor(Color.WHITE);

    // 获得图表的x轴
    XAxis xAxis = mLineChart.getXAxis();
    // 设置x轴的文本颜色为白色
    xAxis.setTextColor(Color.WHITE);
    // 不设置纵向的网格线,即与x轴垂直的线
    xAxis.setDrawGridLines(false);
    // 避免图表剪辑的边缘是屏幕
    xAxis.setAvoidFirstLastClipping(true);
    // 设置x轴可见
    xAxis.setEnabled(true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis leftYAxis = mLineChart.getAxisLeft();
    leftYAxis.setTextColor(Color.WHITE);
    leftYAxis.setAxisMaximum(100f);
    leftYAxis.setAxisMinimum(0f);
    leftYAxis.setDrawGridLines(true);
    // 获取右y轴并将其设置为可见
    YAxis rightYAxis  = mLineChart.getAxisRight();
    rightYAxis.setEnabled(true);
    rightYAxis.setDrawGridLines(false);
    // 设置与背景颜色相同使文本不可见
    rightYAxis.setTextColor(Color.parseColor("#6A1B9A"));

    addEntry(UserInfo.getInt(getContext(),"AverageDb"));
    return view;
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:76,代码来源:RecordDBFragment.java

示例15: onCreateView

import com.github.mikephil.charting.charts.LineChart; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_store_db_record, container, false);
    mDBTextView = (TextView) view.findViewById(R.id.store_record_db_fragment_db_tv);

    mDurationTimeView = (TextView) view.findViewById(R.id.store_record_db_fragment_duration_tv);

    mAverageTextView = (TextView) view.findViewById(R.id.store_record_db_fragment_average_tv);

    mMaxTextView = (TextView) view.findViewById(R.id.store_record_db_fragment_max_tv);

    mBtn = (Button) view.findViewById(R.id.store_record_db_fragment_switch_btn);
    mBtn.setOnClickListener(this);

    mLineChart = (LineChart) view.findViewById(R.id.store_record_db_fragment_info_lc);
    mLineChart.setOnChartValueSelectedListener(this);
    // 设置表描述为不可见
    mLineChart.getDescription().setEnabled(false);
    // 设置表描述可见,颜色值以及显示的文本
    // mLineChart.getDescription().setEnabled(true);
    // mLineChart.getDescription().setText(getString(R.string.db));
    // mLineChart.getDescription().setTextColor(Color.WHITE);
    // enable touch gestures
    mLineChart.setTouchEnabled(true);
    // enable scaling and dragging
    mLineChart.setDragEnabled(true);
    mLineChart.setScaleEnabled(true);
    mLineChart.setDrawGridBackground(false);
    // if disabled, scaling can be done on x- and y-axis separately
    mLineChart.setPinchZoom(true);
    // set an alternative background color
    mLineChart.setBackgroundColor(Color.parseColor("#6A1B9A"));
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mLineChart.setData(data);

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

    // modify the legend ...
    l.setForm(Legend.LegendForm.LINE);
    //l.setTypeface(mTfLight);
    l.setTextColor(Color.WHITE);

    // 获得图表的x轴
    XAxis xAxis = mLineChart.getXAxis();
    // 设置x轴的文本颜色为白色
    xAxis.setTextColor(Color.WHITE);
    // 不设置纵向的网格线,即与x轴垂直的线
    xAxis.setDrawGridLines(false);
    // 避免图表剪辑的边缘是屏幕
    xAxis.setAvoidFirstLastClipping(true);
    // 设置x轴可见
    xAxis.setEnabled(true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis leftYAxis = mLineChart.getAxisLeft();
    leftYAxis.setTextColor(Color.WHITE);
    leftYAxis.setAxisMaximum(100f);
    leftYAxis.setAxisMinimum(0f);
    leftYAxis.setDrawGridLines(true);
    // 获取右y轴并将其设置为可见
    YAxis rightYAxis = mLineChart.getAxisRight();
    rightYAxis.setEnabled(true);
    rightYAxis.setDrawGridLines(false);
    // 设置与背景颜色相同使文本不可见
    rightYAxis.setTextColor(Color.parseColor("#6A1B9A"));

    addEntry(UserInfo.getInt(getContext(), "AverageDb"));
    return view;
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:75,代码来源:StoreDbRecordFragment.java


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