Skip to content

Commit

Permalink
Refactored graphLabel functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
RLCorp committed Aug 13, 2024
1 parent b2dcec7 commit 5024d6c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/common/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,8 @@ export class ChartComponent implements OnInit, OnChanges {
* @param {number[]} dataValues - An array of data values to be used for creating the graph labels.
*/
createGraphLabels(dataValues: number[]): void {
let tempGraphLabels: PointAnnotations[] = [];
for (let i = 0; i < dataValues.length; i++) {
tempGraphLabels.push({
this.graphLabels = dataValues.map((dataValue, i) => {
return {
//Position the annotation at the corresponding label on the x-axis
x: this.labels[i],
y: 0,
Expand All @@ -425,7 +424,7 @@ export class ChartComponent implements OnInit, OnChanges {
//create the label for the annotation
label: {
offsetY: -5,
text: dataValues[i].toString(),
text: dataValue.toString(),
borderColor: '#FFFFFF',
style: {
padding: {top: -1, left: 3.5, right: 3.5},
Expand All @@ -436,8 +435,8 @@ export class ChartComponent implements OnInit, OnChanges {
color: '#FFFFFF',
},
},
});
}
this.graphLabels = tempGraphLabels;
}
})

}
}

0 comments on commit 5024d6c

Please sign in to comment.