axisDefault.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var zrUtil = require("zrender/lib/core/util");
  20. /*
  21. * Licensed to the Apache Software Foundation (ASF) under one
  22. * or more contributor license agreements. See the NOTICE file
  23. * distributed with this work for additional information
  24. * regarding copyright ownership. The ASF licenses this file
  25. * to you under the Apache License, Version 2.0 (the
  26. * "License"); you may not use this file except in compliance
  27. * with the License. You may obtain a copy of the License at
  28. *
  29. * http://www.apache.org/licenses/LICENSE-2.0
  30. *
  31. * Unless required by applicable law or agreed to in writing,
  32. * software distributed under the License is distributed on an
  33. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  34. * KIND, either express or implied. See the License for the
  35. * specific language governing permissions and limitations
  36. * under the License.
  37. */
  38. var defaultOption = {
  39. show: true,
  40. zlevel: 0,
  41. z: 0,
  42. // Inverse the axis.
  43. inverse: false,
  44. // Axis name displayed.
  45. name: '',
  46. // 'start' | 'middle' | 'end'
  47. nameLocation: 'end',
  48. // By degree. By default auto rotate by nameLocation.
  49. nameRotate: null,
  50. nameTruncate: {
  51. maxWidth: null,
  52. ellipsis: '...',
  53. placeholder: '.'
  54. },
  55. // Use global text style by default.
  56. nameTextStyle: {},
  57. // The gap between axisName and axisLine.
  58. nameGap: 15,
  59. // Default `false` to support tooltip.
  60. silent: false,
  61. // Default `false` to avoid legacy user event listener fail.
  62. triggerEvent: false,
  63. tooltip: {
  64. show: false
  65. },
  66. axisPointer: {},
  67. axisLine: {
  68. show: true,
  69. onZero: true,
  70. onZeroAxisIndex: null,
  71. lineStyle: {
  72. color: '#333',
  73. width: 1,
  74. type: 'solid'
  75. },
  76. // The arrow at both ends the the axis.
  77. symbol: ['none', 'none'],
  78. symbolSize: [10, 15]
  79. },
  80. axisTick: {
  81. show: true,
  82. // Whether axisTick is inside the grid or outside the grid.
  83. inside: false,
  84. // The length of axisTick.
  85. length: 5,
  86. lineStyle: {
  87. width: 1
  88. }
  89. },
  90. axisLabel: {
  91. show: true,
  92. // Whether axisLabel is inside the grid or outside the grid.
  93. inside: false,
  94. rotate: 0,
  95. // true | false | null/undefined (auto)
  96. showMinLabel: null,
  97. // true | false | null/undefined (auto)
  98. showMaxLabel: null,
  99. margin: 8,
  100. // formatter: null,
  101. fontSize: 12
  102. },
  103. splitLine: {
  104. show: true,
  105. lineStyle: {
  106. color: ['#ccc'],
  107. width: 1,
  108. type: 'solid'
  109. }
  110. },
  111. splitArea: {
  112. show: false,
  113. areaStyle: {
  114. color: ['rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)']
  115. }
  116. }
  117. };
  118. var axisDefault = {};
  119. axisDefault.categoryAxis = zrUtil.merge({
  120. // The gap at both ends of the axis. For categoryAxis, boolean.
  121. boundaryGap: true,
  122. // Set false to faster category collection.
  123. // Only usefull in the case like: category is
  124. // ['2012-01-01', '2012-01-02', ...], where the input
  125. // data has been ensured not duplicate and is large data.
  126. // null means "auto":
  127. // if axis.data provided, do not deduplication,
  128. // else do deduplication.
  129. deduplication: null,
  130. // splitArea: {
  131. // show: false
  132. // },
  133. splitLine: {
  134. show: false
  135. },
  136. axisTick: {
  137. // If tick is align with label when boundaryGap is true
  138. alignWithLabel: false,
  139. interval: 'auto'
  140. },
  141. axisLabel: {
  142. interval: 'auto'
  143. }
  144. }, defaultOption);
  145. axisDefault.valueAxis = zrUtil.merge({
  146. // The gap at both ends of the axis. For value axis, [GAP, GAP], where
  147. // `GAP` can be an absolute pixel number (like `35`), or percent (like `'30%'`)
  148. boundaryGap: [0, 0],
  149. // TODO
  150. // min/max: [30, datamin, 60] or [20, datamin] or [datamin, 60]
  151. // Min value of the axis. can be:
  152. // + a number
  153. // + 'dataMin': use the min value in data.
  154. // + null/undefined: auto decide min value (consider pretty look and boundaryGap).
  155. // min: null,
  156. // Max value of the axis. can be:
  157. // + a number
  158. // + 'dataMax': use the max value in data.
  159. // + null/undefined: auto decide max value (consider pretty look and boundaryGap).
  160. // max: null,
  161. // Readonly prop, specifies start value of the range when using data zoom.
  162. // rangeStart: null
  163. // Readonly prop, specifies end value of the range when using data zoom.
  164. // rangeEnd: null
  165. // Optional value can be:
  166. // + `false`: always include value 0.
  167. // + `true`: the extent do not consider value 0.
  168. // scale: false,
  169. // AxisTick and axisLabel and splitLine are caculated based on splitNumber.
  170. splitNumber: 5,
  171. // Interval specifies the span of the ticks is mandatorily.
  172. // interval: null
  173. // Specify min interval when auto calculate tick interval.
  174. // minInterval: null
  175. // Specify max interval when auto calculate tick interval.
  176. // maxInterval: null
  177. minorTick: {
  178. // Minor tick, not available for cateogry axis.
  179. show: false,
  180. // Split number of minor ticks. The value should be in range of (0, 100)
  181. splitNumber: 5,
  182. // Lenght of minor tick
  183. length: 3,
  184. // Same inside with axisTick
  185. // Line style
  186. lineStyle: {// Default to be same with axisTick
  187. }
  188. },
  189. minorSplitLine: {
  190. show: false,
  191. lineStyle: {
  192. color: '#eee',
  193. width: 1
  194. }
  195. }
  196. }, defaultOption);
  197. axisDefault.timeAxis = zrUtil.defaults({
  198. scale: true,
  199. min: 'dataMin',
  200. max: 'dataMax'
  201. }, axisDefault.valueAxis);
  202. axisDefault.logAxis = zrUtil.defaults({
  203. scale: true,
  204. logBase: 10
  205. }, axisDefault.valueAxis);
  206. var _default = axisDefault;
  207. module.exports = _default;