whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
SUPPORT
whitespace
FORUM
whitespace
FAQS
whitespace
SUBSCRIPTION
whitespace
REQUEST ON-LINE
whitespace
whitespace

Technical Support Forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Ivan  
#1 Posted : Wednesday, March 9, 2011 5:52:02 PM(UTC)
Ivan
Rank: Member

Groups: Registered
Joined: 3/7/2011(UTC)
Posts: 25
Location: Albis

Hi Support,

Here is my problem..

I would like to have the legend to show in one line if you look at the screenshot it is showing like a LIST... and I dont want it that way... another issue I have is the dots are not showing in the right colors... for example HT should be blue and NT green.

here is the code:

Sorry for the messy code... I am just trying to find all functions in the getting started for late implementation:



public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

ChartView chartView = new ChartView(this);
ChartArea area = chartView.addArea();
ChartSeries series = new ChartSeries(ChartTypes.StackedColumn);
ChartSeries series2 = new ChartSeries(ChartTypes.StackedColumn);
ChartLegend legend = new ChartLegend();
ChartLegend legend2 = new ChartLegend();

//series.getPoints().setData(new double[]{26,18,42,33});
//ChartPoint point = new ChartPoint(1,26);
//point.setAxisLabel("t1");
//series.getPoints().add(point);

for (int i = 2;i<7;i++)
{
ChartPoint point1 = new ChartPoint(i,15);
point1.setLabelFormat("$"+" t1");
//point1.setAxisLabel("t1");
//point1.setLabel("label");
point1.setBackColor(Color.BLUE);
point1.setBorderColor(Color.WHITE);
series.getPoints().add(point1);

ChartPoint point2 = new ChartPoint(i,10);
point2.setLabelFormat("$"+" t2");
//point1.setAxisLabel("t1");
//point1.setLabel("label");
point2.setBackColor(Color.GREEN);
point2.setBorderColor(Color.CYAN);
series2.getPoints().add(point2);
}

//series.getPoints().get(1).setAxisLabel("t1");
series.setShowLabel(true);
series.setHLabelAlignment(Alignment.Center);
series.setVLabelAlignment(Alignment.Near);
series.getTextPaint().setColor(Color.BLACK);
series.getTextPaint().setTextSize(15f);
series.getTextPaint().setAntiAlias(true);
series.setName("HT");
//series.setLegend("HT");

legend.setName("HT");
legend.setDock(Dock.Bottom);
legend.setLayoutMode(LayoutMode.Vertical);
legend.setAlignment(Alignment.Near);
legend.getTextPaint().setColor(Color.BLACK);
//legend.setItemsProvider(new LegendItemsProvider.PointItemsProvider());


legend2.setName("NT");
legend2.setDock(Dock.Bottom);
legend2.setAlignment(Alignment.Near);
legend2.setLayoutMode(LayoutMode.Vertical);
legend2.getTextPaint().setColor(Color.BLACK);
//legend2.setItemsProvider(new LegendItemsProvider.SeriesItemsProvider());

series2.setShowLabel(true);
series2.setHLabelAlignment(Alignment.Center);
series2.setVLabelAlignment(Alignment.Near);
series2.getTextPaint().setColor(Color.BLACK);
series2.getTextPaint().setTextSize(15f);
series2.getTextPaint().setAntiAlias(true);
series2.setName("NT");
//series2.setLegend("NT");


ChartTitle ctitle = new ChartTitle();
ctitle.getTextPaint().setColor(Color.BLACK);
ctitle.getTextPaint().setAntiAlias(true);
ctitle.getTextPaint().setTextSize(20);
ctitle.setAlignment(Alignment.Center);
ctitle.setDock(Dock.Top);
ctitle.setText("01.01.2010 - 10.10.2011 (KW 40)");

chartView.getTitles().add(ctitle);
chartView.setBackgroundColor(Color.WHITE);
chartView.getChart().setSpacing(10);

//area.setName("01.01.2010 - 10.10.2011 (KW 40)");

area.getDefaultXAxis().setTitle("days");
area.getDefaultXAxis().getTitlePaint().setColor(Color.BLACK);

area.getDefaultXAxis().getLinePaint().setColor(Color.BLACK);
area.getDefaultXAxis().getLinePaint().setStrokeWidth(2f);
area.getDefaultXAxis().getLabelPaint().setColor(Color.RED);
area.getDefaultXAxis().setGridVisible(false);


area.getDefaultYAxis().setTitle("kWh");
area.getDefaultYAxis().getTitlePaint().setColor(Color.BLACK);


area.getDefaultYAxis().getLinePaint().setColor(Color.BLACK);
area.getDefaultYAxis().getLinePaint().setStrokeWidth(2f);
area.getDefaultYAxis().getLabelPaint().setColor(Color.BLUE);
area.getDefaultYAxis().getLabelPaint().setTextSize(20f);
area.getDefaultYAxis().setGridVisible(false);


area.getDefaultXAxis().getScale().setMargin(0);
area.getDefaultXAxis().getScale().setInterval(1.0, IntervalType.Days);
area.getDefaultXAxis().setLabelsMode(LabelsMode.SeriesLabels);

chartView.getSeries().add(series);
chartView.getSeries().add(series2);
chartView.getLegends().add(legend2);
chartView.getLegends().add(legend);
series.setArea(area.getName());
series2.setArea(area.getName());

setContentView(chartView);
}



thank you very much for your help

Edited by moderator Thursday, March 10, 2011 11:52:06 AM(UTC)  | Reason: code reformatting

Ivan attached the following image(s):
aichartsLegend01.png (20kb) downloaded 115 time(s).

You cannot view/download attachments. Try to login or register.
Baydalka Volodymyr  
#2 Posted : Wednesday, March 9, 2011 6:37:03 PM(UTC)
Baydalka Volodymyr
Rank: Member

Groups: Registered
Joined: 7/28/2009(UTC)
Posts: 447
Man

Hi,

1) You don't need to create new instance of ChartLegend for each series. However if you use one legend for all series with line - ChartLegend.setLayoutMode(LayoutMode.Vertical) - legend will represent items like a list.

2) Also you do not need to specify area or legend name for series if you use only one instance of them.

3) You don't need to specify general properties (color, border-color, etc.) for each point. Points use series properties if you do not specify it for point.

Please check following sample

Best regards,
File Attachment(s):
aiCharts.ForumSample290.zip (15kb) downloaded 26 time(s).

You cannot view/download attachments. Try to login or register.
Volodymyr Baydalka
Andriod development and support team
Ivan  
#3 Posted : Wednesday, March 9, 2011 7:13:37 PM(UTC)
Ivan
Rank: Member

Groups: Registered
Joined: 3/7/2011(UTC)
Posts: 25
Location: Albis

Hi Support,

thank you very much for the quick and prepared response... appreciate it very much

Ivan
Ivan  
#4 Posted : Tuesday, March 15, 2011 3:37:27 PM(UTC)
Ivan
Rank: Member

Groups: Registered
Joined: 3/7/2011(UTC)
Posts: 25
Location: Albis

Hi Support,

I have the following issue, I have a chart with 4 chart line series in it... but I want to show only the LEGEND of 2 of these SERIES... and make the legend invisible for the other 2 series.... can you tell me how to do that?

thank you very much for your always fast answers
Ivan
Baydalka Volodymyr  
#5 Posted : Tuesday, March 15, 2011 3:40:41 PM(UTC)
Baydalka Volodymyr
Rank: Member

Groups: Registered
Joined: 7/28/2009(UTC)
Posts: 447
Man

Hi,

Try to bind series to unused legend name to hide it. Example : series.setLegend("_HIDDEN_LEGEND");

Best regards,
Volodymyr Baydalka
Andriod development and support team
Ivan  
#6 Posted : Tuesday, March 15, 2011 4:27:08 PM(UTC)
Ivan
Rank: Member

Groups: Registered
Joined: 3/7/2011(UTC)
Posts: 25
Location: Albis

Cool Thanks! it worked..

Ivan
Ivan  
#7 Posted : Tuesday, March 15, 2011 4:31:00 PM(UTC)
Ivan
Rank: Member

Groups: Registered
Joined: 3/7/2011(UTC)
Posts: 25
Location: Albis

Another quick question,

Please see attached screenshot... is there any reason why there is a big space between the first legend and the second legend? did I make a programming mistake?

If there is a way to make it look better please let me know

thanks for the help
Ivan
Ivan attached the following image(s):
legendQ.png (4kb) downloaded 88 time(s).

You cannot view/download attachments. Try to login or register.
Baydalka Volodymyr  
#8 Posted : Tuesday, March 15, 2011 6:35:16 PM(UTC)
Baydalka Volodymyr
Rank: Member

Groups: Registered
Joined: 7/28/2009(UTC)
Posts: 447
Man

Hi,

Unfortunately there is no way to fix it.
Legend arranges items with the same interval - largest item width.

Best regards,
Volodymyr Baydalka
Andriod development and support team
Ivan  
#9 Posted : Wednesday, March 16, 2011 12:11:48 PM(UTC)
Ivan
Rank: Member

Groups: Registered
Joined: 3/7/2011(UTC)
Posts: 25
Location: Albis

thanks for the information...

Ivan
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2017 ArtfulBits. All rights reserved.