开发者

Date value on X Axis label achartengine

i want to use on the X-Axes a set of DataTime values.

Using the achartengine, i want to show on it the following objects:

date1,

  • rain => "value"
  • sun => "value"
  • wind => "value"

date2

  • rain => "value"
  • sun => "value"
  • wind => "value"

etc...

I've already set an achartengine with those values.

Here it's my code:

if (mChartView == null){
            layout_chart = (LinearLayout) findViewById(R.id.chart);
            mChartView = ChartFactory.getCombinedXYChartView(
                    Grafico_modello.this
      开发者_如何学Go              , chart.getDataset()//mDataset
                    , chart.getRenderer()//mRenderer
                    , chart.getTypes() //types
                    ); 
    }

//populating the object on the .getDataset method
for (i=0;i<name_label.length;i++){
    var[i] = new XYSeries(name_label[i]);
        for (j=0;j<grafico.length();j++){
            int unix_time=0;
            unix_time=grafico.getDays()[j];
            var[i].add(unix_time
                    , grafico.getVariabili()
                             .get(unix_time)
                        .get(name_var[i]));
            }
}

UPDATE 1:

Date value on X Axis label achartengine


I think i solved my problem. Here it is the code.

//SETTING THE DATASET
TimeSeries[] var = new TimeSeries[7];
XYSeriesRenderer[] arrayRenderer = new XYSeriesRenderer[7];
for (i=0;i<name_label.length;i++){
var[i] = new TimeSeries(name_label[i]);
    for (j=0;j<grafico.length();j++){
    int unix_time=0;
    unix_time=grafico.getDays()[j];
    Date date = new Date ();
    date.setTime((long)unix_time*1000);
    var[i].add(date
        , grafico.getVariabili()
                     .get(unix_time)
                      .get(name_var[i]));
    }
        arrayRenderer[i]= new XYSeriesRenderer();
}
//pioggia - celeste
arrayRenderer[0].setColor(Color.rgb(173, 216, 230));
//tmin - blu
arrayRenderer[1].setColor(Color.BLUE);
//tmax - rosso
arrayRenderer[2].setColor(Color.RED);
//sole - giallo
arrayRenderer[3].setColor(Color.YELLOW);
//vento - bianco
arrayRenderer[4].setColor(Color.WHITE);
//Umin - marrone
arrayRenderer[5].setColor(Color.rgb(165, 42, 42));
//Umax - verde
arrayRenderer[6].setColor(Color.GREEN);
}
//SETTING THE CHART
mChartView = ChartFactory.getTimeChartView(
            Grafico_meteo.this
            , mDataset//mDataset
            , mRenderer//mRenderer
            , null
            );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜