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

[SOLVED] Creating and displaying charts at runtime Options · View
s_pai
#1 Posted : Monday, February 21, 2011 9:41:31 PM
Rank: Newbie

Groups: Registered

Joined: 2/21/2011
Posts: 3
Hello,

We're evaluating aiCharts and I hit a roadblock. We need to create charts dynamically at runtime, from XML. I can't seem to find any good examples of this, are there any?

The following is what I'm trying right now and it doesn't display a chart, only the trial license message.

onCreate contains:
Code:
ChartView chartView = new ChartView(this);

XmlPullParser parser;
try {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    parser = factory.newPullParser();
    parser.setInput(new InputStreamReader(getAssets().open("chart.xml")));
} catch (XmlPullParserException e) {
    Log.e(TAG, "Failed to get XmlPullParserFactory", e.getCause());
    return;
} catch (IOException e) {
    Log.e(TAG, "Failed to open data.xml", e.getCause());
    return;
}
       
ChartEngine chart = new ChartEngine(getResources(), parser);
chartView.setChart(chart);

LinearLayout layout = new LinearLayout(this);
layout.addView(chartView);
setContentView(layout);


chart.xml contains:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<chart>
    <title text="Chart XML Sample"/>
    <area/>
    <series type="Column" showlabel="true" points="20, 10, 40, 30, 50"/>
    <legend dock="Right"/>
</chart>


Am I using ChartEngine incorrectly? Missing something else obvious? Any pointers are greatly appreciated, thanks!

Sami

edit: I logged chartView.getAreas() before and after calling setChart(), and it remains empty. Perhaps I should set the XML parser to a specific state before passing it to ChartEngine.
Baydalka Volodymyr
#2 Posted : Tuesday, February 22, 2011 4:20:29 PM
Rank: Developers Team


Groups: Registered, Administrators

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

Thank you for bug report. The problem is that XML contains inner text (space/tab chars). Android APK builder usually compresses XML resources (aiCharts usually works with XML from resources) and removes empty text. Try to remove spaces and tabs from your XML for now.

Best regards,
Volodymyr Baydalka
Andriod development and support team
s_pai
#3 Posted : Tuesday, February 22, 2011 6:57:27 PM
Rank: Newbie

Groups: Registered

Joined: 2/21/2011
Posts: 3
Removing the extra whitespace works. Thanks!
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.