You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pmf4n7i39/MPChartMarkerView.java

55 lines
1.7 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.example.yangenneng0.myapplication.viewUI;
import android.content.Context;
import com.example.yangenneng0.myapplication.R;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.CandleEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
public class MPChartMarkerView extends MarkerView {
private ArrowTextView tvContent;
/**
    * Constructor. Sets up the MarkerView with a custom layout resource.
    *
    * @param context
    * @param layoutResource the layout resource to use for the MarkerView
    */
public MPChartMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (ArrowTextView) findViewById(R.id.tvContent);
}
@Override
public void refreshContent(Entry e, Highlight highlight) {
if (e instanceof CandleEntry) {
CandleEntry ce = (CandleEntry) e;
tvContent.setText(StringUtils.double2String(ce.getHigh(), 2));
} else {
if (tvContent==null){}
else {
tvContent.setText(StringUtils.double2String(e.getY(), 2));
}
}
super.refreshContent(e, highlight);//必须加上该句话This sentence must be added.
}
private MPPointF mOffset;
@Override
public MPPointF getOffset() {
if(mOffset == null) {
// center the marker horizontally and vertically
mOffset = new MPPointF(-(getWidth() / 2), -getHeight());
}
return mOffset;
}
}