How can I add multiple x-axis for the Bar Chart, and also show different labels on those multiple x-axis as shown in the image attached.
|
<ejs-chart [axes]='axis' (axisLabelRender)='axisLabelRender($event)'>
<e-series-collection>
<e-series xAxisName='xAxis' ></e-series>
</e-series-collection>
</ejs-chart>
public axis: Object = [{
rowIndex: 0,
name: 'xAxis'
}];
public axisLabelRender(args: IAxisLabelRenderEventArgs): void{
if(args.axis["name"] == "primaryXAxis"){
args.text = args.value == 0 ? "23" : (args.value == 1 ? "22": args.text);
}
if(args.axis["name"]== "xAxis"){
args.text = args.value == 0 || args.value == 1 ? "None": args.text;
}
}; |
Hi, how can I add multiple x-axis with different labels in table format for bar chart as shown in the attached image.
|
public primaryXAxis: Object = {
multiLevelLabels: [
{
border: { type: 'Rectangle' },
categories: [
{ start: -0.5, end: 0.5, text: 'Seedless', },
{ start: 0.5, end: 2.5, text: 'Seeded', },
//….
]
}, {
border: { type: 'Rectangle' },
categories: [
{ start: -0.5, end: 2.5, text: 'In Season', },
{ start: 2.5, end: 5.5, text: 'Out of Season', },
//….
]
}]
}; |
Hi, Actually I want to pass the label data by an array. How can we use multilevel labels without using start and end values.
Hi, I want to implement this type of chart using multilevel labels.
How can I implement this chart using multiLevelLabes without using the start and end values as shown in the code below. Or is there any other way to implement this type of chart?
|
// add your additional code here
public start = -0.5;
public end = 1.5;
public index = 0;
public categoryList: object[] = [];
public labelData: String[] = [
'Seedless',
'Seeded',
'Seedless',
'Seeded',
'Seedless',
'Seeded',
'Seedless',
'Seeded'
];
public load(args: ILoadedEventArgs): void {
for (var i = 0; i < this.labelData.length; i++) {
this.categoryList.push({
start: this.start + this.index,
end: this.end + this.index,
text: this.labelData[i]
});
this.index += 2;
}
args.chart.primaryXAxis.multiLevelLabels[0].categories = this.categoryList;
}
// add your additional code here |
Thank you for your reply. But I am facing another issue in the chart that you have replied. I want the data from seedless to seeded part and to show till grapes data (color - light green, value - 13) on the first page and rest of the data on second page starting from seeded pears (color - sky blue, value - 42) until the seedless grapes (color - purple, value - 28) .
Below is my code which I have tried :-
|
public first(args){
document.getElementById("div1").style.display = "block";
document.getElementById("div2").style.display = "none";
}
public second(args){
document.getElementById("div1").style.display = "none";
document.getElementById("div2").style.display = "block";
} |
You have send this sample using 2 data set but we want it in one data set and also the page change part. For you reference:-
|
@ViewChild('chart')
public chart: ChartComponent;
public first(args){
this.chart.primaryXAxis.zoomFactor = 0.8; // number of points to be displayed/total number of points(8/10)
this.chart.primaryXAxis.zoomPosition = 1;
this.chart.refresh();
}
public second(args){
this.chart.primaryXAxis.zoomFactor = 0.2;//(2/10)
this.chart.primaryXAxis.zoomPosition = 0;
this.chart.refresh();
} |
Hi, if we use isInversed property in chart then it shows negative axis. How can we achieve page change property using zoomFactor and zoomPosition which you suggest.
Sample Link :- https://stackblitz.com/edit/angular-yqtfse-beqp42
|
public first(args){
if(this.chart.primaryXAxis.isInversed)
this.chart.primaryXAxis.zoomPosition = 0;
else
this.chart.primaryXAxis.zoomPosition = 1;
this.chart.primaryXAxis.zoomFactor = 0.8;
this.chart.refresh();
}
public second(args){
if(this.chart.primaryXAxis.isInversed)
this.chart.primaryXAxis.zoomPosition = 0.8;
else
this.chart.primaryXAxis.zoomPosition = 0;
this.chart.primaryXAxis.zoomFactor = 0.2;
this.chart.refresh();
} |
public xAxis: any = {
valueType: 'Category',
title: 'abcd',
interval: 1,
maximum: 9,
minimum: 0,
isInversed: false
};