You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

BarBase.rb 2.9 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. require 'rexml/document'
  2. require 'SVG/Graph/Graph'
  3. module SVG
  4. module Graph
  5. # = Synopsis
  6. #
  7. # A superclass for bar-style graphs. Do not attempt to instantiate
  8. # directly; use one of the subclasses instead.
  9. #
  10. # = Author
  11. #
  12. # Sean E. Russell <serATgermaneHYPHENsoftwareDOTcom>
  13. #
  14. # Copyright 2004 Sean E. Russell
  15. # This software is available under the Ruby license[LICENSE.txt]
  16. #
  17. class BarBase < SVG::Graph::Graph
  18. # Ensures that :fields are provided in the configuration.
  19. def initialize config
  20. raise "fields was not supplied or is empty" unless config[:fields] &&
  21. config[:fields].kind_of?(Array) &&
  22. config[:fields].length > 0
  23. super
  24. end
  25. # In addition to the defaults set in Graph::initialize, sets
  26. # [bar_gap] true
  27. # [stack] :overlap
  28. def set_defaults
  29. init_with( :bar_gap => true, :stack => :overlap )
  30. end
  31. # Whether to have a gap between the bars or not, default
  32. # is true, set to false if you don't want gaps.
  33. attr_accessor :bar_gap
  34. # How to stack data sets. :overlap overlaps bars with
  35. # transparent colors, :top stacks bars on top of one another,
  36. # :side stacks the bars side-by-side. Defaults to :overlap.
  37. attr_accessor :stack
  38. protected
  39. def max_value
  40. @data.collect{|x| x[:data].max}.max
  41. end
  42. def min_value
  43. min = 0
  44. if min_scale_value.nil?
  45. min = @data.collect{|x| x[:data].min}.min
  46. min = min > 0 ? 0 : min
  47. else
  48. min = min_scale_value
  49. end
  50. return min
  51. end
  52. def get_css
  53. return <<EOL
  54. /* default fill styles for multiple datasets (probably only use a single dataset on this graph though) */
  55. .key1,.fill1{
  56. fill: #ff0000;
  57. fill-opacity: 0.5;
  58. stroke: none;
  59. stroke-width: 0.5px;
  60. }
  61. .key2,.fill2{
  62. fill: #0000ff;
  63. fill-opacity: 0.5;
  64. stroke: none;
  65. stroke-width: 1px;
  66. }
  67. .key3,.fill3{
  68. fill: #00ff00;
  69. fill-opacity: 0.5;
  70. stroke: none;
  71. stroke-width: 1px;
  72. }
  73. .key4,.fill4{
  74. fill: #ffcc00;
  75. fill-opacity: 0.5;
  76. stroke: none;
  77. stroke-width: 1px;
  78. }
  79. .key5,.fill5{
  80. fill: #00ccff;
  81. fill-opacity: 0.5;
  82. stroke: none;
  83. stroke-width: 1px;
  84. }
  85. .key6,.fill6{
  86. fill: #ff00ff;
  87. fill-opacity: 0.5;
  88. stroke: none;
  89. stroke-width: 1px;
  90. }
  91. .key7,.fill7{
  92. fill: #00ffff;
  93. fill-opacity: 0.5;
  94. stroke: none;
  95. stroke-width: 1px;
  96. }
  97. .key8,.fill8{
  98. fill: #ffff00;
  99. fill-opacity: 0.5;
  100. stroke: none;
  101. stroke-width: 1px;
  102. }
  103. .key9,.fill9{
  104. fill: #cc6666;
  105. fill-opacity: 0.5;
  106. stroke: none;
  107. stroke-width: 1px;
  108. }
  109. .key10,.fill10{
  110. fill: #663399;
  111. fill-opacity: 0.5;
  112. stroke: none;
  113. stroke-width: 1px;
  114. }
  115. .key11,.fill11{
  116. fill: #339900;
  117. fill-opacity: 0.5;
  118. stroke: none;
  119. stroke-width: 1px;
  120. }
  121. .key12,.fill12{
  122. fill: #9966FF;
  123. fill-opacity: 0.5;
  124. stroke: none;
  125. stroke-width: 1px;
  126. }
  127. EOL
  128. end
  129. end
  130. end
  131. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...