Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zmiana koloru wykresu w zależności od wartości
Lethys
post
Post #1





Grupa: Zarejestrowani
Postów: 642
Pomógł: 2
Dołączył: 9.03.2006

Ostrzeżenie: (30%)
XX---


Witam,

Przerzuciłem się na morris js, aby przedstawić dane z bazy.

Generalnie wszystko działa ale mam problem z dodatkowo opcją, tzn. chcę zmienić kolor konkretnego punktu wykresu gdy action=buy

tak wygląda mój JSON:

  1. [{"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":""}]


A tak kod wykresu:

  1. $.getJSON('results.json', function(day_data) {
  2.  
  3. Morris.Line({
  4. element: 'graph',
  5. data: day_data,
  6. xkey: 'longdate',
  7. ykeys: ['price'],
  8. labels: ['Cena'],
  9. pointSize: 4,
  10. lineColors: function(action) {
  11. if(action == "buy") return "#0da3be";
  12. else if(action == "sell") return "#11ca26";
  13. //else return działa bo pobiera ten kolor
  14. else return "#7c7c7c";
  15. },
  16. hoverCallback: function(index, options, content) {
  17. //var displayDate = "<b>"+changeDateFormat(day_data[index]['clock'])+"</b><br>";
  18. var date = "<b><font color='black'>Data: "+day_data[index]['longdate']+"</font></b><br>";
  19. var param1 = "<font color='"+lineColor[0]+"'>Cena - "+day_data[index]['price']+"</font><br>";
  20. return date+param1;
  21. },
  22. xLabelFormat : function (x) {
  23. return changeDateFormat(x);
  24. }
  25.  
  26.  
  27.  
  28.  
  29. });
  30. });


Else return działa, czyli jest problem z odczytaniem tego actiona.

Teoretycznie powinno działać ale nie działa (IMG:style_emoticons/default/smile.gif)

Ten post edytował Lethys 21.08.2014, 11:47:33
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 20:02