Как показать значения оси X в линейной диаграмме в представлении маркера. Я использовал функцию getVal() для получения значений оси y, но как получить значения оси x в представлении маркера. Below это мой код для просмотра маркера.Как показать метки X в виде маркера в линейной диаграмме?
public class MymarkerView extends MarkerView
{
private TextView indices;
public MymarkerView(Context context, int layoutResource) {
super(context, layoutResource);
indices = (TextView) findViewById(R.id.indices);
}
// callbacks everytime the MarkerView is redrawn, can be used to update the
// content (user-interface)
@Override
public void refreshContent(Entry e, Highlight highlight) {
indices.setText("Indices:" +e.getVal());
}
@Override
public int getXOffset(float xpos) {
// this will center the marker-view horizontally
return -(getWidth()/2);
}
@Override
public int getYOffset(float ypos) {
// this will cause the marker-view to be above the selected value
return -getHeight();
}
public void draw(Canvas canvas, float posx, float posy)
{
// take offsets into consideration
posx += getXOffset(posx);
posy=0;
// AVOID OFFSCREEN
if(posx<65)
posx=65;
if(posx>350)
posx=350;
// translate to the correct position and draw
canvas.translate(posx, posy);
draw(canvas);
canvas.translate(-posx, -posy);
}
}
Благодаря @Madhu ..Это решил мою проблему с MPAndroidChart 2.4.4. –
Еще один вопрос, который я хотел задать. Я использовал метод draw(), чтобы расположить маркерный вид внутри диаграммы. Но в приведенном выше коде я использовал определенное значение «posx» (65 и 350), чтобы зафиксировать положение markerview для моей диаграммы. Это работало для портретного вида моего мобильного экрана. Но как установить значение «posx» для работы на всем экране Android с фиксированным расстоянием просмотра маркера слева и справа .... Что изменения должны я сделать для моего значения posx в методе «draw». –