NativeScript & Vue.JS

Chart LinearAxis

If you followed the getting started article, you now know how to create a chart and add it to a NativeScript page. In this article, you will learn more about the linear axis and how to use it in your chart.

Getting Started

RadCartesianChart requires an axis that can represent the values of the data points. The LinearAxis plots the associated data points using each point's actual value, provided for the axis. The axis works with categorical data and uses the Value property of each CategoricalDataPoint that needs to be plotted. It will build a numerical range (user-defined or automatically calculated) and will determine each data point X or Y coordinate (depending on whether the axis is specified as Horizontal or as Vertical).

Example 1: Linear Axis

import { getCountriesData } from '../../data';

const description = 'Line Series';

export default {
  name: 'LineSeriesExample',
  description: description,
  template: `
  <Page>
    <ActionBar :title="title">
      <NavigationButton text="Back" android.systemIcon="ic_menu_back" @tap="onNavigationButtonTap"></NavigationButton>
    </ActionBar>
    <RadCartesianChart>
      <CategoricalAxis v-tkCartesianHorizontalAxis />
      <LinearAxis v-tkCartesianVerticalAxis />
      <LineSeries v-tkCartesianSeries
                  :items="items"
                  categoryProperty="Country"
                  valueProperty="Amount" />
    </RadCartesianChart>
  </Page>
  `,
  data () {
    return {
      title: description,
      items: getCountriesData(),
    };
  },
  methods: {
    onNavigationButtonTap() {
      Frame.topmost().goBack();
    },
  },
};

Properties

Major Step

The major step represents the value difference between two visible ticks on the axis. The major step unit is used to determine what exactly the value of the major step represents. To get or set the major step use the majorStep property.

Maximum

Defines the maximum available value. To get or set the maximum use the maximum property.

Minimum

Defines the minimum available value. To get or set the maximum use the minimum property.

References

Want to see this scenario in action? Check our SDK Examples repository on GitHub. You will find this and many other practical examples with NativeScript UI.

Examples used in this article:

Related articles you might find useful: