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
chrlyck  
#1 Posted : Monday, January 17, 2011 3:17:01 AM(UTC)
chrlyck
Rank: Newbie

Groups: Registered
Joined: 1/17/2011(UTC)
Posts: 2

I have come across a (for me) very serious bug in ChartPoint.

I am on a trial license, and need this software for one purpose only. The thing is i will be using the bar chart and i will be using values from 0.0 to approx 3.0. I need to display the labels on each bar.

The problem is that when setting certain y-values (from 0.00 to 1.00) the ChartPoint is registering a different value than the double assigned to it. I have 0 to two digits, examples:
0
0.1
0.11

I used the example on the webpage as a start. Heres my sample code to reproduce the problem (running in android emulator)

I expect all other charts have the same problem, it will only be visible though if the labels are shown.

Please tell me there is a workaround for this. Crying If not i really have to go with some other charting software.

Se the 0-25 screenshot to see the values 0.03, 0.06 and 0.08 being registered as 0.03??0000000002, 0.06??00000005 and 0.8990000000001

The values affected (from 0.0 to 1.0 are:
0.03
0.06
0.08
0.35
0.41
0.47
0.57
0.69
0.70
0.82
0.83
0.94
0.95

As soon as i get past 1.0 there are no problems with this... Bored
This can be seen in the screenshot 0-3, here it is obvious that only the first third of the numbers have bugs in them.

java code (my layout xml is called chart.xml):
Code:
		setContentView(R.layout.chart);
		ChartView chartView = (ChartView) findViewById(R.id.chartView);
		

		ChartSeries series1 = chartView.getSeries().get(0);
		for (int i = 0; i < 25; i++) {
			ChartPoint point = new ChartPoint(0,0);
			point.setX(i);
			point.setY(Double.parseDouble(""+i)/100);
			series1.getPoints().add(point);
		}
		
		series1.getActualXAxis().setGridVisible(false);
		series1.getActualYAxis().setGridVisible(false);
		series1.getActualXAxis().setLabelsMode(LabelsMode.SeriesLabels);


layout xml (layout/chart.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
  <com.artfulbits.aiCharts.ChartView
    android:id="@+id/chartView"
    chart="@xml/chart"
    android:background="@android:drawable/alert_dark_frame" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>
</LinearLayout>


chart config (xml/chart.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<chart>
	<area>
		<area.xaxis title="Sales"/>
		<area.yaxis title="Date"/>
	</area>
	<series type="Bar" color="#FFE0400A" showlabel="true" halign="Near"/>
</chart>


Edit:
I'd like to add that the 13 numbers mentioned above are not the only numbers having the problem, when moving to an even higher precision the bugs are plenty, i don't need this though.
Examples are:
0.003
0.005
0.006
0.007
0.013
0.015
...

Edited by user Monday, January 17, 2011 3:34:51 AM(UTC)  | Reason: Not specified

File Attachment(s):
0-25.tif (45kb) downloaded 6 time(s).
0-3.tif (51kb) downloaded 6 time(s).

You cannot view/download attachments. Try to login or register.
chrlyck  
#2 Posted : Monday, January 17, 2011 9:53:28 PM(UTC)
chrlyck
Rank: Newbie

Groups: Registered
Joined: 1/17/2011(UTC)
Posts: 2

Found a workaround.

To translate to this example i do:

Code:
        ChartSeries series1 = chartView.getSeries().get(0);
        for (int i = 0; i < 25; i++) {
            ChartPoint point = new ChartPoint(0,0);
            point.setX(i);
            point.setY(Double.parseDouble(""+i)/100);
            point.setLabel(Double.parseDouble(""+i)/100+"");
            series1.getPoints().add(point);
        }


Would be nice with a fix though Smile
Baydalka Volodymyr  
#3 Posted : Tuesday, January 18, 2011 4:11:51 PM(UTC)
Baydalka Volodymyr
Rank: Member

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

Hi,

Sometimes bugs like that may appear. This is related to float-point mathematic and we can't do much to fix it. We recommend to use ChartSeries.setLabelFormat method to determinate labels format.

Example : series1.setLabelFormat("{YVALUE0,#.##}");

Best regards,
Volodymyr Baydalka
Andriod development and support team
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.