Bar chart using achartengine

前端 未结 4 1741
花落未央
花落未央 2020-12-08 05:34

I want to draw a bar chart which contains five individual bars - I have used Achartengine. I am able to display all five bars in the same color but I want to differentiate o

4条回答
  •  春和景丽
    2020-12-08 06:12

    You have to use different SimpleSeriesRenderer inside buildBarRenderer() call, and define as many serie as the desired number of colors, this way (replacing your first two lines of code):

    values.add(new double[] {21});  
    values.add(new double[] {56});  
    values.add(new double[] {33});  
    //ETC.
    int[] colors = new int[] { Color.rgb(227, 121, 15),
                               Color.rgb(227, 121, 227), 
                               Color.rgb(127, 121, 127) };
    

    The rest of code should be same as yours, but I haven't tested it. AFAIK you need different series, because every serie can only have one color.

提交回复
热议问题