javascript - Display yAxis label on a diagonal line -
i example highcharts :
i'd make yaxis label ( 0k,50k..in example) not in vertical line

but on diagonal line image

i've been search on highchart's docs not found attribute on yaxis label or maybe i'm wrong ,i've tried attribute on highchart's docs still no luck
yaxis: { gridlineinterpolation: 'polygon', linewidth: 0, min: 0, labels: { ... } }, please suggest how many !
you can rotate whole graph using pane.startangle, see: http://jsfiddle.net/xeaxk/381/
or wrap method responsible positioning points , edit radius use different axis.startanglerad: http://jsfiddle.net/xeaxk/385/
code:
(function (h) { h.wrap(h.tick.prototype, 'getlabelposition', function (proceed, x, y, label, horiz, labeloptions, tickmarkoffset, index, step) { var rot = this.axis.isxaxis ? this.axis.startanglerad : -2.5 * math.pi / 4, origrot = this.axis.startanglerad, axis = this.axis, optionsy = labeloptions.y, ret; axis.startanglerad = rot; centerslot = 20, // 20 degrees each side @ top , bottom align = labeloptions.align, angle = ((axis.translate(this.pos) + rot + math.pi / 2) / math.pi * 180) % 360; if (axis.isradial) { ret = axis.getposition(this.pos, (axis.center[2] / 2) + h.pick(labeloptions.distance, -25)); // automatically rotated if (labeloptions.rotation === 'auto') { label.attr({ rotation: angle }); // vertically centered } else if (optionsy === null) { optionsy = axis.chart.renderer.fontmetrics(label.styles.fontsize).b - label.getbbox().height / 2; } // automatic alignment if (align === null) { if (axis.iscircular) { if (this.label.getbbox().width > axis.len * axis.tickinterval / (axis.max - axis.min)) { // #3506 centerslot = 0; } if (angle > centerslot && angle < 180 - centerslot) { align = 'left'; // right hemisphere } else if (angle > 180 + centerslot && angle < 360 - centerslot) { align = 'right'; // left hemisphere } else { align = 'center'; // top or bottom } } else { align = 'center'; } label.attr({ align: align }); } ret.x += labeloptions.x; ret.y += optionsy; } else { ret = proceed.call(this, x, y, label, horiz, labeloptions, tickmarkoffset, index, step); } axis.startanglerad = origrot; return ret; }); })(highcharts);
Comments
Post a Comment