Java Code Examples for com.github.mikephil.charting.components.YAxis#setDrawAxisLine()

The following examples show how to use com.github.mikephil.charting.components.YAxis#setDrawAxisLine() . 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: TestSuiteFragment.java    From SQLite-Performance with The Unlicense 5 votes vote down vote up
private void setupYAxes(BarLineChartBase chart) {
    YAxis y = chart.getAxisLeft();
    y.setDrawZeroLine(true);
    y.setDrawLabels(false);
    y.setDrawGridLines(false);
    y.setDrawAxisLine(false);
    y.setAxisMinimum(0);
    y = chart.getAxisRight();
    y.setDrawZeroLine(true);
    y.setDrawLabels(false);
    y.setDrawGridLines(false);
    y.setDrawAxisLine(false);
    y.setAxisMinimum(0);
}
 
Example 2
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 3
Source File: RecordingsAdapter.java    From go-bees with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Setup chart (axis, grid, etc.).
 *
 * @param lineChart      chart to setup.
 * @param data           chart with the data.
 * @param firstTimestamp seconds timestamp of the first record (used as initial reference).
 */
private void setupChart(LineChart lineChart, LineData data, long firstTimestamp) {
    // General setup
    lineChart.setDrawGridBackground(false);
    lineChart.setDrawBorders(false);
    lineChart.setViewPortOffsets(50, 0, 50, 50);
    lineChart.getDescription().setEnabled(false);
    lineChart.getLegend().setEnabled(false);
    lineChart.setTouchEnabled(false);
    lineChart.setNoDataText(context.getString(R.string.no_flight_act_data_available));
    // X axis setup
    IAxisValueFormatter xAxisFormatter = new HourAxisValueFormatter(firstTimestamp);
    XAxis xAxis = lineChart.getXAxis();
    xAxis.setValueFormatter(xAxisFormatter);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setCenterAxisLabels(false);
    xAxis.setTextColor(ContextCompat.getColor(context, R.color.colorIcons));
    // Y axis setup
    YAxis yAxis = lineChart.getAxisLeft();
    yAxis.setAxisMaximum(40);
    yAxis.setAxisMinimum(0);
    yAxis.setDrawLabels(false);
    yAxis.setDrawAxisLine(false);
    yAxis.setDrawGridLines(true);
    lineChart.getAxisRight().setEnabled(false);
    // Add data
    lineChart.setData(data);
}
 
Example 4
Source File: TrafficFragment.java    From gito-github-client with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
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 6
Source File: ModelDetailActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
private void prepareChart() {
    mChart.setTouchEnabled(true);
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setPinchZoom(true);
    mChart.setHighlightPerTapEnabled(true);
    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setHighlightPerDragEnabled(false);

    mChart.getDescription().setEnabled(false);
    mChart.setDrawGridBackground(false);
    mChart.getLegend().setEnabled(true);
    mChart.getAxisRight().setEnabled(false);
    mChart.setMarker(new AMarkView(this, R.layout.ac_detail_mark_view));

    final YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTextColor(ContextCompat.getColor(this, R.color.text_primary));
    leftAxis.setAxisMaximum(1F);
    leftAxis.setDrawGridLines(false);
    leftAxis.setDrawAxisLine(true);

    final LimitLine upLine = new LimitLine(0.9F, "Great");
    upLine.setLineWidth(2F);
    upLine.enableDashedLine(10F, 10F, 10F);
    upLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_TOP);
    upLine.setLineColor(ContextCompat.getColor(this, R.color.divider));
    upLine.setTextColor(ContextCompat.getColor(this, R.color.green$1));

    final LimitLine downLine = new LimitLine(0.5F, "Bad");
    downLine.setLineWidth(2F);
    downLine.enableDashedLine(10F, 10F, 10F);
    downLine.setLabelPosition(LimitLine.LimitLabelPosition.RIGHT_BOTTOM);
    downLine.setLineColor(ContextCompat.getColor(this, R.color.divider));
    downLine.setTextColor(ContextCompat.getColor(this, R.color.pink_$1));

    leftAxis.addLimitLine(upLine);
    leftAxis.addLimitLine(downLine);
}
 
Example 7
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 8
Source File: FragmentBarChart.java    From fingen with Apache License 2.0 5 votes vote down vote up
private void setupBarChart() {
    mBarChart.setDrawBarShadow(false);
    mBarChart.setDrawValueAboveBar(true);
    mBarChart.setDescription("");
    mBarChart.setMaxVisibleValueCount(Integer.MAX_VALUE);
    mBarChart.setPinchZoom(false);
    mBarChart.setDrawGridBackground(false);
    mBarChart.setOnChartValueSelectedListener(this);
    mBarChart.setHighlightPerDragEnabled(false);

    int textColor = ColorUtils.getTextColor(getActivity());

    XAxis xl = mBarChart.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
    xl.setDrawAxisLine(true);
    xl.setDrawGridLines(true);
    xl.setGridLineWidth(0.3f);
    xl.setTextColor(textColor);

    YAxis yl = mBarChart.getAxisLeft();
    yl.setDrawAxisLine(true);
    yl.setDrawGridLines(true);
    yl.setGridLineWidth(0.3f);
    yl.setAxisMinValue(0f);
    yl.setTextColor(textColor);

    YAxis yr = mBarChart.getAxisRight();
    yr.setDrawAxisLine(true);
    yr.setDrawGridLines(false);
    yr.setAxisMinValue(0f);
    yr.setTextColor(textColor);

    mBarChart.setXAxisRenderer(new FgHorizontalBarChartRenderer(getActivity(), mBarChart.getViewPortHandler(),
            mBarChart.getXAxis(), mBarChart.getTransformer(YAxis.AxisDependency.LEFT), mBarChart));
    mBarChart.getLegend().setEnabled(false);
}
 
Example 9
Source File: FragmentTimeBarChart.java    From fingen with Apache License 2.0 5 votes vote down vote up
private void setupBarChart() {
    mBarChart.setDrawBarShadow(false);
    mBarChart.setDrawValueAboveBar(true);
    mBarChart.setDescription("");
    mBarChart.setMaxVisibleValueCount(Integer.MAX_VALUE);
    mBarChart.setPinchZoom(false);
    mBarChart.setDrawGridBackground(false);
    mBarChart.setOnChartValueSelectedListener(this);
    mBarChart.setHighlightPerDragEnabled(false);

    int textColor = ColorUtils.getTextColor(getActivity());

    XAxis xl = mBarChart.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
    xl.setDrawAxisLine(true);
    xl.setDrawGridLines(true);
    xl.setGridLineWidth(0.3f);
    xl.setTextColor(textColor);

    YAxis yl = mBarChart.getAxisLeft();
    yl.setDrawAxisLine(true);
    yl.setDrawGridLines(true);
    yl.setGridLineWidth(0.3f);
    yl.setAxisMinValue(0f);
    yl.setTextColor(textColor);

    YAxis yr = mBarChart.getAxisRight();
    yr.setDrawAxisLine(true);
    yr.setDrawGridLines(false);
    yr.setAxisMinValue(0f);
    yr.setTextColor(textColor);

    mBarChart.setXAxisRenderer(new FgHorizontalBarChartRenderer(getActivity(), mBarChart.getViewPortHandler(),
            mBarChart.getXAxis(), mBarChart.getTransformer(YAxis.AxisDependency.LEFT), mBarChart));
    mBarChart.getLegend().setEnabled(false);
}
 
Example 10
Source File: HorizontalBarChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_horizontalbarchart);

        setTitle("HorizontalBarChartActivity");

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

        seekBarX = findViewById(R.id.seekBar1);
        seekBarY = findViewById(R.id.seekBar2);

        seekBarY.setOnSeekBarChangeListener(this);
        seekBarX.setOnSeekBarChangeListener(this);

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

        chart.setDrawBarShadow(false);

        chart.setDrawValueAboveBar(true);

        chart.getDescription().setEnabled(false);

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

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

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

        chart.setDrawGridBackground(false);

        XAxis xl = chart.getXAxis();
        xl.setPosition(XAxisPosition.BOTTOM);
        xl.setTypeface(tfLight);
        xl.setDrawAxisLine(true);
        xl.setDrawGridLines(false);
        xl.setGranularity(10f);

        YAxis yl = chart.getAxisLeft();
        yl.setTypeface(tfLight);
        yl.setDrawAxisLine(true);
        yl.setDrawGridLines(true);
        yl.setAxisMinimum(0f); // this replaces setStartAtZero(true)
//        yl.setInverted(true);

        YAxis yr = chart.getAxisRight();
        yr.setTypeface(tfLight);
        yr.setDrawAxisLine(true);
        yr.setDrawGridLines(false);
        yr.setAxisMinimum(0f); // this replaces setStartAtZero(true)
//        yr.setInverted(true);

        chart.setFitBars(true);
        chart.animateY(2500);

        // setting data
        seekBarY.setProgress(50);
        seekBarX.setProgress(12);

        Legend l = chart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);
        l.setFormSize(8f);
        l.setXEntrySpace(4f);
    }
 
Example 11
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 12
Source File: CandleStickChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_candlechart);

        setTitle("CandleStickChartActivity");

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

        seekBarX = findViewById(R.id.seekBar1);
        seekBarX.setOnSeekBarChangeListener(this);

        seekBarY = findViewById(R.id.seekBar2);
        seekBarY.setOnSeekBarChangeListener(this);

        chart = findViewById(R.id.chart1);
        chart.setBackgroundColor(Color.WHITE);

        chart.getDescription().setEnabled(false);

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

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

        chart.setDrawGridBackground(false);

        XAxis xAxis = chart.getXAxis();
        xAxis.setPosition(XAxisPosition.BOTTOM);
        xAxis.setDrawGridLines(false);

        YAxis leftAxis = chart.getAxisLeft();
//        leftAxis.setEnabled(false);
        leftAxis.setLabelCount(7, false);
        leftAxis.setDrawGridLines(false);
        leftAxis.setDrawAxisLine(false);

        YAxis rightAxis = chart.getAxisRight();
        rightAxis.setEnabled(false);
//        rightAxis.setStartAtZero(false);

        // setting data
        seekBarX.setProgress(40);
        seekBarY.setProgress(100);

        chart.getLegend().setEnabled(false);
    }
 
Example 13
Source File: QuotationFragment.java    From bitshares_wallet with MIT License 4 votes vote down vote up
private void initChart() {
    int colorHomeBg = getResources().getColor(android.R.color.transparent);
    int colorLine = getResources().getColor(R.color.common_divider);
    int colorText = getResources().getColor(R.color.text_grey_light);

    mChart.setDescription(null);
    mChart.setDrawGridBackground(true);
    mChart.setBackgroundColor(colorHomeBg);
    mChart.setGridBackgroundColor(colorHomeBg);
    mChart.setScaleYEnabled(false);
    mChart.setPinchZoom(true);

    mChart.setNoDataText(getString(R.string.main_activity_loading));
    mChart.setAutoScaleMinMaxEnabled(true);
    mChart.setDragEnabled(true);
    mChart.setDoubleTapToZoomEnabled(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawGridLines(true);
    xAxis.setGridColor(colorLine);
    xAxis.setTextColor(colorText);
    xAxis.setLabelCount(3);
    //xAxis.setSpaceBetweenLabels(4);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setLabelCount(4, false);
    leftAxis.setDrawGridLines(true);
    leftAxis.setDrawAxisLine(true);
    leftAxis.setGridColor(colorLine);
    leftAxis.setTextColor(colorText);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setTextSize(8);
    rightAxis.setLabelCount(5, false);
    rightAxis.setDrawGridLines(false);
    rightAxis.setDrawAxisLine(true);
    rightAxis.setGridColor(colorLine);
    rightAxis.setTextColor(colorText);
    rightAxis.setAxisMinimum(0);
}
 
Example 14
Source File: BarChartPositiveNegative.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_barchart_noseekbar);

    mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    mChart = (BarChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setExtraTopOffset(-30f);
    mChart.setExtraBottomOffset(10f);
    mChart.setExtraLeftOffset(70f);
    mChart.setExtraRightOffset(70f);

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

    mChart.setDescription("");

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

    mChart.setDrawGridBackground(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setSpaceBetweenLabels(2);
    xAxis.setTextColor(Color.LTGRAY);
    xAxis.setTextSize(13f);

    YAxis left = mChart.getAxisLeft();
    left.setDrawLabels(false);
    left.setStartAtZero(false);
    left.setSpaceTop(25f);
    left.setSpaceBottom(25f);
    left.setDrawAxisLine(false);
    left.setDrawGridLines(false);
    left.setDrawZeroLine(true); // draw a zero line
    left.setZeroLineColor(Color.GRAY);
    left.setZeroLineWidth(0.7f);
    mChart.getAxisRight().setEnabled(false);
    mChart.getLegend().setEnabled(false);

    // THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
    List<Data> data = new ArrayList<>();
    data.add(new Data(0, -224.1f, "12-29"));
    data.add(new Data(1, 238.5f, "12-30"));
    data.add(new Data(2, 1280.1f, "12-31"));
    data.add(new Data(3, -442.3f, "01-01"));
    data.add(new Data(4, -2280.1f, "01-02"));

    setData(data);
}
 
Example 15
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;
}
 
Example 16
Source File: HorizontalBarChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_horizontalbarchart);

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

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

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

        mChart.setDrawBarShadow(false);

        mChart.setDrawValueAboveBar(true);

        mChart.setDescription("");

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

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

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

        // mChart.setDrawXLabels(false);

        mChart.setDrawGridBackground(false);

        // mChart.setDrawYLabels(false);

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

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

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

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

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

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

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

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

        // mChart.setDrawLegend(false);
    }
 
Example 17
Source File: FilledLineActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@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);

    setTitle("FilledLineActivity");

    chart = findViewById(R.id.chart1);
    chart.setBackgroundColor(Color.WHITE);
    chart.setGridBackgroundColor(fillColor);
    chart.setDrawGridBackground(true);

    chart.setDrawBorders(true);

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

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

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

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

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

    chart.getAxisRight().setEnabled(false);

    // add data
    setData(100, 60);

    chart.invalidate();
}
 
Example 18
Source File: RecordingFragment.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Configure bees chart and the data.
 *
 * @param recordsList list of records.
 */
private void setupBeesChart(List<Record> recordsList) {
    // Setup data
    referenceTimestamp = recordsList.get(0).getTimestamp().getTime() / 1000;
    Record[] records = recordsList.toArray(new Record[recordsList.size()]);
    List<Entry> entries = new ArrayList<>();
    int maxNumBees = 0;
    for (Record record : records) {
        // Convert timestamp to seconds and relative to first timestamp
        long timestamp = record.getTimestamp().getTime() / 1000 - referenceTimestamp;
        int numBees = record.getNumBees();
        entries.add(new Entry(timestamp, numBees));
        // Get max num of bees
        if (numBees > maxNumBees) {
            maxNumBees = numBees;
        }
    }
    lastTimestamp = (long) entries.get(entries.size() - 1).getX();
    // Style char lines (type, color, etc.)
    LineDataSet lineDataSet = new LineDataSet(entries, getString(R.string.num_bees));
    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    lineDataSet.setCubicIntensity(0.2f);
    lineDataSet.setDrawValues(false);
    lineDataSet.setDrawCircles(false);
    lineDataSet.setLineWidth(1.8f);
    lineDataSet.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
    // General setup
    beesChart.setDrawGridBackground(false);
    beesChart.setDrawBorders(false);
    beesChart.setViewPortOffsets(80, 40, 80, 50);
    beesChart.getDescription().setEnabled(false);
    beesChart.getLegend().setEnabled(false);
    beesChart.setTouchEnabled(true);
    beesChart.setDragEnabled(false);
    beesChart.setScaleEnabled(false);
    beesChart.setPinchZoom(false);
    BeesMarkerView mv = new BeesMarkerView(getContext(), R.layout.recording_bees_marker_vew);
    mv.setChartView(beesChart);
    beesChart.setMarker(mv);
    beesChart.setNoDataText(getString(R.string.no_flight_act_data_available));
    // X axis setup
    IAxisValueFormatter xAxisFormatter = new HourAxisValueFormatter(referenceTimestamp);
    XAxis xAxis = beesChart.getXAxis();
    xAxis.setValueFormatter(xAxisFormatter);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(Color.BLACK);
    // Y axis setup
    YAxis leftAxis = beesChart.getAxisLeft();
    leftAxis.setAxisMaximum(maxNumBees > 40 ? maxNumBees + 2 : 40);
    leftAxis.setAxisMinimum(0);
    leftAxis.setDrawGridLines(true);
    leftAxis.setDrawAxisLine(false);
    YAxis rightAxis = beesChart.getAxisRight();
    rightAxis.setAxisMaximum(maxNumBees > 40 ? maxNumBees + 2 : 40);
    rightAxis.setAxisMinimum(0);
    rightAxis.setDrawGridLines(true);
    rightAxis.setDrawAxisLine(false);
    // Add data
    beesChart.setData(new LineData(lineDataSet));
}
 
Example 19
Source File: LineChartCard.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
private void initializeViews() {
    titleTextView = (TextView) findViewById(R.id.view_chart_line_title);
    titleTextView.setText(titleText);
    titleTextView.setTextColor(titleTextColor);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
    titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));

    expand = (ImageView) findViewById(R.id.view_chart_line_expand);
    if (expandTintColor != 0) {
        Drawable drawable = expand.getDrawable();
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, expandTintColor);
        expand.setImageDrawable(drawable);
    }

    chart = (LineChart) findViewById(R.id.view_chart_line);
    chart.getLegend().setEnabled(false);
    chart.setDescription("");
    chart.setDrawBorders(false);
    chart.setDrawGridBackground(false);
    chart.setPinchZoom(false);
    chart.setTouchEnabled(true);
    chart.setDragEnabled(true);
    chart.setExtraLeftOffset(0);
    chart.setExtraBottomOffset(8);
    chart.setExtraTopOffset(0);

    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(false);
    xAxis.setLabelsToSkip(0);
    xAxis.setXOffset(16);
    xAxis.setTextSize(chartXAxisTextSize);
    xAxis.setTextColor(chartXAxisTextColor);
    xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL));

    YAxis yAxisLeft = chart.getAxisLeft();
    yAxisLeft.setDrawAxisLine(false);
    yAxisLeft.setDrawGridLines(false);
    yAxisLeft.setDrawZeroLine(false);
    yAxisLeft.setDrawLabels(true);
    yAxisLeft.setShowOnlyMinMax(true);
    yAxisLeft.setXOffset(16);
    yAxisLeft.setTextSize(chartYAxisTextSize);
    yAxisLeft.setTextColor(chartYAxisTextColor);
    yAxisLeft.setTypeface(Typeface.create(chartYAxisTextTypeface, Typeface.NORMAL));

    YAxis yAxisRight = chart.getAxisRight();
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawZeroLine(false);
    yAxisRight.setDrawLabels(false);
    yAxisRight.setSpaceTop(0);
}
 
Example 20
Source File: BarChartCard.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
private void initializeViews() {
    titleTextView = (TextView) findViewById(R.id.view_chart_bar_title);
    titleTextView.setText(titleText);
    titleTextView.setTextColor(titleTextColor);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
    titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));

    expand = (ImageView) findViewById(R.id.view_chart_line_expand);
    if (expandTintColor != 0) {
        Drawable drawable = expand.getDrawable();
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, expandTintColor);
        expand.setImageDrawable(drawable);
    }

    chart = (BarChart) findViewById(R.id.view_chart_bar);
    chart.getLegend().setEnabled(false);
    chart.setDescription("");
    chart.setDrawBorders(false);
    chart.setDrawValueAboveBar(false);
    chart.setDrawGridBackground(false);
    chart.setDrawBarShadow(false);
    chart.setDrawHighlightArrow(false);
    chart.setPinchZoom(false);
    chart.setExtraLeftOffset(0);
    chart.setExtraRightOffset(0);
    chart.setExtraBottomOffset(8);
    chart.setExtraTopOffset(0);
    chart.setTouchEnabled(true);
    chart.setDragEnabled(true);

    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawAxisLine(false);
    xAxis.setYOffset(16);
    xAxis.setDrawGridLines(false);
    xAxis.setLabelsToSkip(0);
    xAxis.setTextSize(chartXAxisTextSize);
    xAxis.setTextColor(chartXAxisTextColor);
    xAxis.setTypeface(Typeface.create(chartXAxisTextTypeface, Typeface.NORMAL));

    YAxis yAxisLeft = chart.getAxisLeft();
    yAxisLeft.setDrawAxisLine(false);
    yAxisLeft.setDrawGridLines(false);
    yAxisLeft.setDrawZeroLine(false);
    yAxisLeft.setDrawLabels(false);

    YAxis yAxisRight = chart.getAxisRight();
    yAxisRight.setDrawAxisLine(false);
    yAxisRight.setDrawGridLines(false);
    yAxisRight.setDrawZeroLine(false);
    yAxisRight.setDrawLabels(false);
}