1
マーカービューの折れ線グラフにx軸値を表示する方法getVal()関数を使用してy軸値を取得しましたが、マーカービューでx軸値を取得する方法。マーカービューの私のコードです。折れ線グラフのマーカービューに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 ..itのようなxの値を取得しますMPAndroidChart 2.4.4で私の問題を解決しました。 –
もう1つ質問私は質問したかった..私はグラフの中に私のマーカービューを配置するdraw()メソッドを使用しました。しかし、上記のコードで私は "posx"(65と350)私のチャートのマーカービュー。これは私のモバイル画面の肖像画のビューのために働いた。しかし、右から同様にマーカービューの固定距離を持つすべてのアンドロイド画面のために働くように "posx"値を設定する方法....私は "draw"メソッドで自分のposx値に変更する必要があります。 –