Java Code Examples for com.github.mikephil.charting.components.XAxis#setDrawLabels()

The following examples show how to use com.github.mikephil.charting.components.XAxis#setDrawLabels() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiesChartActivity.java    From Mi-Band with GNU General Public License v2.0 6 votes vote down vote up
private void createChartLegend() {
    /*
    Legend l = mChart.getLegend();
    l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE);
    l.setYOffset(0f);
    l.setYEntrySpace(0f);
    l.setTextSize(8f);
    */

    XAxis x = mChart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setDrawLimitLinesBehindData(true);

    YAxis y = mChart.getAxisLeft();
    y.setAxisMaxValue(1f);
    y.setDrawTopYLabelEntry(false);
    y.setEnabled(true);

    mChart.getAxisRight().setEnabled(false);
}
 
Example 2
Source File: SleepChartActivity.java    From Mi-Band with GNU General Public License v2.0 6 votes vote down vote up
private void createChartLegend() {
    /*
    Legend l = mChart.getLegend();
    l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_INSIDE);
    l.setYOffset(0f);
    l.setYEntrySpace(0f);
    l.setTextSize(8f);
    */

    XAxis x = mChart.getXAxis();
    x.setDrawLabels(true);
    x.setDrawGridLines(false);
    x.setEnabled(true);
    x.setDrawLimitLinesBehindData(true);

    YAxis y = mChart.getAxisLeft();
    y.setAxisMaxValue(1f);
    y.setDrawTopYLabelEntry(false);
    y.setEnabled(true);

    mChart.getAxisRight().setEnabled(false);
}
 
Example 3
Source File: PowerChart.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
private void setFormatting() {
    powerChart.setDrawGridBackground(false);
    powerChart.getLegend().setEnabled(false);
    powerChart.getAxisRight().setEnabled(false);
    powerChart.getDescription().setEnabled(false);
    powerChart.setNoDataText("");
    powerChart.setHardwareAccelerationEnabled(true);

    YAxis yAxis = powerChart.getAxisLeft();
    yAxis.setEnabled(true);
    yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    yAxis.setDrawTopYLabelEntry(false);
    yAxis.setDrawGridLines(false);
    yAxis.setDrawAxisLine(false);
    yAxis.setTextColor(ContextCompat.getColor(context, R.color.lightGrey));
    yAxis.setTextSize(context.getResources().getInteger(R.integer.chartDateTextSize));
    yAxis.setValueFormatter(new IntegerYAxisValueFormatter());

    XAxis xAxis = powerChart.getXAxis();
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawLabels(true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(ContextCompat.getColor(context, R.color.lightGrey));
    xAxis.setValueFormatter(new HoursMinutesXAxisValueFormatter(chartLabels));

    xAxis.setTextSize(context.getResources().getInteger(R.integer.chartDateTextSize));
}
 
Example 4
Source File: MeasurementActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
public void initVueMeter(){
    mChart.setDrawBarShadow(false);
    mChart.setDescription("");
    mChart.setPinchZoom(false);
    mChart.setDrawGridBackground(false);
    mChart.setMaxVisibleValueCount(0);
    mChart.setScaleXEnabled(false); // Disable scaling on the X-axis
    // XAxis parameters: hide all
    XAxis xlv = mChart.getXAxis();
    xlv.setPosition(XAxisPosition.BOTTOM);
    xlv.setDrawAxisLine(false);
    xlv.setDrawGridLines(false);
    xlv.setDrawLabels(false);
    // YAxis parameters (left): main axis for dB values representation
    YAxis ylv = mChart.getAxisLeft();
    ylv.setDrawAxisLine(false);
    ylv.setDrawGridLines(true);
    ylv.setAxisMaxValue(110.f);
    ylv.setStartAtZero(true);
    ylv.setTextColor(Color.WHITE);
    ylv.setGridColor(Color.WHITE);
    ylv.setValueFormatter(new dBValueFormatter());
    // YAxis parameters (right): no axis, hide all
    YAxis yrv = mChart.getAxisRight();
    yrv.setEnabled(false);
    //return true;
}
 
Example 5
Source File: CalibrationLinearityActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
private void initBar() {
    BarChart barChart = getBarChart();
    if(barChart == null) {
        return;
    }
    barChart.setDescription("");

    barChart.setDrawGridBackground(false);

    barChart.setMaxVisibleValueCount(200);

    Legend l = barChart.getLegend();
    l.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
    l.setTextColor(Color.WHITE);

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

    XAxis xl = barChart.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);
}
 
Example 6
Source File: CalibrationLinearityActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: Results.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
public void initSpectrumChart(){
    sChart.setPinchZoom(false);
    sChart.setDoubleTapToZoomEnabled(false);
    sChart.setDrawBarShadow(false);
    sChart.setDescription("");
    sChart.setPinchZoom(false);
    sChart.setDrawGridBackground(false);
    sChart.setHighlightPerTapEnabled(true);
    sChart.setHighlightPerDragEnabled(false);
    sChart.setDrawHighlightArrow(true);
    sChart.setDrawValueAboveBar(true);
    // XAxis parameters: hide all
    XAxis xls = sChart.getXAxis();
    xls.setPosition(XAxisPosition.BOTTOM);
    xls.setDrawAxisLine(true);
    xls.setDrawGridLines(false);
    xls.setLabelRotationAngle(-90);
    xls.setDrawLabels(true);
    xls.setTextColor(Color.WHITE);
    xls.setLabelsToSkip(0);
    // YAxis parameters (left): main axis for dB values representation
    YAxis yls = sChart.getAxisLeft();
    yls.setDrawAxisLine(true);
    yls.setDrawGridLines(true);
    yls.setAxisMaxValue(110.f);
    yls.setStartAtZero(true);
    yls.setTextColor(Color.WHITE);
    yls.setGridColor(Color.WHITE);
    // YAxis parameters (right): no axis, hide all
    YAxis yrs = sChart.getAxisRight();
    yrs.setEnabled(false);
    //return true;
}
 
Example 8
Source File: ChartUtil.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 显示图表
 *
 * @param context    上下文
 * @param lineChart  图表对象
 * @param yDataList  数据
 * @param title      图表标题(如:XXX趋势图)
 * @param curveLable 曲线图例名称(如:--用电量/时间)
 * @param unitName   坐标点击弹出提示框中数字单位(如:KWH)
 */
public static void showChart(Context context, LineChart lineChart,
                             List<Entry> yDataList, String title, String curveLable, String unitName) {
    // 设置数据
    lineChart.setData(setLineData(context, yDataList, curveLable));
    // 描述的显示和隐藏
    lineChart.getDescription().setEnabled(false);
    // 是否在折线图上添加边框
    lineChart.setDrawBorders(true);
    // 如果没有数据的时候,会显示这个,类似文本框的placeholder
    lineChart.setNoDataText(context.getString(R.string.no_data_chart));
    // 是否显示表格颜色
    lineChart.setDrawGridBackground(false);
    // 禁止绘制图表边框的线
    lineChart.setDrawBorders(false);
    // 表格的的颜色,在这里是是给颜色设置一个透明度
    // lineChart.setGridBackgroundColor(Color.WHITE & 0x70FFFFFF);
    // 设置是否启动触摸响应
    lineChart.setTouchEnabled(false);
    // 是否可以拖拽
    lineChart.setDragEnabled(false);
    // 是否可以缩放
    lineChart.setScaleEnabled(false);
    // 如果禁用,可以在x和y轴上分别进行缩放
    lineChart.setPinchZoom(false);
    // lineChart.setMarkerView(mv);
    // 设置背景色
    // lineChart.setBackgroundColor(getResources().getColor(R.color.bg_white));
    // 图例对象
    Legend mLegend = lineChart.getLegend();
    // mLegend.setPosition(LegendPosition.BELOW_CHART_CENTER);
    // 图例样式 (CIRCLE圆形;LINE线性;SQUARE是方块)
    mLegend.setForm(LegendForm.SQUARE);
    // 图例大小
    mLegend.setFormSize(8f);
    // 图例上的字体颜色
    mLegend.setTextColor(context.getApplicationContext().getResources().getColor(R.color.theme_color));
    mLegend.setTextSize(12f);
    // 图例字体
    // mLegend.setTypeface(mTf);
    // 图例的显示和隐藏
    mLegend.setEnabled(false);
    // 隐藏右侧Y轴(只在左侧的Y轴显示刻度)
    lineChart.getAxisRight().setEnabled(false);
    // 隐藏左侧Y轴(只在左侧的Y轴显示刻度)
    lineChart.getAxisLeft().setEnabled(false);
    XAxis xAxis = lineChart.getXAxis();
    // 显示X轴上的刻度值
    xAxis.setDrawLabels(false);
    // 设置X轴的数据显示在报表的下方
    xAxis.setPosition(XAxisPosition.BOTTOM);
    // 轴线
    xAxis.setDrawAxisLine(false);
    // 设置不从X轴发出纵向直线
    xAxis.setDrawGridLines(false);
    // 执行的动画,x轴(动画持续时间)
    lineChart.animateX(1500);
    lineChart.notifyDataSetChanged();
}
 
Example 9
Source File: BaseView.java    From android-kline with Apache License 2.0 4 votes vote down vote up
protected void initBottomChart(AppCombinedChart chart) {
        chart.setScaleEnabled(true);
        chart.setDrawBorders(false);
        chart.setBorderWidth(1);
        chart.setDragEnabled(true);
        chart.setScaleYEnabled(false);
        chart.setAutoScaleMinMaxEnabled(true);
        chart.setDragDecelerationEnabled(false);
        chart.setHighlightPerDragEnabled(false);
        Legend lineChartLegend = chart.getLegend();
        lineChartLegend.setEnabled(false);


        XAxis xAxisVolume = chart.getXAxis();
        xAxisVolume.setDrawLabels(true);
        xAxisVolume.setDrawAxisLine(false);
        xAxisVolume.setDrawGridLines(false);
        xAxisVolume.setTextColor(mAxisColor);
        xAxisVolume.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxisVolume.setLabelCount(3, true);
        xAxisVolume.setAvoidFirstLastClipping(true);
        xAxisVolume.setAxisMinimum(-0.5f);

        xAxisVolume.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                if (mData.isEmpty()) {
                    return "";
                }
                if (value < 0) {
                    value = 0;
                }
                if (value < mData.size()) {
                    return DateUtils.formatDate(mData.get((int) value).getDate(), mDateFormat);
                }
                return "";
            }
        });

        YAxis axisLeftVolume = chart.getAxisLeft();
        axisLeftVolume.setDrawLabels(true);
        axisLeftVolume.setDrawGridLines(false);
        axisLeftVolume.setLabelCount(3, true);
        axisLeftVolume.setDrawAxisLine(false);
        axisLeftVolume.setTextColor(mAxisColor);
        axisLeftVolume.setSpaceTop(10);
        axisLeftVolume.setSpaceBottom(0);
        axisLeftVolume.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
        /*axisLeftVolume.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                String s;
                if (value > 10000) {
                    s = (int) (value / 10000) + "w";
                } else if (value > 1000) {
                    s = (int) (value / 1000) + "k";
                } else {
                    s = (int) value + "";
                }
                return String.format(Locale.getDefault(), "%1$5s", s);
            }
        });
*/
        Transformer leftYTransformer = chart.getRendererLeftYAxis().getTransformer();
        ColorContentYAxisRenderer leftColorContentYAxisRenderer = new ColorContentYAxisRenderer(chart.getViewPortHandler(), chart.getAxisLeft(), leftYTransformer);
        leftColorContentYAxisRenderer.setLabelInContent(true);
        leftColorContentYAxisRenderer.setUseDefaultLabelXOffset(false);
        chart.setRendererLeftYAxis(leftColorContentYAxisRenderer);

        //右边y
        YAxis axisRightVolume = chart.getAxisRight();
        axisRightVolume.setDrawLabels(false);
        axisRightVolume.setDrawGridLines(false);
        axisRightVolume.setDrawAxisLine(false);

    }
 
Example 10
Source File: MiniDateGraph.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public MiniDateGraph(Context context, LineChart chart, String name) {
    mChart = chart;
    mChartName = name;
    mChart.getDescription().setEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setHorizontalScrollBarEnabled(false);
    mChart.setVerticalScrollBarEnabled(false);
    mChart.setAutoScaleMinMaxEnabled(false);
    mChart.setDrawBorders(false);
    mChart.setViewPortOffsets(6f, 6f, 6f, 6f);
    mChart.animateY(1000, Easing.EaseInOutBack); // animate horizontal 3000 milliseconds
    mChart.setClickable(false);

    mChart.getAxisRight().setDrawLabels(false);
    mChart.getAxisLeft().setDrawLabels(false);
    mChart.getLegend().setEnabled(false);
    mChart.setPinchZoom(false);
    mChart.setDescription(null);
    mChart.setTouchEnabled(false);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setNoDataText(context.getString(R.string.no_chart_data_available));

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setDrawLabels(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(ColorTemplate.getHoloBlue());
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(false);
    xAxis.setCenterAxisLabels(false);
    xAxis.setGranularity(1); // 1 jour

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setEnabled(false);
    leftAxis.setDrawZeroLine(false);
    leftAxis.setDrawLabels(false);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
    leftAxis.setTextColor(ColorTemplate.getHoloBlue());
    leftAxis.setDrawGridLines(false);
    leftAxis.setGranularityEnabled(false);

    mChart.getAxisRight().setEnabled(false);
}
 
Example 11
Source File: MeasurementSpectrumFragment.java    From NoiseCapture with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if(view == null) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_measurement_spectrum, container, false);
        BarChart sChart = (BarChart) view.findViewById(R.id.spectrumChart);
        sChart.setDrawBarShadow(false);
        sChart.setDescription("");
        sChart.getLegend().setEnabled(false);
        sChart.setTouchEnabled(false);
        sChart.setPinchZoom(false);
        sChart.setDrawGridBackground(false);
        sChart.setMaxVisibleValueCount(0);
        sChart.setHorizontalScrollBarEnabled(false);
        sChart.setVerticalScrollBarEnabled(false);
        sChart.setNoDataTextDescription(getText(R.string.no_data_text_description).toString());
        // XAxis parameters:
        XAxis xls = sChart.getXAxis();
        xls.setPosition(XAxis.XAxisPosition.BOTTOM);
        xls.setDrawAxisLine(true);
        xls.setDrawGridLines(false);
        xls.setDrawLabels(true);
        xls.setTextColor(Color.WHITE);
        xls.setAvoidFirstLastClipping(false);
        // YAxis parameters (left): main axis for dB values representation
        YAxis yls = sChart.getAxisLeft();
        yls.setDrawAxisLine(true);
        yls.setDrawGridLines(true);
        yls.setAxisMaxValue(100.f);
        yls.setAxisMinValue(0f);
        yls.setTextColor(Color.WHITE);
        yls.setGridColor(Color.WHITE);
        yls.setSpaceBottom(0);
        yls.setSpaceTop(0);
        yls.setValueFormatter(new SPLValueFormatter());
        // YAxis parameters (right): no axis, hide all
        YAxis yrs = sChart.getAxisRight();
        yrs.setEnabled(false);
    }
    return view;
}