I am trying a horizontal bar chart with ng2-charts as below to draw with custom scale i.e.
This is what I have achieved so far where I am getting output as 
Code:
public barChartColors: any [] =[
{
backgroundColor:'#5081bd',
},
{
backgroundColor:'rgba(80,129,189,255)',
}
];
public barChartOptions1: ChartOptions = {
responsive: true,
scales: {
yAxes: [
{
display: true,
scaleLabel: {
display: true,
labelString: "",
fontSize: 20
},
},
]
}
}
public barChartType1: ChartType = "horizontalBar";
DesignHorizantalBarChart(chartdata: any) {
let dataobj = {};
let setData = [];
let setLabels = [];
let arr = [];
chartdata.forEach((element, index) => {
element.index = index;
if (!element.isOpenText) {
setLabels = [...element.responses];
let average = ((element.average * element.responses.length) / 100);
setData.push(average.toFixed(2));
dataobj = {
data: setData,
label: element.reportTitle,
stack: element.reportTitle,
};
arr.push(dataobj);
this.barChartDataSets1.push(arr);
this.barChartLabels1.push(setLabels);
arr = [];
setData = [];
setLabels = [];
}
});
}
Input JSON data from function parameters:
[
{
"guid":"bb3cbb02-c0e7-440c-bd44-5c2bc25a249c",
"questionTitle":"Custom Question 2",
"reportTitle":"first report",
"responses":[
"ans1",
"ans2"
],
"openText":[
],
"isOpenText":false,
"result":null,
"average":66.66666666666666,
"sampleSize":3
}
]
Input Feed for chart after preparing data:
barChartDataSets1 [[{"data":["1.33"],"label":"first report","stack":"first report"}]]
generate-report.component.ts:290 barChartLabels1 [["ans1","ans2"]]
Template:
<canvas baseChart height="20vh" width="80vw"
[colors]="barChartColors"
[datasets]="barChartDataSets1[customdata.index]"
[labels]="barChartLabels1[customdata.index]"
[options]="barChartOptions1"
[chartType]="barChartType1"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)">
</canvas>
I would like to flip the scales and shown in desired output image without flipping the data or something like that. How this can be achieved? Any help would be appreciated.
