PageRenderTime 26ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/static/RGraph/docs/color.html

https://github.com/mneedham/dashboard
HTML | 210 lines | 150 code | 43 blank | 17 comment | 0 complexity | eaa4d6fa01e3fb853ce8f83542949653 MD5 | raw file
  1. <?php ob_start('ob_gzhandler') ?>
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="chrome=1">
  6. <!--
  7. /**
  8. * o------------------------------------------------------------------------------o
  9. * | This file is part of the RGraph package - you can learn more at: |
  10. * | |
  11. * | http://www.rgraph.net |
  12. * | |
  13. * | This package is licensed under the RGraph license. For all kinds of business |
  14. * | purposes there is a small one-time licensing fee to pay and for non |
  15. * | commercial purposes it is free to use. You can read the full license here: |
  16. * | |
  17. * | http://www.rgraph.net/LICENSE.txt |
  18. * o------------------------------------------------------------------------------o
  19. */
  20. -->
  21. <title>RGraph: Javascript charts and graph library - About canvas color definitions</title>
  22. <meta name="keywords" content="rgraph html5 canvas chart docs color" />
  23. <meta name="description" content="RGraph: Javascript charts and graph library - Documentation about canvas colors" />
  24. <meta property="og:title" content="RGraph: Javascript charts and graph library" />
  25. <meta property="og:description" content="A graph library based on the HTML5 canvas tag" />
  26. <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/>
  27. <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
  28. <link rel="icon" type="image/png" href="../images/favicon.png">
  29. <script>
  30. var _gaq = _gaq || [];
  31. _gaq.push(['_setAccount', 'UA-54706-2']);
  32. _gaq.push(['_trackPageview']);
  33. (function() {
  34. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  35. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  36. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  37. })();
  38. </script>
  39. </head>
  40. <body>
  41. <!-- Social networking buttons -->
  42. <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed">
  43. <a title="Bookmark with delicious" href="http://delicious.com/save?jump=close&v=4&noui&jump=close&url=http://www.rgraph.net&notes=RGraph%20is%20a%20HTML5%20based%20javascript%20charts%20library%20supporting%20a%20wide%20range%20of%20different%20charts%20types&title=RGraph:Javascript%20charts%20and%20graphs%20library" target="_blank"><img src="../images/delicious.png" alt="Bookmark with delicious" width="22" height="22" border="0" align="absmiddle" /></a>
  44. <a href="http://twitter.com/home/?status=RGraph%3A%20Javascript+charts+and+graph+library+http%3A%2F%2Fwww.rgraph.net+%23rgraph+%23html5+%23canvas+%23javascript+%23charts+@_rgraph" target="_blank"><img src="../images/twitter.png" id="twitter_icon" alt="tweet this site" width="22" height="22" border="0" align="absmiddle" /></a>
  45. <a title="Share RGraph on Facebook" href="" onclick="window.open('http://www.facebook.com/sharer.php?u=http://www.rgraph.net&t=RGraph:%20Javascript%20chart%20and%20graph%20library', 'facebook_window', 'width=500,height=400,top=100,left=100'); return false"><img src="../images/facebook.png" width="22" height="22" alt="Post to Facebook" align="absmiddle" border="0"/></a>
  46. </div>
  47. <script>
  48. // Opera fix
  49. if (navigator.userAgent.indexOf('Opera') == -1) {
  50. document.getElementById("social_icons").style.position = 'fixed';
  51. }
  52. </script>
  53. <!-- Social networking buttons -->
  54. <div id="breadcrumb">
  55. <a href="../index.html">RGraph: Javascript charts and graph library</a>
  56. >
  57. <a href="index.html">Documentation</a>
  58. >
  59. About canvas color definitions
  60. </div>
  61. <h1>RGraph: Javascript charts and graph library - About canvas color definitions</h1>
  62. <script>
  63. if (RGraph.isIE8()) {
  64. document.write('<div style="background-color: #fee; border: 2px dashed red; padding: 5px"><b>Important</b><br /><br /> Internet Explorer 8 does not natively support the HTML5 canvas tag, so if you want to see the charts, you can either:<ul><li>Install <a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a></li><li>Use ExCanvas. This is provided in the RGraph Archive.</li><li>Use another browser entirely. Your choices are Firefox 3.5+, Chrome 2+, Safari 4+ or Opera 10.5+. </li></ul> <b>Note:</b> Internet Explorer 9 fully supports the canvas tag. Click <a href="http://support.rgraph.net/message/rgraph-in-internet-explorer-9.html" target="_blank">here</a> to see some screenshots.</div>');
  65. }
  66. </script>
  67. <p>
  68. You will probably want to know the different ways you can define a color. There are a few
  69. ways which you can use, all of which are quite straight-forward.
  70. </p>
  71. <ul id="colors">
  72. <li><a href="#named">Named colors</a></li>
  73. <li><a href="#hex">Hex values</a></li>
  74. <li><a href="#rgb">RGB values</a></li>
  75. <li><a href="#rgba">RGBA values</a></li>
  76. <li><a href="#hsl">HSL values</a></li>
  77. <li><a href="#hsla">HSLA values</a></li>
  78. <li><a href="#lgradients">Linear gradients</a></li>
  79. <li><a href="#rgradients">Radial gradients</a></li>
  80. <li><a href="#info">More information</a></li>
  81. </ul>
  82. <a name="named"></a>
  83. <br />&nbsp;<br />
  84. <h2>Named colors</h2>
  85. <p>
  86. The first, and easiest, is to use named colors. This gives you a range of color values that have been predefined for you. Eg:
  87. </p>
  88. <pre class="code">myObject.Set('chart.colors', ['red', 'blue']);</pre>
  89. <a name="hex"></a>
  90. <br />&nbsp;<br />
  91. <h2>Hex values</h2>
  92. <p>
  93. The next, is straight forward hex values like you can use in normal CSS. These consist of a hash sign,
  94. followed by three or six hexadecimal characters. Eg:
  95. </p>
  96. <pre class="code">myObject.Set('chart.colors', ['#f00', '#0000ff']);</pre>
  97. <a name="rgb"></a>
  98. <br />&nbsp;<br />
  99. <h2>RGB values</h2>
  100. <p>
  101. Also as used in CSS, RGB values are the same as what you can use in CSS. Eg:
  102. </p>
  103. <pre class="code">myObject.Set('chart.colors', ['rgb(255,0,0)', 'rgb(0,0,255)']);</pre>
  104. <a name="rgba"></a>
  105. <br />&nbsp;<br />
  106. <h2>RGBA values</h2>
  107. <p>
  108. Probably new to most people, is rgba(). Similar to regular rgb() values, but with a fourth value that allows you to specify the
  109. alpha value, which stipulates how transparent the color is. An alpha value of 0 is totally transparent, and a value of 1, is
  110. totally opaque (ie. you can't see through it). With a value of 1, rgba() acts exactly like rgb(). This example gives you red
  111. and blue colors that are semi-transparent:
  112. </p>
  113. <pre class="code">myObject.Set('chart.colors', ['rgba(255,0,0,0.5)', 'rgba(0,0,255,0.5)']);</pre>
  114. <a name="hsl"></a>
  115. <br />&nbsp;<br />
  116. <h2>HSL() values</h2>
  117. <p>
  118. Also probably quite new to you, are hsl() values. Much like rgb(), but instead of red green and blue, it allows you to specify
  119. the Hue, Saturation and Light values instead. For example:
  120. </p>
  121. <pre class="code">myObject.Set('chart.colors', ['hsl(255, 100%, 50%)', 'hsl(169, 100%, 50%)']);</pre>
  122. <a name="hsla"></a>
  123. <br />&nbsp;<br />
  124. <h2>HSLA() values</h2>
  125. <p>
  126. Much like rgb() and rgba(), hsl() has a corresponding hsla() version, which allows you to specify an alpha (transparency) value.
  127. Eg:
  128. </p>
  129. <pre class="code">myObject.Set('chart.colors', ['hsla(255, 100%, 50%, 0.5)', 'hsla(169, 100%, 50%, 0.5)']);</pre>
  130. <a name="lgradients"></a>
  131. <br />&nbsp;<br />
  132. <h2>Linear gradients</h2>
  133. <p>
  134. Gradients can be used in place of color values. You can create a linear gradient like so:
  135. </p>
  136. <pre class="code">myGradient = myObject.context.createLinearGradient(0,0,0,250);
  137. myGradient.addColorStop(0, 'red');
  138. myGradient.addColorStop(1, 'blue');</pre>
  139. <p>
  140. This creates a gradient that goes from red to blue. The gradient starts at 0,0, and finishes at 0,250. ie A vertical
  141. gradient. You may not see the whole gradient - that depends on the extent of the shape you're filling. You can use the gradient
  142. in place of a regular color definition. Eg:
  143. </p>
  144. <pre class="code">myObject.Set('chart.colors', [myGradient]);</pre>
  145. <a name="rgradients"></a>
  146. <br />&nbsp;<br />
  147. <h2>Radial gradients</h2>
  148. <p>
  149. Radial gradients are much like their linear counterparts, but circular, as the name suggests. Eg:
  150. </p>
  151. <pre class="code">myGradient = myObject.context.createRadialGradient(0,0,0,0,0,100);
  152. myGradient.addColorStop(0, 'red');
  153. myGradient.addColorStop(1, 'blue');
  154. </pre>
  155. <p>
  156. Instead of four arguments, it takes six - the coordinates of the start point along with the radius, and the coordinates
  157. of the end point, along with the radius. After it has been created, you can treat as you would a linear gradient:
  158. </p>
  159. <pre class="code">myObject.Set('chart.colors', [myGradient]);</pre>
  160. <a name="info"></a>
  161. <br />&nbsp;<br />
  162. <h2>More information</h2>
  163. <p>
  164. You can read more about CSS3 color definitions <a href="http://www.w3.org/TR/css3-color/" target="_blank" rel="nofollow">here</a>.
  165. </p>
  166. </body>
  167. </html>