CalendarModel.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { __extends } from "tslib";
  41. import * as zrUtil from 'zrender/lib/core/util';
  42. import ComponentModel from '../../model/Component';
  43. import { getLayoutParams, sizeCalculable, mergeLayoutParam } from '../../util/layout';
  44. var CalendarModel =
  45. /** @class */
  46. function (_super) {
  47. __extends(CalendarModel, _super);
  48. function CalendarModel() {
  49. var _this = _super !== null && _super.apply(this, arguments) || this;
  50. _this.type = CalendarModel.type;
  51. return _this;
  52. }
  53. /**
  54. * @override
  55. */
  56. CalendarModel.prototype.init = function (option, parentModel, ecModel) {
  57. var inputPositionParams = getLayoutParams(option);
  58. _super.prototype.init.apply(this, arguments);
  59. mergeAndNormalizeLayoutParams(option, inputPositionParams);
  60. };
  61. /**
  62. * @override
  63. */
  64. CalendarModel.prototype.mergeOption = function (option) {
  65. _super.prototype.mergeOption.apply(this, arguments);
  66. mergeAndNormalizeLayoutParams(this.option, option);
  67. };
  68. CalendarModel.prototype.getCellSize = function () {
  69. // Has been normalized
  70. return this.option.cellSize;
  71. };
  72. CalendarModel.type = 'calendar';
  73. CalendarModel.defaultOption = {
  74. zlevel: 0,
  75. z: 2,
  76. left: 80,
  77. top: 60,
  78. cellSize: 20,
  79. // horizontal vertical
  80. orient: 'horizontal',
  81. // month separate line style
  82. splitLine: {
  83. show: true,
  84. lineStyle: {
  85. color: '#000',
  86. width: 1,
  87. type: 'solid'
  88. }
  89. },
  90. // rect style temporarily unused emphasis
  91. itemStyle: {
  92. color: '#fff',
  93. borderWidth: 1,
  94. borderColor: '#ccc'
  95. },
  96. // week text style
  97. dayLabel: {
  98. show: true,
  99. firstDay: 0,
  100. // start end
  101. position: 'start',
  102. margin: '50%',
  103. nameMap: 'en',
  104. color: '#000'
  105. },
  106. // month text style
  107. monthLabel: {
  108. show: true,
  109. // start end
  110. position: 'start',
  111. margin: 5,
  112. // center or left
  113. align: 'center',
  114. // cn en []
  115. nameMap: 'en',
  116. formatter: null,
  117. color: '#000'
  118. },
  119. // year text style
  120. yearLabel: {
  121. show: true,
  122. // top bottom left right
  123. position: null,
  124. margin: 30,
  125. formatter: null,
  126. color: '#ccc',
  127. fontFamily: 'sans-serif',
  128. fontWeight: 'bolder',
  129. fontSize: 20
  130. }
  131. };
  132. return CalendarModel;
  133. }(ComponentModel);
  134. function mergeAndNormalizeLayoutParams(target, raw) {
  135. // Normalize cellSize
  136. var cellSize = target.cellSize;
  137. var cellSizeArr;
  138. if (!zrUtil.isArray(cellSize)) {
  139. cellSizeArr = target.cellSize = [cellSize, cellSize];
  140. } else {
  141. cellSizeArr = cellSize;
  142. }
  143. if (cellSizeArr.length === 1) {
  144. cellSizeArr[1] = cellSizeArr[0];
  145. }
  146. var ignoreSize = zrUtil.map([0, 1], function (hvIdx) {
  147. // If user have set `width` or both `left` and `right`, cellSizeArr
  148. // will be automatically set to 'auto', otherwise the default
  149. // setting of cellSizeArr will make `width` setting not work.
  150. if (sizeCalculable(raw, hvIdx)) {
  151. cellSizeArr[hvIdx] = 'auto';
  152. }
  153. return cellSizeArr[hvIdx] != null && cellSizeArr[hvIdx] !== 'auto';
  154. });
  155. mergeLayoutParam(target, raw, {
  156. type: 'box',
  157. ignoreSize: ignoreSize
  158. });
  159. }
  160. export default CalendarModel;