Reputation: 11
I am using rangebar type to achieve some requirements (please see URL). The problem is data is dynamic and is there a way we can handle dynamic data ? . In the below example there is only two set of records data1 and data2 and in my case it could be more than five and its dynamic.
<kendo-chart style="height: 200px;" [valueAxis]="{ min: 1765 }">
<kendo-chart-series>
<kendo-chart-series-item type="rangeBar" [spacing]="-1"
[data]="data1" fromField="start" toField="end" categoryField="category">
</kendo-chart-series-item>
<kendo-chart-series-item type="rangeBar"
[data]="data2" fromField="start" toField="end" categoryField="category">
</kendo-chart-series-item>
</kendo-chart-series>
</kendo-chart>
public data1 = [
{ category: "A", start: 1765, end: 1780, color: 'blue' },
{ category: "B", start: 1765, end: 1798, color: 'blue' },
{ category: "C", start: 1765, end: 1802, color: 'blue' }
];
public data2 = [
{ category: "A", start: 1780, end: 1798, color: 'red' },
{ category: "B", start: 1798, end: 1802, color: 'red' },
{ category: "C", start: 1802, end: 1810, color: 'red' }
];
Requirement: https://i.sstatic.net/G7VkI.png
Upvotes: 0
Views: 1565
Reputation: 11
Finally I solved it
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<kendo-chart style="height: 200px;" [valueAxis]="{ min: 100 }">
<kendo-chart-series>
<kendo-chart-series-item
type="rangeBar" [spacing]="-1"
*ngFor="let series of model" [data]="series.data"
fromField="start" toField="end" categoryField="category">
</kendo-chart-series-item>
</kendo-chart-series>
</kendo-chart>
`
})
export class AppComponent {
public data1 = [
{ category: "A", start: 100, end: 110, color: 'blue' },
{ category: "B", start: 110, end: 120, color: 'blue' },
{ category: "C", start: 120, end: 130, color: 'blue' }
];
public data2 = [
{ category: "A", start: 120, end: 130, color: 'red' },
{ category: "B", start: 130, end: 140, color: 'red' },
{ category: "C", start: 140, end: 150, color: 'red' }
];
public showSeries: boolean = false;
public model = [];
constructor(){
this.model.push({ data:this.data1 });
this.model.push({data:this.data2 });
console.log(JSON.stringify(this.model));
}
}
Upvotes: 1