简体   繁体   English

具有圆形网格线插值的Spiderweb图表:看到的标签距离Plotline很远

[英]Spiderweb chart with circular gridline interpolation: Label is seen very far away from Plotline

I have spiderweb chart with plotline at a specific value. 我的蜘蛛网图表的情节线处于特定值。 Gridline interploation is used as circle. 网格线插值用作圆。 In this case, label provided is displayed very far away from plotline (top left corner of chart) by default. 在这种情况下,默认情况下,显示的提供的标签与绘图线(图表的左上角)相距很远。

how can i always display labels at center or at specific position of plotline circle, without manually calculating x and y points. 我如何始终在绘图线圆的中心或特定位置显示标签,而无需手动计算x和y点。

Refer example: http://jsfiddle.net/2862pqma/4/ 参考示例: http : //jsfiddle.net/2862pqma/4/

 Highcharts.chart('container', { chart: { polar: true, type: 'line' }, title: { text: 'Budget vs spending', x: -80 }, pane: { size: '80%' }, xAxis: { categories: ['Sales', 'Marketing', 'Development', 'Customer Support', 'Information Technology', 'Administration' ], tickmarkPlacement: 'on', lineWidth: 0 }, yAxis: { gridLineInterpolation: 'circle', lineWidth: 0, min: 0, plotLines: [{ value: 35000, width: 2, dashStyle: "Solid", color: "red", label: { text: "Line Marker", style: { color: "red" } } }] }, tooltip: { shared: true, pointFormat: '<span style="color:{series.color}">{series.name}: <b>${point.y:,.0f}</b><br/>' }, legend: { align: 'right', verticalAlign: 'top', y: 70, layout: 'vertical' }, series: [{ name: 'Allocated Budget', data: [43000, 19000, 60000, 35000, 17000, 10000], pointPlacement: 'on' }, ] }); 
 <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/highcharts-more.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 400px; max-width: 600px; height: 400px; margin: 0 auto"></div> 

使用xy参数定位标签: 链接到文档

Unfortunately, you need to calculate label position in polar chart, although it is not hard. 不幸的是,尽管并不难,但您需要计算极坐标图中的标签位置。 Use Axis.toPixels function to change axis values into pixels and use them as x and y positions of label. 使用Axis.toPixels函数将轴值更改为像素,并将它们用作标签的xy位置。 Take a look at the example below. 看下面的例子。

API Reference: API参考:
http://api.highcharts.com/highcharts/Axis.toPixels http://api.highcharts.com/highcharts/Axis.toPixels
http://api.highcharts.com/highcharts/chart.events.load http://api.highcharts.com/highcharts/chart.events.load
http://api.highcharts.com/highcharts/xAxis.plotLines.label.x http://api.highcharts.com/highcharts/xAxis.plotLines.label.x
http://api.highcharts.com/highcharts/xAxis.plotLines.label.y http://api.highcharts.com/highcharts/xAxis.plotLines.label.y

Example: 例:
http://jsfiddle.net/z7ya2r9y/ http://jsfiddle.net/z7ya2r9y/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM