MPAndroidChart set center vertical line

前端 未结 3 587
我在风中等你
我在风中等你 2021-01-17 14:31

I want to set a vertical line in center of LineChart like this:

When scrolling to each point, it can notify to change the date below (

3条回答
  •  被撕碎了的回忆
    2021-01-17 14:56

    Take a look at the method

    protected void drawGridBackground(Canvas c) {
    

    in the BarLineChartBase class (parent for a LineChart). In that method you have all data to draw your line right in the middle. Something like this

    RectF rectF = mViewPortHandler.getContentRect();
    float xMiddle = (rectF.right - rectF.left)/2;
    Paint p = new Paint();
    p.setColor(Color.BLACK);
    c.drawLine(xMiddle, rectF.bottom, xMiddle, rectF.top, p);
    

提交回复
热议问题