Search in sources :

Example 36 with YAxis

use of com.github.mikephil.charting.components.YAxis in project open-event-orga-app by fossasia.

the class ChartAnalyser method showChart.

@SuppressFBWarnings(value = "ICAST_IDIV_CAST_TO_DOUBLE", justification = "We want granularity to be integer")
public void showChart(LineChart lineChart) {
    lineChart.setData(lineData);
    lineChart.getXAxis().setEnabled(false);
    lineChart.getAxisRight().setEnabled(false);
    lineChart.getDescription().setEnabled(false);
    YAxis yAxis = lineChart.getAxisLeft();
    yAxis.setGridLineWidth(1);
    yAxis.setGridColor(Color.parseColor("#992ecc71"));
    if (maxTicketSale > TICKET_SALE_THRESHOLD)
        yAxis.setGranularity(maxTicketSale / TICKET_SALE_THRESHOLD);
    lineChart.animateY(1000);
}
Also used : YAxis(com.github.mikephil.charting.components.YAxis) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 37 with YAxis

use of com.github.mikephil.charting.components.YAxis in project MPAndroidChart by PhilJay.

the class BarLineChartBase method init.

@Override
protected void init() {
    super.init();
    mAxisLeft = new YAxis(AxisDependency.LEFT);
    mAxisRight = new YAxis(AxisDependency.RIGHT);
    mLeftAxisTransformer = new Transformer(mViewPortHandler);
    mRightAxisTransformer = new Transformer(mViewPortHandler);
    mAxisRendererLeft = new YAxisRenderer(mViewPortHandler, mAxisLeft, mLeftAxisTransformer);
    mAxisRendererRight = new YAxisRenderer(mViewPortHandler, mAxisRight, mRightAxisTransformer);
    mXAxisRenderer = new XAxisRenderer(mViewPortHandler, mXAxis, mLeftAxisTransformer);
    setHighlighter(new ChartHighlighter(this));
    mChartTouchListener = new BarLineChartTouchListener(this, mViewPortHandler.getMatrixTouch(), 3f);
    mGridBackgroundPaint = new Paint();
    mGridBackgroundPaint.setStyle(Style.FILL);
    // mGridBackgroundPaint.setColor(Color.WHITE);
    // light
    mGridBackgroundPaint.setColor(Color.rgb(240, 240, 240));
    // grey
    mBorderPaint = new Paint();
    mBorderPaint.setStyle(Style.STROKE);
    mBorderPaint.setColor(Color.BLACK);
    mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
}
Also used : Transformer(com.github.mikephil.charting.utils.Transformer) ChartHighlighter(com.github.mikephil.charting.highlight.ChartHighlighter) YAxisRenderer(com.github.mikephil.charting.renderer.YAxisRenderer) Paint(android.graphics.Paint) XAxisRenderer(com.github.mikephil.charting.renderer.XAxisRenderer) YAxis(com.github.mikephil.charting.components.YAxis) BarLineChartTouchListener(com.github.mikephil.charting.listener.BarLineChartTouchListener)

Example 38 with YAxis

use of com.github.mikephil.charting.components.YAxis in project MPAndroidChart by PhilJay.

the class SineCosineFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_line, container, false);
    chart = v.findViewById(R.id.lineChart1);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setData(generateLineData());
    chart.animateX(3000);
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
    Legend l = chart.getLegend();
    l.setTypeface(tf);
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setTypeface(tf);
    leftAxis.setAxisMaximum(1.2f);
    leftAxis.setAxisMinimum(-1.2f);
    chart.getAxisRight().setEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setEnabled(false);
    return v;
}
Also used : Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) View(android.view.View) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 39 with YAxis

use of com.github.mikephil.charting.components.YAxis in project MPAndroidChart by PhilJay.

the class BarChartFrag method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
    // create a new chart object
    chart = new BarChart(getActivity());
    chart.getDescription().setEnabled(false);
    chart.setOnChartGestureListener(this);
    MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
    // For bounds control
    mv.setChartView(chart);
    chart.setMarker(mv);
    chart.setDrawGridBackground(false);
    chart.setDrawBarShadow(false);
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
    chart.setData(generateBarData(1, 20000, 12));
    Legend l = chart.getLegend();
    l.setTypeface(tf);
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setTypeface(tf);
    // this replaces setStartAtZero(true)
    leftAxis.setAxisMinimum(0f);
    chart.getAxisRight().setEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setEnabled(false);
    // programmatically add the chart
    FrameLayout parent = v.findViewById(R.id.parentLayout);
    parent.addView(chart);
    return v;
}
Also used : Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) FrameLayout(android.widget.FrameLayout) BarChart(com.github.mikephil.charting.charts.BarChart) View(android.view.View) MyMarkerView(com.xxmassdeveloper.mpchartexample.custom.MyMarkerView) MyMarkerView(com.xxmassdeveloper.mpchartexample.custom.MyMarkerView) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 40 with YAxis

use of com.github.mikephil.charting.components.YAxis in project MPAndroidChart by PhilJay.

the class BarChartItem method getView.

@SuppressLint("InflateParams")
@Override
public View getView(int position, View convertView, Context c) {
    ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(c).inflate(R.layout.list_item_barchart, null);
        holder.chart = convertView.findViewById(R.id.chart);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    // apply styling
    holder.chart.getDescription().setEnabled(false);
    holder.chart.setDrawGridBackground(false);
    holder.chart.setDrawBarShadow(false);
    XAxis xAxis = holder.chart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(true);
    YAxis leftAxis = holder.chart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(5, false);
    leftAxis.setSpaceTop(20f);
    // this replaces setStartAtZero(true)
    leftAxis.setAxisMinimum(0f);
    YAxis rightAxis = holder.chart.getAxisRight();
    rightAxis.setTypeface(mTf);
    rightAxis.setLabelCount(5, false);
    rightAxis.setSpaceTop(20f);
    // this replaces setStartAtZero(true)
    rightAxis.setAxisMinimum(0f);
    mChartData.setValueTypeface(mTf);
    // set data
    holder.chart.setData((BarData) mChartData);
    holder.chart.setFitBars(true);
    // do not forget to refresh the chart
    // holder.chart.invalidate();
    holder.chart.animateY(700);
    return convertView;
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis) SuppressLint(android.annotation.SuppressLint)

Aggregations

YAxis (com.github.mikephil.charting.components.YAxis)51 XAxis (com.github.mikephil.charting.components.XAxis)45 Legend (com.github.mikephil.charting.components.Legend)22 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)11 AxisBase (com.github.mikephil.charting.components.AxisBase)10 LineData (com.github.mikephil.charting.data.LineData)8 LineDataSet (com.github.mikephil.charting.data.LineDataSet)7 XFormatter (com.a5corp.weather.utils.XFormatter)5 Entry (com.github.mikephil.charting.data.Entry)5 MyMarkerView (com.xxmassdeveloper.mpchartexample.custom.MyMarkerView)5 ArrayList (java.util.ArrayList)5 Typeface (android.graphics.Typeface)4 View (android.view.View)4 OsmandSettings (net.osmand.plus.OsmandSettings)4 SuppressLint (android.annotation.SuppressLint)3 Paint (android.graphics.Paint)3 SpannableString (android.text.SpannableString)3 LimitLine (com.github.mikephil.charting.components.LimitLine)3 MarkerView (com.github.mikephil.charting.components.MarkerView)2 YAxisRenderer (com.github.mikephil.charting.renderer.YAxisRenderer)2