私は、日付ごとに血糖値を表示するための線グラフを描画するためにachartengineに使用しています。線グラフの描画に成功しました。しかし、私はここで苦労しています。しばらくの間、血糖値のチェックのために1日に1つ以上の値があります。同じ日に複数の値を線グラフで表示する方法がわかりません。
Thanks Advance..
Note: I need to show the line graph for multiple values each day. Normally Blood
sugar possible for checking for minimum 3 times per day.
that's my problem.
My Code : my code is very usefull for normal line graph generating..
public class GraphActivity extends Activity {
private ArrayList<String> mMonthArrayList = new ArrayList<String>() ;
private GraphicalView mChart ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(getApplicationContext(), "SecondActivity", 20).show();
mMonthArrayList.add("01/01/2013");
mMonthArrayList.add("02/01/2013");
mMonthArrayList.add("03/01/2013");
mMonthArrayList.add("04/01/2013");
mMonthArrayList.add("05/01/2013");
mMonthArrayList.add("06/01/2013");
mMonthArrayList.add("07/01/2013");
mMonthArrayList.add("08/01/2013");
mMonthArrayList.add("09/01/2013");
mMonthArrayList.add("10/01/2013");
mMonthArrayList.add("11/01/2013");
mMonthArrayList.add("12/01/2013");
openChart();
}
private void openChart()
{
int xsideData[] = {0,2,3,4,6};
int ysideData[] = {200,300,500,600,400};
/*ArrayList<Integer> xsideData = new ArrayList<Integer>() ;
xsideData.add(0);
xsideData.add(1);
xsideData.add(2);
xsideData.add(3);
xsideData.add(4);
ArrayList<Integer> ysideData = new ArrayList<Integer>() ;
ysideData.add(200);
ysideData.add(300);
ysideData.add(400);
ysideData.add(600);
ysideData.add(800);*/
XYSeries xyseriesData = new XYSeries("XYSERIES TITLE");
XYSeriesRenderer xyRenderer = new XYSeriesRenderer() ;
XYMultipleSeriesDataset xymultipleDataset = new XYMultipleSeriesDataset();
// Adding data to xside and yside Series
for(int i = 0 ; i < xsideData.length; i++ ) {
xyseriesData.add(xsideData[i], ysideData[i]);
}
xymultipleDataset.addSeries(xyseriesData);
xyRenderer.setColor(Color.WHITE);
xyRenderer.setPointStyle(PointStyle.CIRCLE);
xyRenderer.setFillPoints(true);
xyRenderer.setLineWidth(1);
xyRenderer.setDisplayChartValues(true);
// Creating a XYMultipleSeriesRenderer to customize the whole chart
XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
multiRenderer.setXLabels(0);
multiRenderer.setXTitle("Year 2012");
//multiRenderer.setZoomButtonsVisible(true);
multiRenderer.setGridColor(Color.WHITE);
multiRenderer.setShowGrid(true);
multiRenderer.setLabelsTextSize(15);
multiRenderer.setLegendTextSize(15);
multiRenderer.setMargins(new int[] { 20, 30, 15, 0 });
multiRenderer.setXLabels(7);
multiRenderer.setYLabels(5);
multiRenderer.setDisplayChartValues(false);
//multiRenderer.setShowGrid(false);
for(int i=0;i<xsideData.length;i++)
{
multiRenderer.addXTextLabel(i, mMonthArrayList.get(i));
}
multiRenderer.addSeriesRenderer(xyRenderer);
LinearLayout chartContainer = (LinearLayout) findViewById(R.id.chart_container);
// Creating a Line Chart
mChart = (GraphicalView) ChartFactory.
getLineChartView(getBaseContext(), xymultipleDataset, multiRenderer);
// Adding the Line Chart to the LinearLayout
chartContainer.addView(mChart);
}
}
My output image :
![enter image description here][1]