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 Search | Active Topics | Log In | Register

Axis grid Options · View
roberto
#1 Posted : Wednesday, January 16, 2013 3:48:30 PM
Rank: Newbie

Groups: Registered

Joined: 1/16/2013
Posts: 6
Hi,
I'm evaluating the ArtfulBits Android Library.
I've a question about grid definition. My need is define a fixed number of lines for the x grid and y grid.

I'll show you an example:
Code:

ChartView chartView = new ChartView(this);
ChartArea area = new ChartArea();
ChartSeries series = new ChartSeries("", ChartTypes.Area);    
/*The following instruction in inside a loop. I've remove it due problem with the forum.*/
series.getPoints().addDate(timestamp[i], value[i]);
        
ChartAxisScale axisScaleY = area.getDefaultYAxis().getScale();
axisScaleY.setRange(0.4500, 0.480);
axisScaleY.setDesiredIntervalCount(3);
ChartAxisScale axisScaleX = area.getDefaultXAxis().getScale();
axisScaleX.setDesiredIntervalCount(5);
chartView.getSeries().add(series);
chartView.getAreas().add(area);
ChartAxis x_axis = area.getDefaultXAxis();
x_axis.setValueType(ValueType.Date);
ChartAxis y_axis = area.getDefaultYAxis();
y_axis.setValueType(ValueType.Double);
y_axis.setLabelsAdapter(ChartAxis.SMART_LABELS_ADAPTER);
setContentView(chartView);


I obtain the following chart:


I need to show the horizontal grid line at quote 0.48 but it isn't shown. Is it possible reach this objective?

Another question, if I increase the desired interval count for x axis from 5 to, for example, 7 it doesn't work. How can i define exactly the number of interval? It seems that the method ChartAxisScale.setDesiredIntervalCount() does not guarantee the effect.

Also i've tried to use ChartAxisScale.setInterval() but i don't have any modification.

Thank you in advance.
Best regards,

Roberto
Baydalka Volodymyr
#2 Posted : Wednesday, January 16, 2013 4:49:39 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

It's problem of double precision calculation. We try to find good solution to fix it in next release. For now, you may set grid interval manually. Example:
axisScaleY.setInterval(Double.valueOf(0.01f)); // Use float to avoid precision problem.

ChartAxisScale.setDesiredIntervalCount value used to find desired interval. It's not a exactly number of intervals. Pseudo-code : interval = ChartRoundFunc((max - min) / desiredIntervalCount)

Best regards,
Volodymyr Baydalka
Andriod development and support team
roberto
#3 Posted : Wednesday, January 16, 2013 6:43:31 PM
Rank: Newbie

Groups: Registered

Joined: 1/16/2013
Posts: 6
Baydalka Volodymyr wrote:
Hi,

It's problem of double precision calculation. We try to find good solution to fix it in next release. For now, you may set grid interval manually. Example:
axisScaleY.setInterval(Double.valueOf(0.01f)); // Use float to avoid precision problem.

ChartAxisScale.setDesiredIntervalCount value used to find desired interval. It's not a exactly number of intervals. Pseudo-code : interval = ChartRoundFunc((max - min) / desiredIntervalCount)

Best regards,


Thank you for the response.

I've removed ChartAxisScale.setDesiredIntervalCount() and i've introduced setInterval definition as you suggested me: all works as expected.

I've another question about grid.
I define a chart adding points to series using:
Code:
series.getPoints().addXY(i, value[i]);


I don't define anything for x axis and x axis scale except some custom labels:
Code:
x_axis.setLabelsAdapter(null);
x_axis.getCustomLabels().clear();
[...]
x_axis.getCustomLabels().add(new ChartAxis.Label(myLabel, point));


As result i obtain correctly labels on x axis but no vertical grid appears in correspondence with a label. How can i resolve this issue?

Thank you.
Best regards,

Roberto

Baydalka Volodymyr
#4 Posted : Thursday, January 17, 2013 3:54:02 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

Use ChartAxis.Label options to show grid. Example: new ChartAxis.Label(myLabel, point, ChartAxis.Label.OPTION_ALL).

Also, you may implement your own LabelsAdapter instead of use custom labels. Please check sample from [aiCharts package]\Samples\New.Features\CustomLabelsAdapterSample

Best regards,
Volodymyr Baydalka
Andriod development and support team
roberto
#5 Posted : Monday, January 21, 2013 12:11:39 PM
Rank: Newbie

Groups: Registered

Joined: 1/16/2013
Posts: 6
Baydalka Volodymyr wrote:
Hi,

Use ChartAxis.Label options to show grid. Example: new ChartAxis.Label(myLabel, point, ChartAxis.Label.OPTION_ALL).

Also, you may implement your own LabelsAdapter instead of use custom labels. Please check sample from [aiCharts package]\Samples\New.Features\CustomLabelsAdapterSample

Best regards,


Hi,
using new ChartAxis.Label(myLabel, point, ChartAxis.Label.OPTION_ALL) it works as expected. I'll analyze the other suggestion you've suggested.

Thank you.
Best regards
Roberto
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-2016 ArtfulBits. All rights reserved.