AnyChart trying to show 2 line charts on an activity





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















hey everyone so i am trying to display 2 line charts on an activity i am using AnyChart when i change my code to display only 1 chart it works but when i add the second one only that one displays and the first one is gone.



this is the activity



public class DetailedFieldActivity extends AppCompatActivity {



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detailed_field);

Intent intentData = getIntent();
String FieldName = intentData.getStringExtra("field");

setTitle(FieldName);


prepareGraphTop();
prepareGraphBot();
}

public void prepareGraphTop() {

Intent graphsIntent = getIntent();
String response = graphsIntent.getStringExtra("response");


AnyChartView top = findViewById(R.id.top_soil);
top.setProgressBar(findViewById(R.id.progress_bar));

Cartesian topChartData = AnyChart.line();

topChartData.animation(true);

topChartData.padding(5d, 10d, 3d, 10d);

topChartData.xAxis(0).scale();
topChartData.xScroller(true).container();

topChartData.crosshair().enabled(true);
topChartData.crosshair()
.yLabel(true)
.yStroke((Stroke) null, null, null, (String) null, (String) null);

topChartData.tooltip().positionMode(TooltipPositionMode.POINT);

topChartData.title("Top Soil (0 - 400mm)");

topChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

final List<DataEntry> seriesDataTop = new ArrayList<>();

try {

JSONObject jsonResponse = new JSONObject(response);
JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

JSONArray dates = graphs.names();

for (int i = 3; i < graphs.length(); i++) {

String dateName = dates.getString(i);

JSONObject dateData = graphs.getJSONObject(dateName);

Number topSoil = dateData.getInt("TB");
Number bb = dateData.getInt("BB");
Number stressBo = dateData.getInt("stress");
Number verwelpBo = dateData.getInt("verwelp");

seriesDataTop.add(new CustomDataTop(dateName, topSoil, bb, stressBo));
}

} catch (JSONException e) {
e.printStackTrace();
}

Set setTop = Set.instantiate();
setTop.data(seriesDataTop);
Mapping seriesTopMapping1 = setTop.mapAs("{ x: 'x', value: 'value' }");
Mapping seriesTopMapping2 = setTop.mapAs("{ x: 'x', value: 'value2' }");
Mapping seriesTopMapping3 = setTop.mapAs("{ x: 'x', value: 'value3' }");

Line seriesTop1 = topChartData.line(seriesTopMapping1);
seriesTop1.name("TB");
seriesTop1.hovered().markers().enabled(true);
seriesTop1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
seriesTop1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);

Line seriesTop2 = topChartData.line(seriesTopMapping2);
seriesTop2.name("TO");
seriesTop2.hovered().markers().enabled(true);
seriesTop2.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
seriesTop2.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);

Line seriesTop3 = topChartData.line(seriesTopMapping3);
seriesTop3.name("Stress Bo");
seriesTop3.hovered().markers().enabled(true);
seriesTop3.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
seriesTop3.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);

topChartData.legend().enabled(true);
topChartData.legend().fontSize(13d);
topChartData.legend().padding(0d, 0d, 10d, 0d);

top.setChart(topChartData);
}

public void prepareGraphBot() {

Intent graphsIntent = getIntent();
String response = graphsIntent.getStringExtra("response");

AnyChartView bottom = findViewById(R.id.bottom_soil);
bottom.setProgressBar(findViewById(R.id.progress_bar));

Cartesian botChartData = AnyChart.line();

botChartData.animation(true);

botChartData.padding(5d, 10d, 3d, 10d);

botChartData.xAxis(0).scale();
botChartData.xScroller(true).container();

botChartData.crosshair().enabled(true);
botChartData.crosshair()
.yLabel(true)
.yStroke((Stroke) null, null, null, (String) null, (String) null);

botChartData.tooltip().positionMode(TooltipPositionMode.POINT);

botChartData.title("Bottom Soil (400 - 800mm)");

botChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

final List<DataEntry> seriesDataBot = new ArrayList<>();

try {

JSONObject jsonResponse = new JSONObject(response);
JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

JSONArray dates = graphs.names();

for (int i = 3; i < graphs.length(); i++) {

String dateName = dates.getString(i);

JSONObject dateData = graphs.getJSONObject(dateName);

Number botSoil = dateData.getInt("TO");
Number bo = dateData.getInt("BO");
Number stressOnder = dateData.getInt("stressonder");
Number verwelpOnder = dateData.getInt("verwelponder");
Number pvrOnder = dateData.getInt("pvronder");

seriesDataBot.add(new CustomDataBot(dateName, botSoil, bo, stressOnder));
}

} catch (JSONException e) {
e.printStackTrace();
}

Set setBot = Set.instantiate();
setBot.data(seriesDataBot);
Mapping seriesBotMapping1 = setBot.mapAs("{ x: 'r', value: 'value12' }");
Mapping seriesBotMapping2 = setBot.mapAs("{ x: 'r', value: 'value22' }");
Mapping seriesBotMapping3 = setBot.mapAs("{ x: 'r', value: 'value32' }");

Line seriesBot1 = botChartData.line(seriesBotMapping1);
seriesBot1.name("TO");
seriesBot1.hovered().markers().enabled(true);
seriesBot1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
seriesBot1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);

Line seriesBot2 = botChartData.line(seriesBotMapping2);
seriesBot2.name("BO");
seriesBot2.hovered().markers().enabled(true);
seriesBot2.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
seriesBot2.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);

Line seriesBot3 = botChartData.line(seriesBotMapping3);
seriesBot3.name("Stress Onder");
seriesBot3.hovered().markers().enabled(true);
seriesBot3.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
seriesBot3.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);

botChartData.legend().enabled(true);
botChartData.legend().fontSize(13d);
botChartData.legend().padding(0d, 0d, 10d, 0d);

bottom.setChart(botChartData);
}

private class CustomDataTop extends ValueDataEntry {

CustomDataTop(String x, Number value, Number value2, Number value3) {
super(x, value);
setValue("value2", value2);
setValue("value3", value3);
}
}

private class CustomDataBot extends ValueDataEntry {

CustomDataBot(String r, Number value12, Number value22, Number value32) {
super(r, value12);
setValue("value22", value22);
setValue("value32", value32);
}

}


}



And this is my xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".DetailedFieldActivity">

<com.anychart.AnyChartView
android:id="@+id/top_soil"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="0dp"
android:layout_marginTop="49dp"
android:layout_marginEnd="0dp">

</com.anychart.AnyChartView>

<com.anychart.AnyChartView
android:id="@+id/bottom_soil"
android:layout_width="match_parent"
android:layout_height="201dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="0dp"
android:layout_marginBottom="50dp">

</com.anychart.AnyChartView>

<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="278dp"
android:layout_height="189dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginStart="53dp"
android:layout_marginTop="159dp"
android:layout_marginEnd="53dp"
android:layout_marginBottom="163dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/top_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="@android:color/transparent"
android:text="Top Bototm Soil" />

<Button
android:id="@+id/depths"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:layout_above="@+id/top_soil"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:background="@android:color/transparent"
android:text="Depths" />

<Button
android:id="@+id/soil_temps"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="0dp"
android:background="@android:color/transparent"
android:text="Soil Temps" />

<Button
android:id="@+id/photo"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@android:color/transparent"
android:text="Photos" />

<Button
android:id="@+id/moisture"
android:layout_width="121dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:background="@android:color/transparent"
android:text="Moisture" />

<Button
android:id="@+id/irrigation"
android:layout_width="123dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@android:color/transparent"
android:text="Irrigation" />

</RelativeLayout>


Any idea on what is wrong?










share|improve this question





























    0















    hey everyone so i am trying to display 2 line charts on an activity i am using AnyChart when i change my code to display only 1 chart it works but when i add the second one only that one displays and the first one is gone.



    this is the activity



    public class DetailedFieldActivity extends AppCompatActivity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detailed_field);

    Intent intentData = getIntent();
    String FieldName = intentData.getStringExtra("field");

    setTitle(FieldName);


    prepareGraphTop();
    prepareGraphBot();
    }

    public void prepareGraphTop() {

    Intent graphsIntent = getIntent();
    String response = graphsIntent.getStringExtra("response");


    AnyChartView top = findViewById(R.id.top_soil);
    top.setProgressBar(findViewById(R.id.progress_bar));

    Cartesian topChartData = AnyChart.line();

    topChartData.animation(true);

    topChartData.padding(5d, 10d, 3d, 10d);

    topChartData.xAxis(0).scale();
    topChartData.xScroller(true).container();

    topChartData.crosshair().enabled(true);
    topChartData.crosshair()
    .yLabel(true)
    .yStroke((Stroke) null, null, null, (String) null, (String) null);

    topChartData.tooltip().positionMode(TooltipPositionMode.POINT);

    topChartData.title("Top Soil (0 - 400mm)");

    topChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

    final List<DataEntry> seriesDataTop = new ArrayList<>();

    try {

    JSONObject jsonResponse = new JSONObject(response);
    JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

    JSONArray dates = graphs.names();

    for (int i = 3; i < graphs.length(); i++) {

    String dateName = dates.getString(i);

    JSONObject dateData = graphs.getJSONObject(dateName);

    Number topSoil = dateData.getInt("TB");
    Number bb = dateData.getInt("BB");
    Number stressBo = dateData.getInt("stress");
    Number verwelpBo = dateData.getInt("verwelp");

    seriesDataTop.add(new CustomDataTop(dateName, topSoil, bb, stressBo));
    }

    } catch (JSONException e) {
    e.printStackTrace();
    }

    Set setTop = Set.instantiate();
    setTop.data(seriesDataTop);
    Mapping seriesTopMapping1 = setTop.mapAs("{ x: 'x', value: 'value' }");
    Mapping seriesTopMapping2 = setTop.mapAs("{ x: 'x', value: 'value2' }");
    Mapping seriesTopMapping3 = setTop.mapAs("{ x: 'x', value: 'value3' }");

    Line seriesTop1 = topChartData.line(seriesTopMapping1);
    seriesTop1.name("TB");
    seriesTop1.hovered().markers().enabled(true);
    seriesTop1.hovered().markers()
    .type(MarkerType.CIRCLE)
    .size(4d);
    seriesTop1.tooltip()
    .position("right")
    .anchor(Anchor.LEFT_CENTER)
    .offsetX(5d)
    .offsetY(5d);

    Line seriesTop2 = topChartData.line(seriesTopMapping2);
    seriesTop2.name("TO");
    seriesTop2.hovered().markers().enabled(true);
    seriesTop2.hovered().markers()
    .type(MarkerType.CIRCLE)
    .size(4d);
    seriesTop2.tooltip()
    .position("right")
    .anchor(Anchor.LEFT_CENTER)
    .offsetX(5d)
    .offsetY(5d);

    Line seriesTop3 = topChartData.line(seriesTopMapping3);
    seriesTop3.name("Stress Bo");
    seriesTop3.hovered().markers().enabled(true);
    seriesTop3.hovered().markers()
    .type(MarkerType.CIRCLE)
    .size(4d);
    seriesTop3.tooltip()
    .position("right")
    .anchor(Anchor.LEFT_CENTER)
    .offsetX(5d)
    .offsetY(5d);

    topChartData.legend().enabled(true);
    topChartData.legend().fontSize(13d);
    topChartData.legend().padding(0d, 0d, 10d, 0d);

    top.setChart(topChartData);
    }

    public void prepareGraphBot() {

    Intent graphsIntent = getIntent();
    String response = graphsIntent.getStringExtra("response");

    AnyChartView bottom = findViewById(R.id.bottom_soil);
    bottom.setProgressBar(findViewById(R.id.progress_bar));

    Cartesian botChartData = AnyChart.line();

    botChartData.animation(true);

    botChartData.padding(5d, 10d, 3d, 10d);

    botChartData.xAxis(0).scale();
    botChartData.xScroller(true).container();

    botChartData.crosshair().enabled(true);
    botChartData.crosshair()
    .yLabel(true)
    .yStroke((Stroke) null, null, null, (String) null, (String) null);

    botChartData.tooltip().positionMode(TooltipPositionMode.POINT);

    botChartData.title("Bottom Soil (400 - 800mm)");

    botChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

    final List<DataEntry> seriesDataBot = new ArrayList<>();

    try {

    JSONObject jsonResponse = new JSONObject(response);
    JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

    JSONArray dates = graphs.names();

    for (int i = 3; i < graphs.length(); i++) {

    String dateName = dates.getString(i);

    JSONObject dateData = graphs.getJSONObject(dateName);

    Number botSoil = dateData.getInt("TO");
    Number bo = dateData.getInt("BO");
    Number stressOnder = dateData.getInt("stressonder");
    Number verwelpOnder = dateData.getInt("verwelponder");
    Number pvrOnder = dateData.getInt("pvronder");

    seriesDataBot.add(new CustomDataBot(dateName, botSoil, bo, stressOnder));
    }

    } catch (JSONException e) {
    e.printStackTrace();
    }

    Set setBot = Set.instantiate();
    setBot.data(seriesDataBot);
    Mapping seriesBotMapping1 = setBot.mapAs("{ x: 'r', value: 'value12' }");
    Mapping seriesBotMapping2 = setBot.mapAs("{ x: 'r', value: 'value22' }");
    Mapping seriesBotMapping3 = setBot.mapAs("{ x: 'r', value: 'value32' }");

    Line seriesBot1 = botChartData.line(seriesBotMapping1);
    seriesBot1.name("TO");
    seriesBot1.hovered().markers().enabled(true);
    seriesBot1.hovered().markers()
    .type(MarkerType.CIRCLE)
    .size(4d);
    seriesBot1.tooltip()
    .position("right")
    .anchor(Anchor.LEFT_CENTER)
    .offsetX(5d)
    .offsetY(5d);

    Line seriesBot2 = botChartData.line(seriesBotMapping2);
    seriesBot2.name("BO");
    seriesBot2.hovered().markers().enabled(true);
    seriesBot2.hovered().markers()
    .type(MarkerType.CIRCLE)
    .size(4d);
    seriesBot2.tooltip()
    .position("right")
    .anchor(Anchor.LEFT_CENTER)
    .offsetX(5d)
    .offsetY(5d);

    Line seriesBot3 = botChartData.line(seriesBotMapping3);
    seriesBot3.name("Stress Onder");
    seriesBot3.hovered().markers().enabled(true);
    seriesBot3.hovered().markers()
    .type(MarkerType.CIRCLE)
    .size(4d);
    seriesBot3.tooltip()
    .position("right")
    .anchor(Anchor.LEFT_CENTER)
    .offsetX(5d)
    .offsetY(5d);

    botChartData.legend().enabled(true);
    botChartData.legend().fontSize(13d);
    botChartData.legend().padding(0d, 0d, 10d, 0d);

    bottom.setChart(botChartData);
    }

    private class CustomDataTop extends ValueDataEntry {

    CustomDataTop(String x, Number value, Number value2, Number value3) {
    super(x, value);
    setValue("value2", value2);
    setValue("value3", value3);
    }
    }

    private class CustomDataBot extends ValueDataEntry {

    CustomDataBot(String r, Number value12, Number value22, Number value32) {
    super(r, value12);
    setValue("value22", value22);
    setValue("value32", value32);
    }

    }


    }



    And this is my xml



    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".DetailedFieldActivity">

    <com.anychart.AnyChartView
    android:id="@+id/top_soil"
    android:layout_width="match_parent"
    android:layout_height="210dp"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_marginStart="0dp"
    android:layout_marginTop="49dp"
    android:layout_marginEnd="0dp">

    </com.anychart.AnyChartView>

    <com.anychart.AnyChartView
    android:id="@+id/bottom_soil"
    android:layout_width="match_parent"
    android:layout_height="201dp"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="0dp"
    android:layout_marginBottom="50dp">

    </com.anychart.AnyChartView>

    <ProgressBar
    android:id="@+id/progress_bar"
    android:layout_width="278dp"
    android:layout_height="189dp"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_marginStart="53dp"
    android:layout_marginTop="159dp"
    android:layout_marginEnd="53dp"
    android:layout_marginBottom="163dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

    <Button
    android:id="@+id/top_bottom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="0dp"
    android:background="@android:color/transparent"
    android:text="Top Bototm Soil" />

    <Button
    android:id="@+id/depths"
    android:layout_width="105dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/top_soil"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="3dp"
    android:background="@android:color/transparent"
    android:text="Depths" />

    <Button
    android:id="@+id/soil_temps"
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="0dp"
    android:background="@android:color/transparent"
    android:text="Soil Temps" />

    <Button
    android:id="@+id/photo"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:background="@android:color/transparent"
    android:text="Photos" />

    <Button
    android:id="@+id/moisture"
    android:layout_width="121dp"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true"
    android:background="@android:color/transparent"
    android:text="Moisture" />

    <Button
    android:id="@+id/irrigation"
    android:layout_width="123dp"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
    android:background="@android:color/transparent"
    android:text="Irrigation" />

    </RelativeLayout>


    Any idea on what is wrong?










    share|improve this question

























      0












      0








      0








      hey everyone so i am trying to display 2 line charts on an activity i am using AnyChart when i change my code to display only 1 chart it works but when i add the second one only that one displays and the first one is gone.



      this is the activity



      public class DetailedFieldActivity extends AppCompatActivity {



      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_detailed_field);

      Intent intentData = getIntent();
      String FieldName = intentData.getStringExtra("field");

      setTitle(FieldName);


      prepareGraphTop();
      prepareGraphBot();
      }

      public void prepareGraphTop() {

      Intent graphsIntent = getIntent();
      String response = graphsIntent.getStringExtra("response");


      AnyChartView top = findViewById(R.id.top_soil);
      top.setProgressBar(findViewById(R.id.progress_bar));

      Cartesian topChartData = AnyChart.line();

      topChartData.animation(true);

      topChartData.padding(5d, 10d, 3d, 10d);

      topChartData.xAxis(0).scale();
      topChartData.xScroller(true).container();

      topChartData.crosshair().enabled(true);
      topChartData.crosshair()
      .yLabel(true)
      .yStroke((Stroke) null, null, null, (String) null, (String) null);

      topChartData.tooltip().positionMode(TooltipPositionMode.POINT);

      topChartData.title("Top Soil (0 - 400mm)");

      topChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

      final List<DataEntry> seriesDataTop = new ArrayList<>();

      try {

      JSONObject jsonResponse = new JSONObject(response);
      JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

      JSONArray dates = graphs.names();

      for (int i = 3; i < graphs.length(); i++) {

      String dateName = dates.getString(i);

      JSONObject dateData = graphs.getJSONObject(dateName);

      Number topSoil = dateData.getInt("TB");
      Number bb = dateData.getInt("BB");
      Number stressBo = dateData.getInt("stress");
      Number verwelpBo = dateData.getInt("verwelp");

      seriesDataTop.add(new CustomDataTop(dateName, topSoil, bb, stressBo));
      }

      } catch (JSONException e) {
      e.printStackTrace();
      }

      Set setTop = Set.instantiate();
      setTop.data(seriesDataTop);
      Mapping seriesTopMapping1 = setTop.mapAs("{ x: 'x', value: 'value' }");
      Mapping seriesTopMapping2 = setTop.mapAs("{ x: 'x', value: 'value2' }");
      Mapping seriesTopMapping3 = setTop.mapAs("{ x: 'x', value: 'value3' }");

      Line seriesTop1 = topChartData.line(seriesTopMapping1);
      seriesTop1.name("TB");
      seriesTop1.hovered().markers().enabled(true);
      seriesTop1.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesTop1.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesTop2 = topChartData.line(seriesTopMapping2);
      seriesTop2.name("TO");
      seriesTop2.hovered().markers().enabled(true);
      seriesTop2.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesTop2.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesTop3 = topChartData.line(seriesTopMapping3);
      seriesTop3.name("Stress Bo");
      seriesTop3.hovered().markers().enabled(true);
      seriesTop3.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesTop3.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      topChartData.legend().enabled(true);
      topChartData.legend().fontSize(13d);
      topChartData.legend().padding(0d, 0d, 10d, 0d);

      top.setChart(topChartData);
      }

      public void prepareGraphBot() {

      Intent graphsIntent = getIntent();
      String response = graphsIntent.getStringExtra("response");

      AnyChartView bottom = findViewById(R.id.bottom_soil);
      bottom.setProgressBar(findViewById(R.id.progress_bar));

      Cartesian botChartData = AnyChart.line();

      botChartData.animation(true);

      botChartData.padding(5d, 10d, 3d, 10d);

      botChartData.xAxis(0).scale();
      botChartData.xScroller(true).container();

      botChartData.crosshair().enabled(true);
      botChartData.crosshair()
      .yLabel(true)
      .yStroke((Stroke) null, null, null, (String) null, (String) null);

      botChartData.tooltip().positionMode(TooltipPositionMode.POINT);

      botChartData.title("Bottom Soil (400 - 800mm)");

      botChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

      final List<DataEntry> seriesDataBot = new ArrayList<>();

      try {

      JSONObject jsonResponse = new JSONObject(response);
      JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

      JSONArray dates = graphs.names();

      for (int i = 3; i < graphs.length(); i++) {

      String dateName = dates.getString(i);

      JSONObject dateData = graphs.getJSONObject(dateName);

      Number botSoil = dateData.getInt("TO");
      Number bo = dateData.getInt("BO");
      Number stressOnder = dateData.getInt("stressonder");
      Number verwelpOnder = dateData.getInt("verwelponder");
      Number pvrOnder = dateData.getInt("pvronder");

      seriesDataBot.add(new CustomDataBot(dateName, botSoil, bo, stressOnder));
      }

      } catch (JSONException e) {
      e.printStackTrace();
      }

      Set setBot = Set.instantiate();
      setBot.data(seriesDataBot);
      Mapping seriesBotMapping1 = setBot.mapAs("{ x: 'r', value: 'value12' }");
      Mapping seriesBotMapping2 = setBot.mapAs("{ x: 'r', value: 'value22' }");
      Mapping seriesBotMapping3 = setBot.mapAs("{ x: 'r', value: 'value32' }");

      Line seriesBot1 = botChartData.line(seriesBotMapping1);
      seriesBot1.name("TO");
      seriesBot1.hovered().markers().enabled(true);
      seriesBot1.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesBot1.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesBot2 = botChartData.line(seriesBotMapping2);
      seriesBot2.name("BO");
      seriesBot2.hovered().markers().enabled(true);
      seriesBot2.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesBot2.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesBot3 = botChartData.line(seriesBotMapping3);
      seriesBot3.name("Stress Onder");
      seriesBot3.hovered().markers().enabled(true);
      seriesBot3.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesBot3.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      botChartData.legend().enabled(true);
      botChartData.legend().fontSize(13d);
      botChartData.legend().padding(0d, 0d, 10d, 0d);

      bottom.setChart(botChartData);
      }

      private class CustomDataTop extends ValueDataEntry {

      CustomDataTop(String x, Number value, Number value2, Number value3) {
      super(x, value);
      setValue("value2", value2);
      setValue("value3", value3);
      }
      }

      private class CustomDataBot extends ValueDataEntry {

      CustomDataBot(String r, Number value12, Number value22, Number value32) {
      super(r, value12);
      setValue("value22", value22);
      setValue("value32", value32);
      }

      }


      }



      And this is my xml



      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".DetailedFieldActivity">

      <com.anychart.AnyChartView
      android:id="@+id/top_soil"
      android:layout_width="match_parent"
      android:layout_height="210dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      android:layout_marginStart="0dp"
      android:layout_marginTop="49dp"
      android:layout_marginEnd="0dp">

      </com.anychart.AnyChartView>

      <com.anychart.AnyChartView
      android:id="@+id/bottom_soil"
      android:layout_width="match_parent"
      android:layout_height="201dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true"
      android:layout_marginStart="0dp"
      android:layout_marginBottom="50dp">

      </com.anychart.AnyChartView>

      <ProgressBar
      android:id="@+id/progress_bar"
      android:layout_width="278dp"
      android:layout_height="189dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:layout_marginStart="53dp"
      android:layout_marginTop="159dp"
      android:layout_marginEnd="53dp"
      android:layout_marginBottom="163dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" />

      <Button
      android:id="@+id/top_bottom"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:layout_marginTop="0dp"
      android:background="@android:color/transparent"
      android:text="Top Bototm Soil" />

      <Button
      android:id="@+id/depths"
      android:layout_width="105dp"
      android:layout_height="wrap_content"
      android:layout_above="@+id/top_soil"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="3dp"
      android:background="@android:color/transparent"
      android:text="Depths" />

      <Button
      android:id="@+id/soil_temps"
      android:layout_width="120dp"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      android:layout_marginTop="0dp"
      android:background="@android:color/transparent"
      android:text="Soil Temps" />

      <Button
      android:id="@+id/photo"
      android:layout_width="100dp"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:background="@android:color/transparent"
      android:text="Photos" />

      <Button
      android:id="@+id/moisture"
      android:layout_width="121dp"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true"
      android:background="@android:color/transparent"
      android:text="Moisture" />

      <Button
      android:id="@+id/irrigation"
      android:layout_width="123dp"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignParentBottom="true"
      android:background="@android:color/transparent"
      android:text="Irrigation" />

      </RelativeLayout>


      Any idea on what is wrong?










      share|improve this question














      hey everyone so i am trying to display 2 line charts on an activity i am using AnyChart when i change my code to display only 1 chart it works but when i add the second one only that one displays and the first one is gone.



      this is the activity



      public class DetailedFieldActivity extends AppCompatActivity {



      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_detailed_field);

      Intent intentData = getIntent();
      String FieldName = intentData.getStringExtra("field");

      setTitle(FieldName);


      prepareGraphTop();
      prepareGraphBot();
      }

      public void prepareGraphTop() {

      Intent graphsIntent = getIntent();
      String response = graphsIntent.getStringExtra("response");


      AnyChartView top = findViewById(R.id.top_soil);
      top.setProgressBar(findViewById(R.id.progress_bar));

      Cartesian topChartData = AnyChart.line();

      topChartData.animation(true);

      topChartData.padding(5d, 10d, 3d, 10d);

      topChartData.xAxis(0).scale();
      topChartData.xScroller(true).container();

      topChartData.crosshair().enabled(true);
      topChartData.crosshair()
      .yLabel(true)
      .yStroke((Stroke) null, null, null, (String) null, (String) null);

      topChartData.tooltip().positionMode(TooltipPositionMode.POINT);

      topChartData.title("Top Soil (0 - 400mm)");

      topChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

      final List<DataEntry> seriesDataTop = new ArrayList<>();

      try {

      JSONObject jsonResponse = new JSONObject(response);
      JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

      JSONArray dates = graphs.names();

      for (int i = 3; i < graphs.length(); i++) {

      String dateName = dates.getString(i);

      JSONObject dateData = graphs.getJSONObject(dateName);

      Number topSoil = dateData.getInt("TB");
      Number bb = dateData.getInt("BB");
      Number stressBo = dateData.getInt("stress");
      Number verwelpBo = dateData.getInt("verwelp");

      seriesDataTop.add(new CustomDataTop(dateName, topSoil, bb, stressBo));
      }

      } catch (JSONException e) {
      e.printStackTrace();
      }

      Set setTop = Set.instantiate();
      setTop.data(seriesDataTop);
      Mapping seriesTopMapping1 = setTop.mapAs("{ x: 'x', value: 'value' }");
      Mapping seriesTopMapping2 = setTop.mapAs("{ x: 'x', value: 'value2' }");
      Mapping seriesTopMapping3 = setTop.mapAs("{ x: 'x', value: 'value3' }");

      Line seriesTop1 = topChartData.line(seriesTopMapping1);
      seriesTop1.name("TB");
      seriesTop1.hovered().markers().enabled(true);
      seriesTop1.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesTop1.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesTop2 = topChartData.line(seriesTopMapping2);
      seriesTop2.name("TO");
      seriesTop2.hovered().markers().enabled(true);
      seriesTop2.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesTop2.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesTop3 = topChartData.line(seriesTopMapping3);
      seriesTop3.name("Stress Bo");
      seriesTop3.hovered().markers().enabled(true);
      seriesTop3.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesTop3.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      topChartData.legend().enabled(true);
      topChartData.legend().fontSize(13d);
      topChartData.legend().padding(0d, 0d, 10d, 0d);

      top.setChart(topChartData);
      }

      public void prepareGraphBot() {

      Intent graphsIntent = getIntent();
      String response = graphsIntent.getStringExtra("response");

      AnyChartView bottom = findViewById(R.id.bottom_soil);
      bottom.setProgressBar(findViewById(R.id.progress_bar));

      Cartesian botChartData = AnyChart.line();

      botChartData.animation(true);

      botChartData.padding(5d, 10d, 3d, 10d);

      botChartData.xAxis(0).scale();
      botChartData.xScroller(true).container();

      botChartData.crosshair().enabled(true);
      botChartData.crosshair()
      .yLabel(true)
      .yStroke((Stroke) null, null, null, (String) null, (String) null);

      botChartData.tooltip().positionMode(TooltipPositionMode.POINT);

      botChartData.title("Bottom Soil (400 - 800mm)");

      botChartData.xAxis(0).labels().padding(3d, 3d, 3d, 3d);

      final List<DataEntry> seriesDataBot = new ArrayList<>();

      try {

      JSONObject jsonResponse = new JSONObject(response);
      JSONObject graphs = jsonResponse.getJSONObject("Grafieke");

      JSONArray dates = graphs.names();

      for (int i = 3; i < graphs.length(); i++) {

      String dateName = dates.getString(i);

      JSONObject dateData = graphs.getJSONObject(dateName);

      Number botSoil = dateData.getInt("TO");
      Number bo = dateData.getInt("BO");
      Number stressOnder = dateData.getInt("stressonder");
      Number verwelpOnder = dateData.getInt("verwelponder");
      Number pvrOnder = dateData.getInt("pvronder");

      seriesDataBot.add(new CustomDataBot(dateName, botSoil, bo, stressOnder));
      }

      } catch (JSONException e) {
      e.printStackTrace();
      }

      Set setBot = Set.instantiate();
      setBot.data(seriesDataBot);
      Mapping seriesBotMapping1 = setBot.mapAs("{ x: 'r', value: 'value12' }");
      Mapping seriesBotMapping2 = setBot.mapAs("{ x: 'r', value: 'value22' }");
      Mapping seriesBotMapping3 = setBot.mapAs("{ x: 'r', value: 'value32' }");

      Line seriesBot1 = botChartData.line(seriesBotMapping1);
      seriesBot1.name("TO");
      seriesBot1.hovered().markers().enabled(true);
      seriesBot1.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesBot1.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesBot2 = botChartData.line(seriesBotMapping2);
      seriesBot2.name("BO");
      seriesBot2.hovered().markers().enabled(true);
      seriesBot2.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesBot2.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      Line seriesBot3 = botChartData.line(seriesBotMapping3);
      seriesBot3.name("Stress Onder");
      seriesBot3.hovered().markers().enabled(true);
      seriesBot3.hovered().markers()
      .type(MarkerType.CIRCLE)
      .size(4d);
      seriesBot3.tooltip()
      .position("right")
      .anchor(Anchor.LEFT_CENTER)
      .offsetX(5d)
      .offsetY(5d);

      botChartData.legend().enabled(true);
      botChartData.legend().fontSize(13d);
      botChartData.legend().padding(0d, 0d, 10d, 0d);

      bottom.setChart(botChartData);
      }

      private class CustomDataTop extends ValueDataEntry {

      CustomDataTop(String x, Number value, Number value2, Number value3) {
      super(x, value);
      setValue("value2", value2);
      setValue("value3", value3);
      }
      }

      private class CustomDataBot extends ValueDataEntry {

      CustomDataBot(String r, Number value12, Number value22, Number value32) {
      super(r, value12);
      setValue("value22", value22);
      setValue("value32", value32);
      }

      }


      }



      And this is my xml



      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".DetailedFieldActivity">

      <com.anychart.AnyChartView
      android:id="@+id/top_soil"
      android:layout_width="match_parent"
      android:layout_height="210dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      android:layout_marginStart="0dp"
      android:layout_marginTop="49dp"
      android:layout_marginEnd="0dp">

      </com.anychart.AnyChartView>

      <com.anychart.AnyChartView
      android:id="@+id/bottom_soil"
      android:layout_width="match_parent"
      android:layout_height="201dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true"
      android:layout_marginStart="0dp"
      android:layout_marginBottom="50dp">

      </com.anychart.AnyChartView>

      <ProgressBar
      android:id="@+id/progress_bar"
      android:layout_width="278dp"
      android:layout_height="189dp"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:layout_marginStart="53dp"
      android:layout_marginTop="159dp"
      android:layout_marginEnd="53dp"
      android:layout_marginBottom="163dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" />

      <Button
      android:id="@+id/top_bottom"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:layout_marginTop="0dp"
      android:background="@android:color/transparent"
      android:text="Top Bototm Soil" />

      <Button
      android:id="@+id/depths"
      android:layout_width="105dp"
      android:layout_height="wrap_content"
      android:layout_above="@+id/top_soil"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="3dp"
      android:background="@android:color/transparent"
      android:text="Depths" />

      <Button
      android:id="@+id/soil_temps"
      android:layout_width="120dp"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_alignParentEnd="true"
      android:layout_marginTop="0dp"
      android:background="@android:color/transparent"
      android:text="Soil Temps" />

      <Button
      android:id="@+id/photo"
      android:layout_width="100dp"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:background="@android:color/transparent"
      android:text="Photos" />

      <Button
      android:id="@+id/moisture"
      android:layout_width="121dp"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true"
      android:background="@android:color/transparent"
      android:text="Moisture" />

      <Button
      android:id="@+id/irrigation"
      android:layout_width="123dp"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignParentBottom="true"
      android:background="@android:color/transparent"
      android:text="Irrigation" />

      </RelativeLayout>


      Any idea on what is wrong?







      java android






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 10:41









      The43JokerThe43Joker

      233




      233
























          2 Answers
          2






          active

          oldest

          votes


















          1














          change this line after getting the reference of chartview



          //prepareGraphTop method
          AnyChartView top = findViewById(R.id.top_soil);
          APIlib.getInstance().setActiveAnyChartView(top);
          //prepareGraphBot method
          AnyChartView bottom = findViewById(R.id.bottom_soil);
          APIlib.getInstance().setActiveAnyChartView(bottom);


          you can check the documentation Click here!






          share|improve this answer
























          • Thank you, you just stopped days of searching for an answer

            – The43Joker
            Nov 21 '18 at 6:46



















          0














          MPAndroid Chart



          A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging, animations and MultipleCharts.



          It is easier to implement multiple charts in one xml file



              <RelativeLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content">

          <android.support.v7.widget.CardView
          android:id="@+id/pie_chart_card"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginBottom="@dimen/card_layout_padding"
          android:elevation="@dimen/elevation"
          app:cardCornerRadius="@dimen/card_radius">

          <com.github.mikephil.charting.charts.PieChart
          android:id="@+id/pie_chart"
          android:layout_width="match_parent"
          android:layout_height="@dimen/card_size_chart_pie" />
          </android.support.v7.widget.CardView>

          <android.support.v7.widget.CardView
          android:id="@+id/line_chart_card"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/pie_chart_card"
          android:layout_marginBottom="@dimen/card_layout_padding"
          android:elevation="@dimen/elevation"
          app:cardCornerRadius="@dimen/card_radius">

          <com.github.mikephil.charting.charts.LineChart
          android:id="@+id/line_chart"
          android:layout_width="match_parent"
          android:layout_height="@dimen/card_size_chart" />
          </android.support.v7.widget.CardView>

          </RelativeLayout>





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53336185%2fanychart-trying-to-show-2-line-charts-on-an-activity%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            change this line after getting the reference of chartview



            //prepareGraphTop method
            AnyChartView top = findViewById(R.id.top_soil);
            APIlib.getInstance().setActiveAnyChartView(top);
            //prepareGraphBot method
            AnyChartView bottom = findViewById(R.id.bottom_soil);
            APIlib.getInstance().setActiveAnyChartView(bottom);


            you can check the documentation Click here!






            share|improve this answer
























            • Thank you, you just stopped days of searching for an answer

              – The43Joker
              Nov 21 '18 at 6:46
















            1














            change this line after getting the reference of chartview



            //prepareGraphTop method
            AnyChartView top = findViewById(R.id.top_soil);
            APIlib.getInstance().setActiveAnyChartView(top);
            //prepareGraphBot method
            AnyChartView bottom = findViewById(R.id.bottom_soil);
            APIlib.getInstance().setActiveAnyChartView(bottom);


            you can check the documentation Click here!






            share|improve this answer
























            • Thank you, you just stopped days of searching for an answer

              – The43Joker
              Nov 21 '18 at 6:46














            1












            1








            1







            change this line after getting the reference of chartview



            //prepareGraphTop method
            AnyChartView top = findViewById(R.id.top_soil);
            APIlib.getInstance().setActiveAnyChartView(top);
            //prepareGraphBot method
            AnyChartView bottom = findViewById(R.id.bottom_soil);
            APIlib.getInstance().setActiveAnyChartView(bottom);


            you can check the documentation Click here!






            share|improve this answer













            change this line after getting the reference of chartview



            //prepareGraphTop method
            AnyChartView top = findViewById(R.id.top_soil);
            APIlib.getInstance().setActiveAnyChartView(top);
            //prepareGraphBot method
            AnyChartView bottom = findViewById(R.id.bottom_soil);
            APIlib.getInstance().setActiveAnyChartView(bottom);


            you can check the documentation Click here!







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 16 '18 at 12:20









            Nikul VadherNikul Vadher

            535




            535













            • Thank you, you just stopped days of searching for an answer

              – The43Joker
              Nov 21 '18 at 6:46



















            • Thank you, you just stopped days of searching for an answer

              – The43Joker
              Nov 21 '18 at 6:46

















            Thank you, you just stopped days of searching for an answer

            – The43Joker
            Nov 21 '18 at 6:46





            Thank you, you just stopped days of searching for an answer

            – The43Joker
            Nov 21 '18 at 6:46













            0














            MPAndroid Chart



            A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging, animations and MultipleCharts.



            It is easier to implement multiple charts in one xml file



                <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
            android:id="@+id/pie_chart_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/card_layout_padding"
            android:elevation="@dimen/elevation"
            app:cardCornerRadius="@dimen/card_radius">

            <com.github.mikephil.charting.charts.PieChart
            android:id="@+id/pie_chart"
            android:layout_width="match_parent"
            android:layout_height="@dimen/card_size_chart_pie" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
            android:id="@+id/line_chart_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/pie_chart_card"
            android:layout_marginBottom="@dimen/card_layout_padding"
            android:elevation="@dimen/elevation"
            app:cardCornerRadius="@dimen/card_radius">

            <com.github.mikephil.charting.charts.LineChart
            android:id="@+id/line_chart"
            android:layout_width="match_parent"
            android:layout_height="@dimen/card_size_chart" />
            </android.support.v7.widget.CardView>

            </RelativeLayout>





            share|improve this answer




























              0














              MPAndroid Chart



              A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging, animations and MultipleCharts.



              It is easier to implement multiple charts in one xml file



                  <RelativeLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content">

              <android.support.v7.widget.CardView
              android:id="@+id/pie_chart_card"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="@dimen/card_layout_padding"
              android:elevation="@dimen/elevation"
              app:cardCornerRadius="@dimen/card_radius">

              <com.github.mikephil.charting.charts.PieChart
              android:id="@+id/pie_chart"
              android:layout_width="match_parent"
              android:layout_height="@dimen/card_size_chart_pie" />
              </android.support.v7.widget.CardView>

              <android.support.v7.widget.CardView
              android:id="@+id/line_chart_card"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@id/pie_chart_card"
              android:layout_marginBottom="@dimen/card_layout_padding"
              android:elevation="@dimen/elevation"
              app:cardCornerRadius="@dimen/card_radius">

              <com.github.mikephil.charting.charts.LineChart
              android:id="@+id/line_chart"
              android:layout_width="match_parent"
              android:layout_height="@dimen/card_size_chart" />
              </android.support.v7.widget.CardView>

              </RelativeLayout>





              share|improve this answer


























                0












                0








                0







                MPAndroid Chart



                A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging, animations and MultipleCharts.



                It is easier to implement multiple charts in one xml file



                    <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <android.support.v7.widget.CardView
                android:id="@+id/pie_chart_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/card_layout_padding"
                android:elevation="@dimen/elevation"
                app:cardCornerRadius="@dimen/card_radius">

                <com.github.mikephil.charting.charts.PieChart
                android:id="@+id/pie_chart"
                android:layout_width="match_parent"
                android:layout_height="@dimen/card_size_chart_pie" />
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                android:id="@+id/line_chart_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/pie_chart_card"
                android:layout_marginBottom="@dimen/card_layout_padding"
                android:elevation="@dimen/elevation"
                app:cardCornerRadius="@dimen/card_radius">

                <com.github.mikephil.charting.charts.LineChart
                android:id="@+id/line_chart"
                android:layout_width="match_parent"
                android:layout_height="@dimen/card_size_chart" />
                </android.support.v7.widget.CardView>

                </RelativeLayout>





                share|improve this answer













                MPAndroid Chart



                A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, dragging, animations and MultipleCharts.



                It is easier to implement multiple charts in one xml file



                    <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <android.support.v7.widget.CardView
                android:id="@+id/pie_chart_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/card_layout_padding"
                android:elevation="@dimen/elevation"
                app:cardCornerRadius="@dimen/card_radius">

                <com.github.mikephil.charting.charts.PieChart
                android:id="@+id/pie_chart"
                android:layout_width="match_parent"
                android:layout_height="@dimen/card_size_chart_pie" />
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                android:id="@+id/line_chart_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/pie_chart_card"
                android:layout_marginBottom="@dimen/card_layout_padding"
                android:elevation="@dimen/elevation"
                app:cardCornerRadius="@dimen/card_radius">

                <com.github.mikephil.charting.charts.LineChart
                android:id="@+id/line_chart"
                android:layout_width="match_parent"
                android:layout_height="@dimen/card_size_chart" />
                </android.support.v7.widget.CardView>

                </RelativeLayout>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 13:42









                Shoaib ShaikhShoaib Shaikh

                12




                12






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53336185%2fanychart-trying-to-show-2-line-charts-on-an-activity%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python