简体   繁体   English

Highcharts散点图标记转换错误

[英]Highcharts scatter marker translation error

I have made a highcharts graph which is intended to mirror the following: 我制作了一个高图图表,旨在反映以下内容:

酒吧

I am using a triangle image as a marker for the graph, but by default, the marker is being situated in the center of the bar. 我使用三角形图像作为图形的标记,但默认情况下,标记位于条形图的中心。 I have tried to use the translation function 我试过使用翻译功能

  chart.series[1].data.graphic.translate(0, 20);

but this does not seem to be helping. 但这似乎并没有帮助。 Here is my full code: 这是我的完整代码:

barchartFiddle barchartFiddle

I was also wondering how I would add the percentage to the top of as it would move along with the bar. 我也想知道如何将百分比添加到顶部,因为它会随着条形移动。 Furthermore, I have tried using (multiple versions with different css properties + high zIndex - I will be listing the basic) 此外,我尝试过使用(具有不同css属性的多个版本+高zIndex - 我将列出基本的)

chart.renderer.text('blah',50,50).add();

to add the bottom 3 criteria, but for some odd reason, no text shows up. 添加底部3个标准,但由于某些奇怪的原因,没有文字出现。 Finally, I was wondering what logic to add in order to change the appearance of the text, depending on the data, to mirror the one shown in the image (Note difference between acceptable and healthy) 最后,我想知道要添加什么逻辑,以便根据数据更改文本的外观,以反映图像中显示的文本(注意可接受和健康之间的区别)

In your jsFiddle you have added your callback function in wrong place, when you will add it correctly it should work fine. 在你的jsFiddle中你已经在错误的地方添加了你的回调函数,当你正确添加它应该可以正常工作。

function(chart) {
    var marker = chart.series[1].data[0];
    marker.graphic.translate(-20, 0);
}

You can use dataLabels for showing the percent value near your marker. 您可以使用dataLabels显示标记附近的百分比值。

  dataLabels: {
    enabled: true,
    x: -5,
    y: 10,
    style: {
      fontSize: 20
    },
    formatter: function() {
      return this.y + '%'
    }
  }

Here you can find an example how it can work: http://jsfiddle.net/2TuCW/341/ 在这里你可以找到一个如何工作的例子: http//jsfiddle.net/2TuCW/341/

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

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