Changing the color of dot depending from value on Morris js graph

Posted by Michal Lipa on Stack Overflow See other posts from Stack Overflow or by Michal Lipa
Published on 2014-08-21T10:17:57Z Indexed on 2014/08/21 10:19 UTC
Read the original article Hit count: 276

Filed under:
|
|
|

Im rendering graph by morris js. Im using data from mysql database by JSON.

Everything works fine, but I would like to add one more feature to the graph. (change dot color if there is something in buy action).

My JSON:

[{"longdate":"2014-08-20 18:20:01","price":"1620","action":"buy"},{"longdate":"2014-08-20 18:40:01","price":"1640","action":""},{"longdate":"2014-08-20 19:00:01","price":"1620","action":""}]

So I would like to change dot color for values with buy action.

My code for graph:

$.getJSON('results.json', function(day_data) {

Morris.Line({
  element: 'graph',
  data: day_data,
  xkey: 'longdate',
  ykeys: ['price'], 
  labels: ['Cena'],
  lineColors: lineColor,
  pointSize: 0,
  hoverCallback: function(index, options, content) { 
 var date = "<b><font color='black'>Data: "+day_data[index]['longdate']+"</font></b><br>";
     var param1 = "<font color='"+lineColor[0]+"'>Cena - "+day_data[index]['price']+"</font><br>";
     return date+param1;
  },
  xLabelFormat : function (x) {
   return changeDateFormat(x);
  }

  /*My TRIAL
if(action == 'buy'){
pointSize: 4,
lineColors: green,
}
 */ 

});
});

So my code doesnt work, how can I make this working?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery