whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
WHY ARTFULBITS
whitespace
OUR APPROACH
whitespace
OUR TEAM
whitespace
FACT SHEET
whitespace
NEWS & EVENTS
whitespace
PRIVACY
whitespace
whitespace

Spline Chart Type

Overview

The term "spline" is used to refer to a wide class of functions that are used in applications requiring data interpolation and/or smoothing. This term more frequently refers to a piecewise polynomial (parametric) curve. Splines are popular curves in mathematics and computer science due to simplicity of their construction, ease and accuracy of evaluation and capacity to approximate complex shapes through curve fitting and interactive curve design. Spline functions for interpolation are normally determined as the minimizers of suitable measures of roughness subject to the interpolation constraints. Splines are very useful for modeling arbitrary functions, and are used extensively in computer graphics. Spline charts allow you to take a limited set of known data points and approximate transitional values. aiCharts uses B-spline function for interpolation. The B-spline is a generalization of a Bézier curve. B-spline curves require more information and a more complex theory than Bézier curves. But, it has more advantages. First, a B-spline curve can be a Bézier curve. Second, B-spline curves satisfy all important properties that Bézier curves have. Third, B-spline curves provide more control flexibility than Bézier curves can do.

Creating the Spline Chart

In order to create a simple spline chart is needed to create an instance of chart series, set ChartType as Spline and fill series with the data, like in the following sample:

zip archive Download sample

<?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>
package com.artfulbits.aiCharts.splinesample;

import com.artfulbits.aiCharts.ChartView;
import com.artfulbits.aiCharts.Base.ChartSeries;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity
{
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		ChartView chartView = (ChartView) findViewById(R.id.chartView);

		ChartSeries series1 = chartView.getSeries().get("Sinus");
		ChartSeries series2 = chartView.getSeries().get("Cosinus");

		for (int i = 0; i < 20; i++)
		{
			series1.getPoints().addXY(i, Math.sin(i));
			series2.getPoints().addXY(i, Math.cos(i));
		}
	}
}
<?xml version="1.0" encoding="utf-8"?>
<ai:chart xmlns:ai="http://www.artfulbits.com/android/aiCharts">
	<ai:area>
		<ai:area.xaxis scale_interval="3.14159265" scale_min="0" scale_max="19"/>
		<ai:area.yaxis labels_visible="false"/>
	</ai:area>
	<ai:series type="Spline" name="Sinus"/>
	<ai:series type="Spline" name="Cosinus"/>
	<ai:legend/>
</ai:chart>
Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2016 ArtfulBits. All rights reserved.