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


Java YAxis.setGranularityEnabled方法代码示例

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


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

示例1: initTemperatureChart

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

示例2: initResistanceChart

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

示例3: chartYAxisStyling

import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void chartYAxisStyling(YAxis yAxis) {
    yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
    yAxis.setTextColor(SettingsActivity.ThemePreferenceFragment.isLight(getContext()) ?
            getResources().getColor(R.color.traffic_chart_text_color_light) :
            getResources().getColor(R.color.traffic_chart_text_color_dark));
    yAxis.setDrawGridLines(false);
    yAxis.setGranularityEnabled(true);
    yAxis.setDrawAxisLine(true);
}
 
开发者ID:DmitryMalkovich,项目名称:gito-github-client,代码行数:11,代码来源:TrafficFragment.java

示例4: onCreate

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

    // 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);

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

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTfLight);
    leftAxis.setLabelCount(6, false);
    leftAxis.setAxisMinimum(-2.5f);
    leftAxis.setAxisMaximum(2.5f);
    leftAxis.setGranularityEnabled(true);
    leftAxis.setGranularity(0.1f);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setTypeface(mTfLight);
    rightAxis.setLabelCount(6, false);
    rightAxis.setAxisMinimum(-2.5f);
    rightAxis.setAxisMaximum(2.5f);
    rightAxis.setGranularity(0.1f);

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

    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);

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

示例5: onCreate

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

示例6: setUpActivityChart

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

示例7: setUpActivityChart

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

示例8: initChart

import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initChart() {
    // init chart
    mChart.getDescription().setEnabled(false);
    mChart.setTouchEnabled(true);
    mChart.setDragDecelerationFrictionCoef(0.9f);
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setDrawGridBackground(false);
    mChart.setHighlightPerDragEnabled(true);
    mChart.setBackground(getActivity().getDrawable(R.drawable.bg_chart));
    mChart.setViewPortOffsets(80f, 0f, 80f, 0f);
    setData();
    mChart.invalidate();
    mChart.getLegend().setEnabled(false);

    // init xAxis
    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
    xAxis.setDrawAxisLine(false);
    xAxis.setTextSize(10f);
    xAxis.setTextColor(Color.rgb(255, 192, 56));
    xAxis.setDrawGridLines(true);
    xAxis.setCenterAxisLabels(false);
    xAxis.setDrawGridLines(false);
    xAxis.setEnabled(false);
    xAxis.setGranularityEnabled(true);

    YAxis yAxis = mChart.getAxisLeft();
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis.setTextColor(ColorTemplate.getHoloBlue());
    yAxis.setDrawGridLines(true);
    yAxis.setGranularityEnabled(true);
    yAxis.setAxisMinimum(50f);
    yAxis.setAxisMaximum(130f);
    yAxis.setYOffset(-9f);
    yAxis.setXOffset(-20f);
    yAxis.setTextColor(Color.rgb(255, 192, 56));
    yAxis.setDrawAxisLine(false);
    yAxis.setDrawGridLines(false);

    mChart.getAxisRight().setEnabled(false);
}
 
开发者ID:InnoFang,项目名称:FamilyBond,代码行数:43,代码来源:DataDisplayFragment.java

示例9: initCharts

import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initCharts(BarChart mChart) {
        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);

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

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
        leftAxis.setLabelCount(6, false);
//        leftAxis.setAxisMinimum(-2.5f);
//        leftAxis.setAxisMaximum(2.5f);
        leftAxis.setGranularityEnabled(true);
        leftAxis.setGranularity(0.1f);

        YAxis rightAxis = mChart.getAxisRight();
        rightAxis.setDrawGridLines(false);
        rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
        rightAxis.setLabelCount(6, false);
//        rightAxis.setAxisMinimum(-2.5f);
//        rightAxis.setAxisMaximum(2.5f);
        rightAxis.setGranularity(0.1f);

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

        mChart.animateXY(2000, 2000);
    }
 
开发者ID:qizhenghao,项目名称:Microsoft_Band,代码行数:50,代码来源:AccelerateFragment.java

示例10: initChart

import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
     * 初始化报表
     *
     * @param showAnimation 是否显示动画
     */
    void initChart(boolean showAnimation) {

        int screenWidth = Utils.getScreenWidth(mContext);
        combinedChart.getLayoutParams().height = screenWidth * 300 / 640;

        //启用缩放和拖动
        combinedChart.setDragEnabled(true);//拖动
        combinedChart.setScaleEnabled(false);//缩放
        combinedChart.setOnChartValueSelectedListener(this);
        combinedChart.getDescription().setEnabled(false);
        combinedChart.setBackgroundColor(ContextCompat.getColor(mContext, R.color.co10));
        combinedChart.setDrawGridBackground(false);
        combinedChart.setDrawBarShadow(false);
        combinedChart.setHighlightFullBarEnabled(false);

        Legend l = combinedChart.getLegend();
        l.setForm(Legend.LegendForm.NONE);//底部样式
        l.setTextColor(ContextCompat.getColor(mContext, R.color.transparent));
        l.setWordWrapEnabled(false);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);

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

        YAxis leftAxis = combinedChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setGranularityEnabled(false);
        leftAxis.setDrawAxisLine(false);
        leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
        leftAxis.setTextColor(ContextCompat.getColor(mContext, R.color.co4));

        updateTitle(items.get(dateSelected));
        XAxis xAxis = combinedChart.getXAxis();
        xAxis.setTypeface(mTfLight);
        xAxis.setEnabled(true);//设置轴启用或禁用 如果禁用以下的设置全部不生效
        xAxis.setDrawAxisLine(true);//是否绘制轴线
        xAxis.setDrawGridLines(false);//设置x轴上每个点对应的线
        xAxis.setDrawLabels(true);//绘制标签  指x轴上的对应数值
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//设置x轴的显示位置
        xAxis.setTextSize(10f); //设置X轴文字大小
        xAxis.setGranularityEnabled(true);//是否允许X轴上值重复出现
        xAxis.setTextColor(ContextCompat.getColor(this, R.color.co4));//设置X轴文字颜色
//        //设置竖线的显示样式为虚线
//        //lineLength控制虚线段的长度
//        //spaceLength控制线之间的空间
        xAxis.enableGridDashedLine(10f, 10f, 0f);
        xAxis.setAxisMinimum(0f);//设置x轴的最小值
        xAxis.setAxisMaximum(mDatas.length);//设置最大值
        xAxis.setAvoidFirstLastClipping(true);//图表将避免第一个和最后一个标签条目被减掉在图表或屏幕的边缘
        xAxis.setLabelRotationAngle(0f);//设置x轴标签字体的旋转角度
//        设置x轴显示标签数量  还有一个重载方法第二个参数为布尔值强制设置数量 如果启用会导致绘制点出现偏差
        xAxis.setLabelCount(10);
        xAxis.setGridLineWidth(10f);//设置竖线大小
//        xAxis.setGridColor(Color.RED);//设置竖线颜色
        xAxis.setAxisLineColor(Color.GRAY);//设置x轴线颜色
        xAxis.setAxisLineWidth(1f);//设置x轴线宽度

        CombinedData combinedData = new CombinedData();
        combinedData.setData(generateLineData());
        combinedData.setData(generateBarData());
        combinedData.setValueTypeface(mTfLight);
        xAxis.setAxisMaximum(combinedData.getXMax() + 0.25f);
        //X轴的数据格式
        ValueFormatter xAxisFormatter = new ValueFormatter(combinedChart);
        xAxisFormatter.setmValues(xAxisValue);
        xAxis.setValueFormatter(xAxisFormatter);//格式化x轴标签显示字符
        combinedChart.setData(combinedData);
        combinedChart.invalidate();
        if (showAnimation) {
            combinedChart.animateY(2000);
        }
    }
 
开发者ID:jay16,项目名称:shengyiplus-android,代码行数:81,代码来源:HomeTricsActivity.java

示例11: SetupChart

import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
public void SetupChart() {
    lineChart = (LineChart) myLayout.findViewById(R.id.chart);
    lineChart.setDescription("");
    lineChart.setDrawBorders(false);
    lineChart.setNoDataTextDescription("You need to provide data for the chart.");
    lineChart.setDrawGridBackground(false);
    lineChart.setOnChartValueSelectedListener(this);
    lineChart.setTouchEnabled(true);
    lineChart.setDragEnabled(false);
    lineChart.setPinchZoom(false);
    lineChart.setScaleXEnabled(true);
    lineChart.setScaleYEnabled(true);
    lineChart.invalidate();
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);
    // add empty data
    lineChart.setData(data);
    // get the legend (only possible after setting data)
    Legend l = lineChart.getLegend();
    l.setEnabled(false);
    // x axis setup
    XAxis xl = lineChart.getXAxis();
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(false);
    xl.setSpaceBetweenLabels(3);
    xl.setEnabled(true);
    xl.setDrawAxisLine(false);
    xl.removeAllLimitLines();
    //right y axis setup
    YAxis rightAxis = lineChart.getAxisRight();
    rightAxis.setEnabled(false);
    //left y axis setup
    YAxis leftAxis = lineChart.getAxisLeft();
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setLabelCount(6, true);
    leftAxis.setAxisMaxValue(400f);
    leftAxis.setAxisMinValue(0f);
    leftAxis.setDrawGridLines(false);
    leftAxis.setStartAtZero(false);
    leftAxis.setEnabled(true);
    leftAxis.setDrawAxisLine(false);
    leftAxis.setDrawZeroLine(false);
    leftAxis.setGranularityEnabled(false);
    //define min max line
    LimitLine max = new LimitLine(150f);
    max.enableDashedLine(10f, 10f, 0f);
    LimitLine min = new LimitLine(50f);
    min.enableDashedLine(10f, 10f, 0f);
    // reset all limit lines to avoid overlapping lines
    leftAxis.removeAllLimitLines();
    //add min max line
    leftAxis.addLimitLine(max);
    leftAxis.addLimitLine(min);

    lineChart.invalidate();
}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:58,代码来源:wearDripWatchFace.java

示例12: setYAxisConfig

import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setYAxisConfig(YAxis axis, ReadableMap propMap) {
    if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMaxValue")) {
        axis.setAxisMaxValue((float) propMap.getDouble("axisMaxValue"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMinValue")) {
        axis.setAxisMinValue((float) propMap.getDouble("axisMinValue"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "inverted")) {
        axis.setInverted(propMap.getBoolean("inverted"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceTop")) {
        axis.setSpaceTop((float) propMap.getDouble("spaceTop"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceBottom")) {
        axis.setSpaceBottom((float) propMap.getDouble("spaceBottom"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "showOnlyMinMax")) {
        axis.setShowOnlyMinMax(propMap.getBoolean("showOnlyMinMax"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "labelCount")) {
        boolean labelCountForce = false;
        if (BridgeUtils.validate(propMap, ReadableType.Boolean, "labelCountForce")) {
            labelCountForce = propMap.getBoolean("labelCountForce");
        }
        axis.setLabelCount(propMap.getInt("labelCount"), labelCountForce);
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "position")) {
        axis.setPosition(YAxis.YAxisLabelPosition.valueOf(propMap.getString("position")));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "granularity")) {
        axis.setGranularity((float) propMap.getDouble("granularity"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "granularityEnabled")) {
        axis.setGranularityEnabled(propMap.getBoolean("granularityEnabled"));
    }


    // formatting
    if (BridgeUtils.validate(propMap, ReadableType.String, "valueFormatter")) {
        String valueFormatter = propMap.getString("valueFormatter");

        if ("largeValue".equals(valueFormatter)) {
            axis.setValueFormatter(new LargeValueFormatter());
        } else if ("percent".equals(valueFormatter)) {
            axis.setValueFormatter(new PercentFormatter());
        } else {
            axis.setValueFormatter(new CustomFormatter(valueFormatter));
        }
    }

    // TODO docs says the remaining config needs to be applied before setting data. Test it
    // zero line
    if (BridgeUtils.validate(propMap, ReadableType.Map, "zeroLine")) {
        ReadableMap zeroLineConfig = propMap.getMap("zeroLine");

        if (BridgeUtils.validate(zeroLineConfig, ReadableType.Boolean, "enabled")) {
            axis.setDrawZeroLine(zeroLineConfig.getBoolean("enabled"));
        }
        if (BridgeUtils.validate(zeroLineConfig, ReadableType.Number, "lineWidth")) {
            axis.setZeroLineWidth((float) zeroLineConfig.getDouble("lineWidth"));
        }
        if (BridgeUtils.validate(zeroLineConfig, ReadableType.String, "lineColor")) {
            axis.setZeroLineColor(Color.parseColor(zeroLineConfig.getString("lineColor")));
        }
    }
}
 
开发者ID:mskec,项目名称:react-native-mp-android-chart,代码行数:67,代码来源:YAxisChartBase.java


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