ChartExpert API Reference

このエントリーをはてなブックマークに追加

日本語

How to Use ChartExpert API

Just start an Activity with chart:///show as a URI and an Intent having a command string as follows;

Intent intent = new Intent(
    Intent.ACTION_VIEW,
    Uri.parse("chart:///show"));
intent.putExtra(
    "content",
    "_client=ChartExpert Demo\n" +
    "_version=1\n" +
    "sample.y=20,22,25,30,28\n" +
    "sample.x=0,1,2,5,6\n" +
    "chart.type=line\n" +
    "chart.dataset=sample\n" +
    "chart.title=Sample Chart"
    );
startActivity(intent);

intent.putExtra(“content”, CommandString);
startActivity(intent);

Retrieve the return code (ver.1.1 or later)

Use startActivityForResult() to retrieve the return code from the ChartExpert.

How to use

private static final int CHARTEXPERT_REQUEST_CODE = 0;
private static final int CHARTEXPERT_RESULT_SUCCESS = Activity.RESULT_OK;
private static final int CHARTEXPERT_RESULT_CANCELED = Activity.RESULT_CANCELED;
private static final int CHARTEXPERT_RESULT_OLDER_CLIENT = Activity.RESULT_FIRST_USER + 0;
private static final int CHARTEXPERT_RESULT_NEWER_CLIENT = Activity.RESULT_FIRST_USER + 1;
private static final int CHARTEXPERT_RESULT_SYNTAX_ERROR = Activity.RESULT_FIRST_USER + 4;

private void startChartExpert() {
    Intent intent = new Intent(
        Intent.ACTION_VIEW,
        Uri.parse("chart:///show"));
    intent.putExtra("content", CommandString);
    startActivityForResult(intent, CHARTEXPERT_REQUEST_CODE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if ( requestCode == CHARTEXPERT_REQUEST_CODE ) {
        String msg;
        switch ( resultCode ) {
        case CHARTEXPERT_RESULT_SUCCESS :
            msg = "RESULT_SUCCESS";
            break;
        case CHARTEXPERT_RESULT_CANCELED :
            msg = "RESULT_CANCELED";
            break;
        case CHARTEXPERT_RESULT_OLDER_CLIENT :
            msg = "RESULT_OLDER_CLIENT";
            break;
        case CHARTEXPERT_RESULT_NEWER_CLIENT :
            msg = "RESULT_NEWER_CLIENT";
            break;
        case CHARTEXPERT_RESULT_SYNTAX_ERROR :
            msg = "RESULT_SYNTAX_ERROR";
            break;
        default :
            msg = "Unknown result code.";
        }
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
    }
}

CHARTEXPERT_RESULT_SUCCESS (= Activity.RESULT_OK = -1)

This value won’t be returned because ChartExpert always closes when user pushes back button. It is reserved for future use.

CHARTEXPERT_RESULT_CANCELED (= Activity.RESULT_CANCELED = 0)

This value will be returned when returned from ChartExpert successfully,

CHARTEXPERT_RESULT_OLDER_CLIENT (= Activity.RESULT_FIRST_USER + 0 = 1)

This value will be returned if _version is smaller than the minimum version supported by ChartExpert.

CHARTEXPERT_RESULT_NEWER_CLIENT (= Activity.RESULT_FIRST_USER + 1 = 2)

This value will be returned if _version is larger than the maximum version supported by ChartExpert.

CHARTEXPERT_RESULT_SYNTAX_ERROR (= Activity.RESULT_FIRST_USER + 4 = 5)

This value will be returned if CommandString has any errors.

Command Reference

Syntax

Specify following commands. A command per line and each line separated by “\n”. Specifying order is non-sensitive.

  • _client=<NAME>
  • _version=<VERSION>
  • <CKEY>.title=<TITLE>
  • <CKEY>.type=<TYPE>
  • <CKEY>.dataset=<DKEY1>[,<DKEY2>[...]]
  • <CKEY>.colortheme=<COLORTHEME>
  • <CKEY>.position=<POSITION>
  • <DKEY>.y=<Y>
  • <DKEY>.x=<X>
  • <DKEY>.label=<LABEL>
  • <DKEY>.level=<LEVEL>
  • <DKEY>.ylabel=<YLABEL>
  • <DKEY>.xlabel=<XLABEL>
  • <DKEY>.yaxis=<YMIN>,<YMAX>[,<YSTEP>]
  • <DKEY>.xaxis=<XMIN>,<XMAX>[,<XSTEP>]
  • <DKEY>.color=<COLOR>

Terms

CKEY : Chart Key

A key to identify charts. It is used as a prefix of chart commands. Any declarations is required before use.

CKEY and DKEY can be a same name.

DKEY : Dataset Key

A key to identify datasets. It is used as a prefix of dataset commands. Any declarations is required before use.

CKEY and DKEY can be a same name.

Reference

_client=<NAME> : Name of Client.

Specify a name of a client app.

It is a required command.

Only single _client command can exist in a command string.

Example:

_client= KaraLog

_version=<VERSION> : API Version

Specify a version of ChartExpert API which a client expects. Currently 1 is the only valid number.

It is a required command.

Only single _client command can exist in a command string.

Example:

_version=1

<CKEY>.title=<TITLE> : Chart Title

Specify a title of a chart.

It is an option command. No title if it is not specified.

1 title command can be specified for each CKEY.

Example:

chart.title=My Weight

<CKEY>.type=<TYPE> : Chart Type

Specify a type of a chart. <TYPE> can be one of line, vbar, scatter, or pie.

It is a required command.

It can be specified for each CKEY.

Example:

chart.type=line

<CKEY>.dataset=<DKEY1>[,<DKEY2>[,...]]: Dataset

Specify datasets to be used for the chart.

<DKEYn> can be one of declared dataset key. To make a complex chart, multiple DKEY can be specified separated by comma except for Pie chart case.

x, xlabel of <DKEY1> will be used for a complex chart.

It is required command.

It can be specified for each CKEY.

Example:

chart.dataset=weight

<CKEY>.colortheme=<COLORTHEME> : Color Theme

Specify a color theme for a chart.

<COLORTHEME> can be one of morning, daytime, evening, night (ver.1.0), spring, summer, fall, or winter (ver.1.1).

It is an option command. daytime is used if not specified.

It can be specified for each CKEY.

Example:

chart.colortheme=daytime

<CKEY>.position=<POSIITON>: Initial Position

Specify an initial position.

<POSITION> can be one of first or last. If first is specified, a chart is initially scrolled to the head of the chart. last is to the tail.

It is an option command. first is used if not specified.

It can be specified for each CKEY.

Example:

chart.position=last

<DKEY>.y=<Y> : y Value

Specify y values as numbers separated by comma. Blank entry, which is no number between two commas, is treated as “no number”.

y values is typically used for y coordinate, but its meaning depends on a type of a chart.

It is required command.

It can be specified for each DKEY.

Example:

weight.y=62.5,63.1,62.7,,62.3

<DKEY>.x=<x> : x Value

Specify x values as numbers separated by comma. Blank entry, which is no number between two commas, is treated as “no number”.

x values is typically used for x coordinate, but its meaning depends on a type of a chart.

It is optional command. 0,1,2,3,…,(the number of y values – 1) is used if not specified.

It can be specified for each DKEY.

Example:

weight.x=0,1,2,3,4

<DKEY>.label=<LABEL> : Value Label

Specify labels attached to data as text string separated by comma. Blank entry, which is no number between two commas, is treated as “no label”.

It is optional command. “no label” is used for all entries if not specified.

It can be specified for each DKEY.

Example:

weight.label=62.5,63.1,62.7,,62.3

<DKEY>.ylabel=<YLABEL> : y Axis Label

Specify labels attached to y axis as text string separated by comma. Blank entry, which is no number between two commas, is treated as “no label”.

It is optional command. “no label” is used for all entries if not specified.

It can be specified for each DKEY.

Example:

questionnaire.ylabel=very bad,bad,normal,good,very good

<DKEY>.xlabel=<XLABEL> : x Axis Label

Specify labels attached to x axis as text string separated by comma. Blank entry, which is no number between two commas, is treated as “no label”.

It is optional command. “no label” is used for all entries if not specified.

It can be specified for each DKEY.

Example:

weight.xlabel=Jul/15,16,17,18,19

<DKEY>.yaxis=<YMIN>,<YMAX>[,<YSTEP>] : y Range and Tick Mark Step

Specify y axis configuration with a minimum, a maximum, and a step of tick marks as real numbers.

It is optional command. It will be automatically determined from dataset if not specified.

It can be specified for each DKEY.

Example:

weight.yaxis=0,10,0.5

<DKEY>.xaxis=<XMIN>,<XMAX>[,<XSTEP>] : x Range and Tick Mark Step

Specify x axis configuration with a minimum, a maximum, and a step of tick marks as real numbers.

It is optional command. 0,(the number of y values – 1),1 will be used if not specified.

It can be specified for each DKEY.

Example:

weight.xaxis=1,7,1

<DKEY>.color=<COLOR> : Color

Specify color as a color name or a color code.

<COLOR> can be one of red, orange, yellow, lightgreen, green, blue, purple, violet,

or a color code by specifing #RRGGBB format.

It is optional command. Color code is automatically deteremined if not specified.

It can be specified for each DKEY.

Example:

weight.color=orange
weight.color=#A0B073

Supported commands

ChartExpert Version 1.0 1.0 >1.1 >1.1
_version 1 2 1 2
<CKEY>.title Y Error Y Y
<CKEY>.type Y Error Y Y
<CKEY>.dataset Y Error Y Y
<CKEY>.colortheme Y Error Y Y
<CKEY>.position Y Error Y Y
<DKEY>.y Y Error Y Y
<DKEY>.x Y Error Y Y
<DKEY>.label Y Error Y Y
<DKEY>.xlabel Y Error Y Y
<DKEY>.ylabel Y Error Y Y
<DKEY>.xaxis Y Error Y Y
<DKEY>.yaxis Y Error Y Y
<DKEY>.color Error Error Ignored Y
© 2017 samurai-apps. All rights reserved. Powered by WordPress Entries RSS Comments RSS