• Demos
    • JavaScript Charts
    • JavaScript StockCharts
  • Download/NPM
    • Download CanvasJS
    • Install via NPM
  • Integrations
    • Front End Technology Samples
      • React Charts
      • Angular Charts
      • Vue.js Charts New!
      • jQuery Charts
      • Dashboards
    • Server Side Technology Samples
      • PHP Charts
      • Python Charts New!
      • ASP.NET MVC Charts
      • Spring MVC Charts
      • JSP Charts
  • License
  • Blog
  • Docs
    • Chart Documentation
    • StockChart Documentation
  • Support Forum
    • Chart Support
    • StockChart Support
  • My Account
  • My Account
  • KEY FEATURES
    • Chart with Index / Data Label
    • Chart with Zooming & Panning
    • Multi Series Chart
    • Chart with Multiple Axes
    • Combination Charts
    • Chart with Animation
    • Chart with Logarithmic Axis
    • Dynamic Chart
    • Chart with Data from AJAX
    • Drilldown Chart
    • Responsive Chart
    • Synchronized Charts
  • LINE CHARTS
    • Line Chart with Date-Time Axis
    • Dashed Line Chart
    • Multi Series Line Chart
    • Spline Chart
    • Multi Series Spline Chart
    • Step Line Chart
    • Multi Series Step Line Chart
  • BAR CHARTS
    • Bar Chart with Category Axis
    • Multi Series Bar Chart
    • Stacked Bar Chart
    • Stacked Bar 100% Chart
    • Stacked Bar 100% Chart with Indexlabels
  • COLUMN CHARTS
    • Column Chart with Numeric Axis
    • Multi Series Column Chart
    • Stacked Column Chart
    • Stacked Column 100% Chart
    • Stacked Column 100% Chart with Indexlabel
    • Waterfall Chart
    • Waterfall Chart with Indexlabels
    • Multi Series Waterfall Chart
  • PIE & DOUGHNUT CHARTS
    • Pie Chart with Index Labels
    • Pie Chart in Dark Theme
    • Doughnut Chart with Index Labels
    • Doughnut Chart in Dark Theme
  • AREA CHARTS
    • Area Chart with Indexlabels
    • Multi Series Area Chart
    • Spline Area Chart
    • Multi Series Spline Area Chart
    • Step Area Chart
    • Stacked Area Chart
    • Stacked Area 100% Chart
  • RANGE CHARTS
    • Range Column Chart
    • Multi Series Range Column Chart
    • Range Bar Chart
    • Multi Series Range Bar Chart
    • Range Area Chart
    • Multi Series Range Area Chart
    • Range Spline Area Chart
    • Multi Series Range Spline Area Chart
  • BUBBLE & SCATTER CHARTS
    • Bubble Chart with Indexlabels
    • Bubble Chart with 3 Dimensional Data
    • Multi Series Scatter Chart
  • FUNNEL & PYRAMID CHARTS
    • Funnel Chart with Index Labels
    • Funnel Chart without Neck
    • Pyramid Chart with Index Labels
  • FINANCIAL CHARTS
    • Candlestick Chart
    • Multi Series Candlestick Chart
    • OHLC Chart
    • OHLC Chart from JSON data
    • Box & Whisker Chart
  • COMBINATION CHARTS
    • Error Bar Chart
    • Pareto Chart
    • Range Area & Line Chart
    • Candlestick & Line Chart
    • OHLC Chart with Trend
  • DYNAMIC CHARTS
    • Dynamic / Live Line Chart
    • Dynamic / Live Column Chart
    • Dynamic / Live Multi Series Chart
  • STOCKCHARTS
    • StockChart with Numeric Axis
    • StockChart with Date-Time Axis
    • StockChart with Navigator & Range Selector
  • JAVASCRIPT, REACT, VUE.JS, JQUERY
    • JavaScript Charts
    • React Charts
    • Vue.js Charts
    • jQuery Charts
  • SERVER SIDE TECHNOLOGIES
    • ASP.NET MVC Charts
    • JSP Charts
    • PHP Charts
    • Python Charts
    • Spring MVC Charts

Angular StockChart with Navigator & Range Selector

Download Angular Chart Samples
  • Angular Chart Samples
  • JavaScript Chart Samples
  • React Chart Samples
  • Vue.js Chart Samples
  • jQuery Chart Samples
  • PHP Chart Samples
  • Python Django Chart Samples
  • ASP.NET Chart Samples
  • JSP Chart Samples
  • Spring MVC Chart Samples
  • Dashboard Samples
  • JavaScript StockChart Samples

Angular StockChart Component comes with elements like navigator & range-selector which lets you control the range of data shown inside viewport of the charts. StockChart has built-in feature to synchronize tooltip & crosshair across all the charts within a StockChart.

  • Component Code
  • Module Code
  • HTML Code
//app.component.ts
import { Component } from '@angular/core';
import * as data from '../assets/btcusd2018.json';

/* Tutorial: https://www.javatpoint.com/display-data-from-json-file-in-angular */
interface JsonData {
  "date": string,
  "open": number,
  "high": number,
  "low": number,
  "close": number,
  "volume_btc": number
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {
  dps1: any = [];
  dps2: any = [];
  dps3: any = [];
  
  stockChartOptions = {
    theme: "light2",
    exportEnabled: true,
    title:{
      text:"Bitcoin Price & Volume"
    },
    charts: [{
      toolTip: {
        shared: true
      },
      axisX: {
        lineThickness: 5,
        tickLength: 0,
        labelFormatter: function() {
          return "";
        }
      },
      axisY: {
        prefix: "$"
      },
      legend: {
        verticalAlign: "top"
      },
      data: [{
        showInLegend: true,
        name: "Stock Price (in USD)",
        yValueFormatString: "$#,###.##",
        type: "candlestick",
        dataPoints : this.dps1
      }]
    },{
      height: 100,
      toolTip: {
        shared: true
      },
      axisY: {
        prefix: "$",
        labelFormatter: function(e: any){
          var suffixes = ["", "K", "M", "B"];
          var order = Math.max(Math.floor(Math.log(e.value) / Math.log(1000)), 0);
          if(order > suffixes.length - 1)
            order = suffixes.length - 1;
          var suffix = suffixes[order];
          return (e.value / Math.pow(1000, order)) + suffix;
        }
      },
      legend: {
        verticalAlign: "top"
      },
      data: [{
        showInLegend: true,
        name: "Volume (BTC/USD)",
        yValueFormatString: "$#,###.##",
        dataPoints : this.dps2
      }]
    }],
    navigator: {
      data: [{
        dataPoints: this.dps3
      }],
      slider: {
        minimum: new Date(2018, 2, 1),
        maximum: new Date(2018, 9, 31)
      }
    }
    }
    
  jsonData: JsonData[] = (data as any).default;

  ngOnInit(){
    for(var i = 0; i < this.jsonData.length; i++) {
      this.dps1.push({x: new Date(data[i].date), y: [Number(data[i].open), Number(data[i].high), Number(data[i].low), Number(data[i].close)]});
      this.dps2.push({x: new Date(data[i].date), y: Number(data[i].volume_usd)});
      this.dps3.push({x: new Date(data[i].date), y: Number(data[i].close)});
    }
  }	
}                              
//app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

import { CanvasJSAngularStockChartsModule } from '@canvasjs/angular-stockcharts';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    CanvasJSAngularStockChartsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }                        
<!-- app.component.html -->
<div>
    <canvasjs-stockchart [options]="stockChartOptions" [styles]="{width: '100%', height: '450px'}"></canvasjs-stockchart>    
</div>                        

Chart Customizations

  • enabled
  • selectedRangeButtonIndex
  • navigator.dynamicUpdate

Note   For step by step instructions, follow our Angular Integration Tutorial
© fenopix
  • About Us
  • FAQs
  • Careers
  • Privacy Policy
Server Side Technologies
  • ASP.NET MVC Charts
  • PHP Charts
  • JSP Charts
  • Spring MVC Charts
Front End Technologies
  • JavaScript Charts
  • jQuery Charts
  • React Charts
  • Angular Charts
  • JavaScript StockCharts
Contact
  • Fenopix, Inc.
  • 2093 Philadelphia Pike,
  • #5678, Claymont,
  • Delaware 19703
  • United States Of America