Working with Data

Local Data

  1. You can bind the data to the Sparkline by using [dataSource] property and then you need to map the X and Y value with xName and yName properties respectively.
  • ts
  • this.sparklinedata = [
    { employeeId: 1, sales: 25 },
    { employeeId: 2, sales: 28 },
    { employeeId: 3, sales: 34 },
    { employeeId: 4, sales: 32 },
    { employeeId: 5, sales: 40 },
    { employeeId: 6, sales: 32 },
    { employeeId: 7, sales: 35 },
    { employeeId: 8, sales: 55 },
    { employeeId: 9, sales: 38 },
    { employeeId: 10, sales: 30 }];
  • html
  • <ej-sparkline id="sparklinecontainer"  [dataSource]="sparklinedata" xName="employeeId" yName="sales">          
                                   
    </ej-sparkline>

    ;

    1. You can also bind an array of data to Sparkline by using [dataSource] property.
  • html
  • <ej-sparkline id="sparklinecontainer"  [dataSource]="[ 2, 6, -1, 1, 12, 5, -2, 7, -3, 5, 8, 10]">          
                                   
    </ej-sparkline>

    ;