chart_gauge.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var chart = c3.generate({
  2. data: {
  3. columns: [
  4. ['data', 91.4]
  5. ],
  6. type: 'gauge',
  7. onclick: function (d, i) { console.log("onclick", d, i); },
  8. onmouseover: function (d, i) { console.log("onmouseover", d, i); },
  9. onmouseout: function (d, i) { console.log("onmouseout", d, i); }
  10. },
  11. gauge: {
  12. // label: {
  13. // format: function(value, ratio) {
  14. // return value;
  15. // },
  16. // show: false // to turn off the min/max labels.
  17. // },
  18. // min: 0, // 0 is default, //can handle negative min e.g. vacuum / voltage / current flow / rate of change
  19. // max: 100, // 100 is default
  20. // units: ' %',
  21. // width: 39 // for adjusting arc thickness
  22. },
  23. color: {
  24. pattern: ['#FF0000', '#F97600', '#F6C600', '#60B044'], // the three color levels for the percentage values.
  25. threshold: {
  26. // unit: 'value', // percentage is default
  27. // max: 200, // 100 is default
  28. values: [30, 60, 90, 100]
  29. }
  30. },
  31. size: {
  32. height: 180
  33. }
  34. });
  35. setTimeout(function () {
  36. chart.load({
  37. columns: [['data', 10]]
  38. });
  39. }, 1000);
  40. setTimeout(function () {
  41. chart.load({
  42. columns: [['data', 50]]
  43. });
  44. }, 2000);
  45. setTimeout(function () {
  46. chart.load({
  47. columns: [['data', 70]]
  48. });
  49. }, 3000);
  50. setTimeout(function () {
  51. chart.load({
  52. columns: [['data', 0]]
  53. });
  54. }, 4000);
  55. setTimeout(function () {
  56. chart.load({
  57. columns: [['data', 100]]
  58. });
  59. }, 5000);