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);
}
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));
}
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;
}
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;
}
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;
}
Aggregations