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

addDate getting smashed on chart Options · View
mdhari
#1 Posted : Wednesday, January 19, 2011 10:14:01 PM
Rank: Newbie

Groups: Registered

Joined: 1/13/2011
Posts: 7
Location: Bay Area
Hi All,

So adding data to my chart through addDate. It's successfully doing so but there is a problem where every addDate adds a gridline and a label and you can see the attached image as to what happens. (that grey is not the background color but the gridlines coming together). Obviously I'm been trying to set Intervals and stuff but I'm not really having success.

I'm looking at other forum posts about "autoscaling" and stuff and tried them out too. Do I have to maybe have to set an absolute date range for the axis?

Ideally, what I want is for every 21 days to show a grid line. That's all I really want. I'm see an example where its possible to make a custom axis formatter but I would assume there is a pretty straightforward solution for this.

It also seems like I shot myself in the foot on this one because I need transformations to figure out the hardware X to an actual X value but I get a double back instead of a Date.

Here is what I tried:

Quote:
chartArea.getDefaultXAxis().setValueType(ChartAxis.ValueType.Date);
//chartArea.getDefaultXAxis().getScale().setIntervalType(ChartAxisScale.IntervalType.Years);
chartArea.getDefaultXAxis().getScale().setInterval(21.0, ChartAxisScale.IntervalType.Days);
chartArea.getDefaultXAxis().setLabelsMode(LabelsMode.NoLabels);
chartArea.getDefaultXAxis().setFormat(new SimpleDateFormat("yyyy.MM.dd"));
//chartArea.getDefaultXAxis().getScale().setDateRange(new Date(2008-1900,1,1), new Date(2010-1900,1,1));


How data is getting added later:

Quote:
for(TableRowData listElement: tableData){

areaSeries.getPoints().addDate(listElement.getDate(), listElement.getBookDoubleRev());
Log.i(TAG, "added:" + listElement.getDate().getYear() + " " + listElement.getDate().getMonth() + " " + listElement.getDate().getDay()
+ " book " + listElement.getBookDoubleRev());
}


I have a funny feeling that I might have to override the addDate function to prevent it from adding a label and gridline.

Thanks,
Michael



mdhari attached the following image(s):
smashedDates.png (55kb) downloaded 67 time(s).
mdhari
#2 Posted : Thursday, January 20, 2011 12:46:48 AM
Rank: Newbie

Groups: Registered

Joined: 1/13/2011
Posts: 7
Location: Bay Area
Here is a short version of what I was trying to achieve:

A chart that had a range selector over data that contained a money value as the y and the date as the x.

The problem:

In order for me to calculate a profit or loss based on what range user has selected, there is a transformation that takes place from hardware x to chart coordinate x. But obviously setting the x values as dates is an issue.

What I need is the 0 on the x axis to be the first date value and from there go on while the transform function gives me an a date value for that x value so I set a start and end point for the range selection. Either that or the actual x value on the chart so I can set the range selection correctly.

But obviously there would be some formatting on the x axis to allow only some dates to be seen.

~Michael

maxb
#3 Posted : Thursday, January 20, 2011 10:37:38 AM
Rank: Newbie

Groups: Registered

Joined: 10/7/2010
Posts: 1
Hi,

try to change the LabelsMode from NoLabels to RangeLabels or HybridLabels.
Baydalka Volodymyr
#4 Posted : Thursday, January 20, 2011 7:31:54 PM
Rank: Developers Team


Groups: Registered, Administrators

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

Please, try to use axis.setLabelsMode(LabelsMode.RangeLabels) and getScale().setInterval methods to setup labels/grid interval.

Best regards,
Volodymyr Baydalka
Andriod development and support team
mdhari
#5 Posted : Wednesday, January 26, 2011 10:01:07 PM
Rank: Newbie

Groups: Registered

Joined: 1/13/2011
Posts: 7
Location: Bay Area
Hi,

Thanks for the reply, its fixed.

Will aiCharts implement another feature to ChartTransform so that getX and getY will return an Object instead of a double.

The reason I ask is because I set the chart series through addDate, and ChartTransform.getX will return a garbage double which doesn't correspond to anything on the chart. I just want the Date object I set earlier.

I noticed as well through documentation that addDate "Internally sets ValueType property on series to ChartAxis.ValueType.Double"
Baydalka Volodymyr
#6 Posted : Thursday, January 27, 2011 5:59:16 PM
Rank: Developers Team


Groups: Registered, Administrators

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

Current version of conversation double-to-date is simple. Try to use following code
Code:
Date date = new Date((long)doubleValue);


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-2016 ArtfulBits. All rights reserved.