Search code examples
angularangular6kendo-gridkendo-chart

How to add vertical and horizontal scrollbar to the Kendo chart


I am using the kendo charts, I want the category in y-axis and date in x-axis to static and want scroll bar for chart instead of taking a div and also want the bar size small and the font size should be less than in the example.

Stackblitz example


Solution

  • To make it happen, had to

    1. add a style section to your component definition
    2. removed the inline style from the div

    app.component.ts changes below:

    @Component({
        selector: 'my-app',
        template: `
            <div >
              <kendo-chart style="width: 3832px" [valueAxis]="valueAxis" [ngStyle]="{ 'height.px': chartHeight }">
                <kendo-chart-plot-area background="#F2F2F2"></kendo-chart-plot-area>
                <kendo-chart-series>
                    <kendo-chart-series-item *ngFor="let series of model"
                    type="rangeBar" [spacing]="-1" [data]="series.data" [opacity]="0.8" fromField="Start" toField="End" categoryField="Category">
                    </kendo-chart-series-item>
                </kendo-chart-series>         
              </kendo-chart>
            </div>
        `,
        styles:[` 
          kendo-chart{ max-width: 525px; max-height: 300px;}
          ::ng-deep g>text{ font-size: 11px !important;}
        `]
    })
    

    complete working demo here