axisDefault.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. import * as zrUtil from 'zrender/src/core/util';
  20. var defaultOption = {
  21. show: true,
  22. zlevel: 0,
  23. z: 0,
  24. // Inverse the axis.
  25. inverse: false,
  26. // Axis name displayed.
  27. name: '',
  28. // 'start' | 'middle' | 'end'
  29. nameLocation: 'end',
  30. // By degree. By default auto rotate by nameLocation.
  31. nameRotate: null,
  32. nameTruncate: {
  33. maxWidth: null,
  34. ellipsis: '...',
  35. placeholder: '.'
  36. },
  37. // Use global text style by default.
  38. nameTextStyle: {},
  39. // The gap between axisName and axisLine.
  40. nameGap: 15,
  41. // Default `false` to support tooltip.
  42. silent: false,
  43. // Default `false` to avoid legacy user event listener fail.
  44. triggerEvent: false,
  45. tooltip: {
  46. show: false
  47. },
  48. axisPointer: {},
  49. axisLine: {
  50. show: true,
  51. onZero: true,
  52. onZeroAxisIndex: null,
  53. lineStyle: {
  54. color: '#333',
  55. width: 1,
  56. type: 'solid'
  57. },
  58. // The arrow at both ends the the axis.
  59. symbol: ['none', 'none'],
  60. symbolSize: [10, 15]
  61. },
  62. axisTick: {
  63. show: true,
  64. // Whether axisTick is inside the grid or outside the grid.
  65. inside: false,
  66. // The length of axisTick.
  67. length: 5,
  68. lineStyle: {
  69. width: 1
  70. }
  71. },
  72. axisLabel: {
  73. show: true,
  74. // Whether axisLabel is inside the grid or outside the grid.
  75. inside: false,
  76. rotate: 0,
  77. // true | false | null/undefined (auto)
  78. showMinLabel: null,
  79. // true | false | null/undefined (auto)
  80. showMaxLabel: null,
  81. margin: 8,
  82. // formatter: null,
  83. fontSize: 12
  84. },
  85. splitLine: {
  86. show: true,
  87. lineStyle: {
  88. color: ['#ccc'],
  89. width: 1,
  90. type: 'solid'
  91. }
  92. },
  93. splitArea: {
  94. show: false,
  95. areaStyle: {
  96. color: ['rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)']
  97. }
  98. }
  99. };
  100. var axisDefault = {};
  101. axisDefault.categoryAxis = zrUtil.merge({
  102. // The gap at both ends of the axis. For categoryAxis, boolean.
  103. boundaryGap: true,
  104. // Set false to faster category collection.
  105. // Only usefull in the case like: category is
  106. // ['2012-01-01', '2012-01-02', ...], where the input
  107. // data has been ensured not duplicate and is large data.
  108. // null means "auto":
  109. // if axis.data provided, do not deduplication,
  110. // else do deduplication.
  111. deduplication: null,
  112. // splitArea: {
  113. // show: false
  114. // },
  115. splitLine: {
  116. show: false
  117. },
  118. axisTick: {
  119. // If tick is align with label when boundaryGap is true
  120. alignWithLabel: false,
  121. interval: 'auto'
  122. },
  123. axisLabel: {
  124. interval: 'auto'
  125. }
  126. }, defaultOption);
  127. axisDefault.valueAxis = zrUtil.merge({
  128. // The gap at both ends of the axis. For value axis, [GAP, GAP], where
  129. // `GAP` can be an absolute pixel number (like `35`), or percent (like `'30%'`)
  130. boundaryGap: [0, 0],
  131. // TODO
  132. // min/max: [30, datamin, 60] or [20, datamin] or [datamin, 60]
  133. // Min value of the axis. can be:
  134. // + a number
  135. // + 'dataMin': use the min value in data.
  136. // + null/undefined: auto decide min value (consider pretty look and boundaryGap).
  137. // min: null,
  138. // Max value of the axis. can be:
  139. // + a number
  140. // + 'dataMax': use the max value in data.
  141. // + null/undefined: auto decide max value (consider pretty look and boundaryGap).
  142. // max: null,
  143. // Readonly prop, specifies start value of the range when using data zoom.
  144. // rangeStart: null
  145. // Readonly prop, specifies end value of the range when using data zoom.
  146. // rangeEnd: null
  147. // Optional value can be:
  148. // + `false`: always include value 0.
  149. // + `true`: the extent do not consider value 0.
  150. // scale: false,
  151. // AxisTick and axisLabel and splitLine are caculated based on splitNumber.
  152. splitNumber: 5,
  153. // Interval specifies the span of the ticks is mandatorily.
  154. // interval: null
  155. // Specify min interval when auto calculate tick interval.
  156. // minInterval: null
  157. // Specify max interval when auto calculate tick interval.
  158. // maxInterval: null
  159. minorTick: {
  160. // Minor tick, not available for cateogry axis.
  161. show: false,
  162. // Split number of minor ticks. The value should be in range of (0, 100)
  163. splitNumber: 5,
  164. // Lenght of minor tick
  165. length: 3,
  166. // Same inside with axisTick
  167. // Line style
  168. lineStyle: {
  169. // Default to be same with axisTick
  170. }
  171. },
  172. minorSplitLine: {
  173. show: false,
  174. lineStyle: {
  175. color: '#eee',
  176. width: 1
  177. }
  178. }
  179. }, defaultOption);
  180. axisDefault.timeAxis = zrUtil.defaults({
  181. scale: true,
  182. min: 'dataMin',
  183. max: 'dataMax'
  184. }, axisDefault.valueAxis);
  185. axisDefault.logAxis = zrUtil.defaults({
  186. scale: true,
  187. logBase: 10
  188. }, axisDefault.valueAxis);
  189. export default axisDefault;