Advertisement
Guest User

Untitled

a guest
Jul 24th, 2012
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. Highcharts Change Bar Color Based on Value
  2. $(document).ready(function() {
  3.  
  4. var options = {
  5. chart: {
  6. renderTo: 'container',
  7. defaultSeriesType: 'bar'
  8. },
  9. title: {
  10. text: 'Spiritual Gifts Results'
  11. },
  12. colors: [
  13. '#3BBEE3'
  14. ],
  15. xAxis: {
  16. categories: []
  17. },
  18.  
  19. yAxis: {
  20. title: {
  21. text: 'Service'
  22. }
  23. },
  24. series: []
  25. };
  26.  
  27. var data = document.getElementById("<%= hdn_Data.ClientID %>");
  28. // Split the lines
  29. if (data.value != "") {
  30. var lines = data.value.split('n');
  31.  
  32. // Iterate over the lines and add categories or series
  33. $.each(lines, function(lineNo, line) {
  34. var items = line.split(',');
  35. // header line containes categories
  36. if (lineNo == 0) {
  37. $.each(items, function(itemNo, item) {
  38. if (itemNo > 0) options.xAxis.categories.push(item);
  39. });
  40. }
  41. // the rest of the lines contain data with their name in the first position
  42. else {
  43. var series = {
  44. data: []
  45. };
  46. $.each(items, function(itemNo, item) {
  47. if (itemNo == 0) {
  48. series.name = item;
  49. } else {
  50. series.data.push(parseFloat(item));
  51. }
  52. });
  53.  
  54. options.series.push(series);
  55.  
  56. }
  57.  
  58. });
  59.  
  60. // Create the chart
  61. var chart1 = new Highcharts.Chart(options);
  62. }
  63. });
  64.  
  65. Categories,Administration,Evangelism,Mercy,Shepherding,Leadership,Wisdom,Teaching
  66. Total Points,11,5,4,4,3,2,1
  67.  
  68. series.name = item;
  69.  
  70. series.data.push(parseFloat(item));
  71.  
  72. series.color: '#f6f6f6'
  73.  
  74. $(document).ready(function() {
  75.  
  76. var options = {
  77. chart: {
  78. renderTo: 'container',
  79. defaultSeriesType: 'bar'
  80. },
  81. title: {
  82. text: 'Spiritual Gifts Results'
  83. },
  84. colors: [
  85. '#3BBEE3'
  86. ],
  87. xAxis: {
  88. categories: []
  89. },
  90.  
  91. yAxis: {
  92. title: {
  93. text: 'Service'
  94. }
  95. },
  96. series: []
  97. };
  98.  
  99. var data = document.getElementById("hdn_Data");
  100. // Split the lines
  101. if (data.value != "") {
  102. var lines = data.value.split('n');
  103.  
  104. // Iterate over the lines and add categories or series
  105. $.each(lines, function(lineNo, line) {
  106. var items = line.split(',');
  107. // header line containes categories
  108. if (lineNo == 0) {
  109. $.each(items, function(itemNo, item) {
  110. if (itemNo > 0) options.xAxis.categories.push(item);
  111. });
  112. }
  113. // the rest of the lines contain data with their name in the first position
  114. else {
  115. var series = {
  116. data: []
  117. };
  118. $.each(items, function(itemNo, item) {
  119. var data = {};
  120. if (itemNo == 0) {
  121. series.name = item;
  122. } else {
  123. data.y = parseFloat(item);
  124. if (itemNo <= 3) {
  125. data.color = 'Gray';
  126. }
  127. else {
  128. data.color = '#3BBEE3';
  129. }
  130. series.data.push(data);
  131. }
  132. });
  133. options.series.push(series);
  134. }
  135. });
  136.  
  137. // Create the chart
  138. var chart1 = new Highcharts.Chart(options);
  139. }
  140. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement