简体   繁体   中英

amCharts: dynamically changing bullet color

I'm using AmChart for making a line chart. I want to dynamically change the color of the bullet (bulletColor) according to the y-values. So for example:

Default bulletcolor: green With a value above 103% the color of the bullet should be orange With a value above 105% the color of the bullet should be red.

I noticed there are customfields that take data from the json for 'bulletSizeField' and 'bulletField'(custom bulletpicture) but I can't find if the same is possible for changing only the color of the bullet. Does anybody know if there's a way to accomplish this result? (either in AmChart itself or get the colordata from the jsonfile like with 'BulletField').

You could, within your script that generates the dataProvider data, add some logic and pass the colour each time based on the value.

http://jsfiddle.net/qkc8bgtq/

"dataProvider": [
  {
    "lineColor": "#00aa00",
    "date": "2012-01-01",
    "duration": 100
  },
  {
    "lineColor": "#00aa00",
    "date": "2012-01-02",
    "duration": 102
  },
  {
    "lineColor": "#ff9900",
    "date": "2012-01-03",
    "duration": 104
  },
  {
    "lineColor": "#aa0000",
    "date": "2012-01-04",
    "duration": 106
  },
  {
    "lineColor": "#aa0000",
    "date": "2012-01-05",
    "duration": 108
  }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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