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


Java Legend.setTextColor方法代碼示例

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


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

示例1: setAxis

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
@Override
public void setAxis(AnalysisXAxisValueFormatter formatter, float yAxisMaxValue) {

    XAxis xAxis = mRadarChart.getXAxis();
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(formatter);
    xAxis.setTextColor(Color.WHITE);

    YAxis yAxis = mRadarChart.getYAxis();
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(yAxisMaxValue);
    yAxis.setDrawLabels(false);

    Legend l = mRadarChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
 
開發者ID:Alex-ZHOU,項目名稱:VMAndroid,代碼行數:27,代碼來源:AnalysisChartFragment.java

示例2: onCreateView

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_idpt, container, false);

    BarChart chart = (BarChart) view.findViewById(R.id.chart);

    BarData data = new BarData(getXAxisValues(), getDataSet());

    //legend coding
    Legend l=chart.getLegend();
    l.setFormSize(10f);
    l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
    l.setTextSize(12f);
    l.setTextColor(Color.BLACK);
    l.setXEntrySpace(5f);
    l.setYEntrySpace(5f);
    //l.setCustom();

    XAxis xaxis=chart.getXAxis();
    xaxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xaxis.setTextSize(7f);
    xaxis.setTextColor(Color.parseColor("#212121"));
    xaxis.setDrawAxisLine(true);
    xaxis.setDrawGridLines(false);


    chart.setData(data);
    chart.setDescription("");
    chart.animateXY(2000, 2000);
    chart.invalidate();
   // chart.zoom(100, 10, 10, 10);


    return view;


}
 
開發者ID:Ronak-59,項目名稱:Trinity-App,代碼行數:38,代碼來源:IDPTFragment.java

示例3: init

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs, int defStyle) {
    setUsePercentValues(true);
    getDescription().setEnabled(false);
    setExtraOffsets(5, 10, 5, 5);
    setDragDecelerationFrictionCoef(0.95f);

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

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

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

    setDrawCenterText(true);

    setRotationAngle(0);
    setRotationEnabled(true);
    setHighlightPerTapEnabled(true);


    Legend l = getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
    l.setTextColor(Color.GRAY);
    l.setDrawInside(false);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(0f);
    l.setYOffset(0f);

    setEntryLabelColor(Color.GRAY);
    setEntryLabelTextSize(12f);
}
 
開發者ID:VidyaSastry,項目名稱:Opal-Chat-AnalyticsDashboard,代碼行數:36,代碼來源:MyPieChart.java

示例4: initTemperatureChart

import com.github.mikephil.charting.components.Legend; //導入方法依賴的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

示例5: initResistanceChart

import com.github.mikephil.charting.components.Legend; //導入方法依賴的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

示例6: setupPie

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void setupPie(PieChart pieChart, int pos, float dados[], String labels[]) {


        List<PieEntry> entries = new ArrayList<>();
        int index = 0;
        for (float dado : dados) {
            entries.add(new PieEntry(dado, labels[index]));
            index++;
        }

        //entries.add(new PieEntry(24.0f, "Red"));
        //entries.add(new PieEntry(30.8f, "Blue"));

        PieDataSet set = new PieDataSet(entries, "");
        Description description = new Description();
        description.setText(" ");
        pieChart.setDescription(description);
        set.setColors(ColorTemplate.MATERIAL_COLORS);
        PieData data = new PieData(set);
        pieChart.setData(data);
        pieChart.invalidate();


        Legend l = pieChart.getLegend();
        l.setFormSize(15f); // set the size of the legend forms/shapes
        l.setForm(Legend.LegendForm.CIRCLE); // set what type of form/shape should be used
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
        l.setOrientation(Legend.LegendOrientation.VERTICAL);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
        l.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        l.setTextSize(18f);
        l.setTextColor(Color.BLACK);
        l.setXEntrySpace(5f); // set the space between the legend entries on the x-axis
        l.setYEntrySpace(5f);

        pieChart.animateXY(3000, 3000);

    }
 
開發者ID:ivoribeiro,項目名稱:AndroidQuiz,代碼行數:39,代碼來源:AdapterEstatisticasGraph.java

示例7: getFormattedPieChart

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
/**
 * Formats a pie chart in a standardized way
 * @param c Context
 * @param p Pie chart
 * @param shouldShowLegend
 * @return the PieChart, whose data must be set and invalidated
 */
public static PieChart getFormattedPieChart(Context c, PieChart p, boolean shouldShowLegend) {
    Legend cLegend = p.getLegend();
    if (shouldShowLegend) {
        cLegend.setEnabled(true);
        cLegend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        cLegend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        cLegend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        cLegend.setDrawInside(false);
        cLegend.setForm(Legend.LegendForm.CIRCLE);
        cLegend.setTextSize(15);
        cLegend.setWordWrapEnabled(true);
    } else {
        cLegend.setEnabled(false);
    }

    p.setDrawEntryLabels(false);
    p.setDescription(EMPTY_CHART_DESCRIPTION);
    p.setHoleRadius(60f);
    p.setTransparentCircleRadius(65f);
    p.setCenterTextSize(20);

    if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
        int colorPrimaryNoir = ContextCompat.getColor(c, R.color.colorPrimaryNoir);
        int colorPrimaryTextNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);

        p.setHoleColor(colorPrimaryNoir);
        p.setTransparentCircleColor(colorPrimaryNoir);
        p.setCenterTextColor(colorPrimaryTextNoir);
        cLegend.setTextColor(colorPrimaryTextNoir);
    }

    p.setRotationEnabled(false);

    p.setOnChartValueSelectedListener(new PieChartListener(p));
    return p;
}
 
開發者ID:lloydtorres,項目名稱:stately,代碼行數:44,代碼來源:RaraHelper.java

示例8: getFormattedLineChart

import com.github.mikephil.charting.components.Legend; //導入方法依賴的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

示例9: onCreate

import com.github.mikephil.charting.components.Legend; //導入方法依賴的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.components.Legend; //導入方法依賴的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_noseekbar);

    TextView tv = (TextView) findViewById(R.id.textView);
    tv.setTypeface(mTfLight);
    tv.setTextColor(Color.WHITE);
    tv.setBackgroundColor(Color.rgb(60, 65, 82));

    mChart = (RadarChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.rgb(60, 65, 82));

    mChart.getDescription().setEnabled(false);

    mChart.setWebLineWidth(1f);
    mChart.setWebColor(Color.LTGRAY);
    mChart.setWebLineWidthInner(1f);
    mChart.setWebColorInner(Color.LTGRAY);
    mChart.setWebAlpha(100);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview);
    mv.setChartView(mChart); // For bounds control
    mChart.setMarker(mv); // Set the marker to the chart

    setData();

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setTypeface(mTfLight);
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        private String[] mActivities = new String[]{"Burger", "Steak", "Salad", "Pasta", "Pizza"};

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mActivities[(int) value % mActivities.length];
        }
    });
    xAxis.setTextColor(Color.WHITE);

    YAxis yAxis = mChart.getYAxis();
    yAxis.setTypeface(mTfLight);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(80f);
    yAxis.setDrawLabels(false);

    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setTypeface(mTfLight);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:71,代碼來源:RadarChartActivitry.java

示例11: formatPieChartLegend

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void formatPieChartLegend(Legend legend) {
    legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    legend.setTextColor(Color.WHITE);
    legend.setDrawInside(false);
}
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:7,代碼來源:ChartFragment.java

示例12: setUpActivityChart

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void setUpActivityChart() {

        Legend l = lineChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);
        l.setTextColor(Color.WHITE);
        l.setTextSize(12);
        l.setWordWrapEnabled(true);
        l.setXEntrySpace(UiUtils.dpToPx(4));
        l.setYEntrySpace(UiUtils.dpToPx(4));

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

        YAxis leftAxis = lineChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setAxisMinimum(0);
        leftAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                return value == 0 ? "" : String.valueOf(FormatUtils.getFormattedTime(context, (int) value));
            }
        });
        leftAxis.setGranularityEnabled(true);
        leftAxis.setGranularity(3600f); // FIXME: 12-04-2017 granularity not respected
        leftAxis.setAxisLineWidth(2f);
        leftAxis.setTextColor(Color.WHITE);
        leftAxis.setAxisLineColor(Color.WHITE);

        XAxis xAxis = lineChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setDrawGridLines(false);
        xAxis.setTextColor(Color.WHITE);
        xAxis.setSpaceMin(0.5f);
        xAxis.setSpaceMax(0.5f);
        xAxis.setYOffset(UiUtils.dpToPx(4));
        xAxis.setAxisLineWidth(2f);
        xAxis.setAxisLineColor(Color.WHITE);

        lineChart.getDescription().setEnabled(false);
        lineChart.setDrawGridBackground(false);
        lineChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
        lineChart.setDragEnabled(false);
        lineChart.setScaleEnabled(false);
        lineChart.setDragDecelerationEnabled(false);
        lineChart.setPinchZoom(false);
        lineChart.setDoubleTapToZoomEnabled(false);
        lineChart.setDrawBorders(false);
        lineChart.setExtraOffsets(16, 0, 16, 0);
    }
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:53,代碼來源:DashboardFragment.java

示例13: setUpActivityChart

import com.github.mikephil.charting.components.Legend; //導入方法依賴的package包/類
private void setUpActivityChart() {

        Legend l = lineChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);
        l.setTextColor(Color.WHITE);
        l.setTextSize(12);
        l.setWordWrapEnabled(true);
        l.setXEntrySpace(UiUtils.dpToPx(4));
        l.setYEntrySpace(UiUtils.dpToPx(4));

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

        YAxis leftAxis = lineChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setAxisMinimum(0);
        leftAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                return value == 0 ? "" : String.valueOf(FormatUtils.getFormattedTime(context, (int) value));
            }
        });
        leftAxis.setGranularityEnabled(true);
        leftAxis.setGranularity(3600f); // FIXME: 12-04-2017 granularity not respected
        leftAxis.setAxisLineWidth(2f);
        leftAxis.setTextColor(Color.WHITE);
        leftAxis.setAxisLineColor(Color.WHITE);

        long referenceTime = new DateTime().plusDays(-7).getMillis();
        XAxis xAxis = lineChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
        xAxis.setDrawGridLines(false);
        xAxis.setTextColor(Color.WHITE);
        xAxis.setSpaceMin(0.5f);
        xAxis.setSpaceMax(0.5f);
        xAxis.setYOffset(UiUtils.dpToPx(4));
        xAxis.setAxisLineWidth(2f);
        xAxis.setAxisLineColor(Color.WHITE);


        CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
        lineChart.setMarker(customMarkerView);
        lineChart.getDescription().setEnabled(false);
        lineChart.setDrawGridBackground(false);
        lineChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
        lineChart.setDragEnabled(false);
        lineChart.setScaleEnabled(false);
        lineChart.setDragDecelerationEnabled(false);
        lineChart.setPinchZoom(false);
        lineChart.setDoubleTapToZoomEnabled(false);
        lineChart.setDrawBorders(false);
        lineChart.setExtraOffsets(16, 0, 16, 0);

        customMarkerView.setChartView(lineChart);
    }
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:60,代碼來源:DashboardFragment.java

示例14: onCreateView

import com.github.mikephil.charting.components.Legend; //導入方法依賴的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.components.Legend; //導入方法依賴的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.components.Legend.setTextColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。