How can I draw a circle on highlight point in line chart?

前端 未结 1 880
粉色の甜心
粉色の甜心 2021-01-01 03:15

I\'m using mpchart to draw my charts.I wanted to increase the circle size of intersection point of highlighter and line dataset. How can I achieve this?

I read somew

相关标签:
1条回答
  • 2021-01-01 03:36

    When using the MpChart Library, the library contains a MarkerView class that helps us to insert the markers for displaying the selected value in the chart. We can use this MarkerView class to display any kind of view for the selected chart data.

    So for the dot I created a new ChartMarker class and extended MarkerView class. Then in the constructor I passed the layout containing an image view with the dot as the src to the super.

    public ChartMarker(Context context) {
        //the super will take care of displaying the layout
        super(context, R.layout.layout_dot);
    }
    

    Finally set the ChartMarker instance to the chart through chart.setMarkerView()

    ChartMarker elevationMarker = new ChartMarker(getActivity());
    elevationChart.setMarkerView(elevationMarker);
    

    And for the layout_dot.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    
    <ImageView
        android:background="@drawable/dot"
        android:layout_width="5dp"
        android:layout_height="5dp" />
    
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题