One way I could think of achieving 2 markers in the same dataset is by creating a custom class implementing IMarker and setting up 2 separate layouts in it.
MarkerView2.java:
public MarkerView2(Context context, int layoutResource, int layoutResource2) {
super(context);
setupLayoutResource(layoutResource);
setupLayoutResource2(layoutResource2);
}
private void setupLayoutResource(int layoutResource) {
// Default usual code..
}
private void setupLayoutResource2(int layoutResource2) {
// Default usual code..
}
Passing both the marker layouts by calling super in the CustomMarkerView2.java:
public class CustomMarkerView2 extends MarkerView2 {
public CustomMarkerView2(Context context, int layoutResource, int layoutResource2) {
super(context, layoutResource, layoutResource2);
}
// Rest of the usual implementations..
}
In the fragment where the LineChart is being set:
CustomMarkerView2 customMarkerView2 = new CustomMarkerView2(view.getContext(), R.layout.custom_marker_view2, R.layout.custom_marker_view);
lineChart.setMarker(customMarkerView2);
Before this, I created 2 separate Implementations of IMarker but only one marker was being set in the chart so I did what I've outlined above.
I am also providing an image which depicts where I am currently at and what I'm trying to achieve. I want the Dot-Icon to be drawn on the value being intersected by the vertical highlighter and the Description-Icon to be drawn on the top.
I was able to set either the Dot-Icon or the Desc-Icon correctly by using the default provided MarkerView class by adjusting return new MPPointF(-(getWidth() / 2f), -getHeight()); in the getOffset() function, but cannot align both of them accordingly using my own custom MarkerView2.
