简体   繁体   中英

Kendo UI for Angular - Bar Chart Fixed Bar Size

We are currently using Kendo UI for Angular in our project and have implemented the Kendo bar chart. Currently the bar size is responsive based on the chart height. We need to set that bar to a fixed size as per the jQuery example below.

Anyone have any thoughts on doing this in Angular?

https://docs.telerik.com/kendo-ui/controls/charts/how-to/appearance/fixed-bar-size

Kendo UI for Angular Bar Chart

It is possible to use the same approach for the angular chart:

<kendo-chart>
  <kendo-chart-series>
    <kendo-chart-series-item type="bar"[data]="[1, 2]" [visual]="barVisual">
    </kendo-chart-series-item>
  </kendo-chart-series>
</kendo-chart>

// component
public barVisual(e: any): void {
  //create the default visual
  const visual = e.createVisual();
  //scale it so that it has the predefined size
  visual.transform(geometry.transform().scale(1, BAR_SIZE / e.rect.size.height, e.rect.center() ));
  return visual;
}

https://plnkr.co/edit/RVRHuCiq4ZD2a6da56D3?p=preview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM