|
InterfaceSpecification
Interface specification for Intents and Content Providers
Featured This document covers the basics to get started with charts. See AdvancedFeatures for topics not covered here. Content Provider OverviewUsing Content Providers may be intimidating at first, but learning them will help you write interoperable applications. Event sequenceThe following steps are approximately what happens under the hood when your application wants to plot data with ChartDroid.
To make this process go as planned, you must
Charts in version 2.xTermsIn this document:
Data typeThere are several ways to present data with ChartDroid. To give the user a choice among all of them, the getType() method of your Content Provider should return the string: vnd.android.cursor.dir/vnd.com.googlecode.chartdroid.graphable For event data (values plotted against a time axis; timelines), getType() should return: vnd.android.cursor.dir/vnd.com.googlecode.chartdroid.timeline To limit the presentation options, categories may be added to the Intent:
Content ProviderYour Content Provider should handle three types of queries:
When displaying a chart, these strings will be appended as a value of the "aspect" query parameter of the source Uri as a "callback" to retrieve the various chart data. Therefore, a Content Provider should examine the "aspect" parameter of the Uri and serve the appropriate columns below. (Using query parameters for this instead of the last path segment permits use of the ContentUris.parseId() function.) if ("axes".equals(uri.getQueryParameter("aspect") )) {
... // serve the axes metadata
} else if ("series".equals(uri.getQueryParameter("aspect") )) {
... // serve the series metadata
} else {
... // serve the data
}Note: The data to chart may be generated dynamically in the client by populating a MatrixCursor. If your data already exists in an SQLite-backed database, it is simple to translate the column names. Use a query such as: String[] projection = new String[] {
"ROWID AS " + BaseColumns._ID, // ROWID is the implicit Primary Key generator in SQLite
MY_AXIS_INDEX_COLUMN + " AS " + "COLUMN_AXIS_INDEX",
MY_SERIES_INDEX_COLUMN + " AS " + "COLUMN_SERIES_INDEX",
...
};
db.query(MY_TABLE, projection, ...);Suggestion: You may want to create a VIEW in your database with the column names already transformed to the ones ChartDroid needs. Android lacks facilities to easily perform column name translation within a ContentProvider. "data" Columns
Developers may choose between the scheme below or an alternate column scheme. Currently the "_id" column is ignored in both schemes. Standard Column SchemeIn this scheme, all datum components are in the same row. This scheme is assumed if there exist any column names that start with the prefix "AXIS_". For the purpose of assigning axis properties, axes are ordered lexographically.
Here is an example results table that your application might produce in response to a "data" query:
"series" ColumnsThe "series" query provides labels and other properties for each data series. All columns are optional.
†Marker styles:
‡Line styles:
"axes" ColumnsThe "axes" query provides labels for each axis.
If the columns COLUMN_AXIS_MIN and COLUMN_AXIS_MAX are not present or their value is null, the axis min and max are calculated automatically, and the axis limits are set to ten percent above and below the data range. In the case of a single value, the default axis limits are set to one unit above and below the value. †COLUMN_AXIS_ROLE indicates how the axis values should be expressed, using an integer index from the following table:
If the field is null or the column is omitted entirely, the default sequence of value expression methods is used:
If only a single axis is present in the data, then the value will be expressed along the Vertical axis, with a natural number sequence indexing the values along the Horizontal axis. Intent ExtrasThe only really "mandatory" query in your Content Provider is data; other aspects of the chart may be delivered through Intent extras. The Intent extras, if present, take precedence over the Content Provider.
Charts in version 1.xActions
Categories
ExtrasPie Chart
Defining Java ConstantsIt is handy to have these long strings defined as constants in your application. An easy way to do this, and at the same time keep your application up-to-date against the spec, is to use svn "externals". In your application's src/ directory, create the directory tree com/googlecode/chartdroid. Then cd to the leaf directory you just created, and set the externals property to keep your project in sync with the chartdroid definitions. cd src mkdir -p com/googlecode/chartdroid svn add com cd com/googlecode/chartdroid svn propset svn:externals 'core http://chartdroid.googlecode.com/svn/trunk/core/src/com/googlecode/chartdroid/core' . cd ../../.. svn ci -m "added constants defined in external repo" svn up Now when you call svn up in your project, it automatically fetches the contants I've defined for use with chartdroid. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Any interactive behavior?
The calendar widget lets you click on individual dates to pop up an event list.
The plots are not yet interactive, but I would like to add dragging behavior similar to that of EvenTrend.
Hi, Can i use the library to plot data dynamically? I am yet to learn about ContentProvider? and stuff. I would like to display the bar graphs dynamically i.e the data set i need to display keeps changing in time. If yes, can you please give me a high level steps on how to achieve this behavior?
Thanks.
Hi, I'm a student that need to plot some chart in a project, and I'm trying to use your chart droid, but I can definitely make it work.... please can u help me?!
It seem that chart droid even receive the message... because the query is not called
//this is the intent sent Intent myIntent = new Intent(Intent.ACTION_VIEW,myContentProvider.CONTENT_URI); sendBroadcast(myIntent);
//from manifest <provider
//from provider public static final String PROVIDER_NAME =
public static final Uri CONTENT_URI = Maybe is something wrong with the intent and the authorities??Thank you
Great product! This screenshot is a plot of pitch location for game 6 of last years world series.
This is obviously for fun, since MLB is strict about their API usage. But they have lots of fun data to play with.
http://gd2.mlb.com/components/game/mlb/year_2011/month_10/day_28/gid_2011_10_28_texmlb_slnmlb_1/
One questions. That is a scatter chart... is it possible to control the bubble size on bubble charts?