mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Add support for mirror option
This commit is contained in:
parent
31c5e45bd4
commit
0c6f37fff7
@ -364,6 +364,12 @@ the following options.
|
||||
labels: {
|
||||
// Boolean - if true show labels
|
||||
show: true,
|
||||
|
||||
// Boolean - if true the chart will mirror the axis labels. If the labels are on the left, mirroring the axis will render them to the right
|
||||
mirror: false,
|
||||
|
||||
// Number - controls the padding between the label and the axis
|
||||
padding: 10,
|
||||
|
||||
// String - template string for labels
|
||||
template: "<%=value%>",
|
||||
|
@ -28,11 +28,13 @@
|
||||
// label settings
|
||||
labels: {
|
||||
show: true,
|
||||
mirror: false,
|
||||
padding: 10,
|
||||
template: "<%=value.toLocaleString()%>",
|
||||
fontSize: 12,
|
||||
fontStyle: "normal",
|
||||
fontColor: "#666",
|
||||
fontFamily: "Helvetica Neue",
|
||||
fontFamily: "Helvetica Neue"
|
||||
}
|
||||
};
|
||||
|
||||
@ -548,12 +550,22 @@
|
||||
var labelStartX;
|
||||
|
||||
if (this.options.position == "left") {
|
||||
labelStartX = this.right - 10;
|
||||
this.ctx.textAlign = "right";
|
||||
if (this.options.labels.mirror) {
|
||||
labelStartX = this.right + this.options.labels.padding;
|
||||
this.ctx.textAlign = "left";
|
||||
} else {
|
||||
labelStartX = this.right - this.options.labels.padding;
|
||||
this.ctx.textAlign = "right";
|
||||
}
|
||||
} else {
|
||||
// right side
|
||||
labelStartX = this.left + 5;
|
||||
this.ctx.textAlign = "left";
|
||||
if (this.options.labels.mirror) {
|
||||
labelStartX = this.left - this.options.labels.padding;
|
||||
this.ctx.textAlign = "right";
|
||||
} else {
|
||||
labelStartX = this.left + this.options.labels.padding;
|
||||
this.ctx.textAlign = "left";
|
||||
}
|
||||
}
|
||||
|
||||
this.ctx.textBaseline = "middle";
|
||||
|
Loading…
Reference in New Issue
Block a user