Jorinde
Jorinde

Reputation: 11

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').

Upvotes: 0

Views: 3587

Answers (1)

Simon
Simon

Reputation: 708

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
  }
]

Upvotes: 1

Related Questions