Angular Dashed Line Charts are plotted by connecting datapoints with a dashed line instead of solid line.
/* app.component.ts */ import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; import { CommonModule } from '@angular/common'; import { CanvasJSAngularChartsModule } from '@canvasjs/angular-charts'; @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet, CommonModule, CanvasJSAngularChartsModule], templateUrl: './app.component.html', styleUrl: './app.component.css', }) export class AppComponent { chartOptions = { animationEnabled: true, theme: "light2", title:{ text: "Site Traffic" }, axisX:{ valueFormatString: "DD MMM", crosshair: { enabled: true, snapToDataPoint: true } }, axisY: { title: "Number of Visits", crosshair: { enabled: true } }, toolTip:{ shared:true }, legend:{ cursor: "pointer", verticalAlign: "bottom", horizontalAlign: "right", dockInsidePlotArea: true, itemclick: function(e: any) { if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) { e.dataSeries.visible = false; } else{ e.dataSeries.visible = true; } e.chart.render(); } }, data: [{ type: "line", showInLegend: true, name: "Total Visit", lineDashType: "dash", markerType: "square", xValueFormatString: "DD MMM, YYYY", dataPoints: [ { x: new Date(2022, 0, 3), y: 650 }, { x: new Date(2022, 0, 4), y: 700 }, { x: new Date(2022, 0, 5), y: 710 }, { x: new Date(2022, 0, 6), y: 658 }, { x: new Date(2022, 0, 7), y: 734 }, { x: new Date(2022, 0, 8), y: 963 }, { x: new Date(2022, 0, 9), y: 847 }, { x: new Date(2022, 0, 10), y: 853 }, { x: new Date(2022, 0, 11), y: 869 }, { x: new Date(2022, 0, 12), y: 943 }, { x: new Date(2022, 0, 13), y: 970 }, { x: new Date(2022, 0, 14), y: 869 }, { x: new Date(2022, 0, 15), y: 890 }, { x: new Date(2022, 0, 16), y: 930 } ] }, { type: "line", showInLegend: true, name: "Unique Visit", lineDashType: "dot", dataPoints: [ { x: new Date(2022, 0, 3), y: 510 }, { x: new Date(2022, 0, 4), y: 560 }, { x: new Date(2022, 0, 5), y: 540 }, { x: new Date(2022, 0, 6), y: 558 }, { x: new Date(2022, 0, 7), y: 544 }, { x: new Date(2022, 0, 8), y: 693 }, { x: new Date(2022, 0, 9), y: 657 }, { x: new Date(2022, 0, 10), y: 663 }, { x: new Date(2022, 0, 11), y: 639 }, { x: new Date(2022, 0, 12), y: 673 }, { x: new Date(2022, 0, 13), y: 660 }, { x: new Date(2022, 0, 14), y: 562 }, { x: new Date(2022, 0, 15), y: 643 }, { x: new Date(2022, 0, 16), y: 570 } ] }] } }
/* app.component.html */ <div> <canvasjs-chart [options]="chartOptions" [styles]="{width: '100%', height:'360px'}"></canvasjs-chart> </div>
In the above example, dotted & dashed lines are shown by setting lineDashType property. Dash type of line between datapoints also be controlled by setting lineDashType in datapoints level. The thickness of line can be set using lineThickness property.
Note For step by step instructions, follow our Angular Integration Tutorial