CalendarModel.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.js';
  42. import ComponentModel from '../../model/Component.js';
  43. import { getLayoutParams, sizeCalculable, mergeLayoutParam } from '../../util/layout.js';
  44. var CalendarModel = /** @class */function (_super) {
  45. __extends(CalendarModel, _super);
  46. function CalendarModel() {
  47. var _this = _super !== null && _super.apply(this, arguments) || this;
  48. _this.type = CalendarModel.type;
  49. return _this;
  50. }
  51. /**
  52. * @override
  53. */
  54. CalendarModel.prototype.init = function (option, parentModel, ecModel) {
  55. var inputPositionParams = getLayoutParams(option);
  56. _super.prototype.init.apply(this, arguments);
  57. mergeAndNormalizeLayoutParams(option, inputPositionParams);
  58. };
  59. /**
  60. * @override
  61. */
  62. CalendarModel.prototype.mergeOption = function (option) {
  63. _super.prototype.mergeOption.apply(this, arguments);
  64. mergeAndNormalizeLayoutParams(this.option, option);
  65. };
  66. CalendarModel.prototype.getCellSize = function () {
  67. // Has been normalized
  68. return this.option.cellSize;
  69. };
  70. CalendarModel.type = 'calendar';
  71. CalendarModel.defaultOption = {
  72. // zlevel: 0,
  73. z: 2,
  74. left: 80,
  75. top: 60,
  76. cellSize: 20,
  77. // horizontal vertical
  78. orient: 'horizontal',
  79. // month separate line style
  80. splitLine: {
  81. show: true,
  82. lineStyle: {
  83. color: '#000',
  84. width: 1,
  85. type: 'solid'
  86. }
  87. },
  88. // rect style temporarily unused emphasis
  89. itemStyle: {
  90. color: '#fff',
  91. borderWidth: 1,
  92. borderColor: '#ccc'
  93. },
  94. // week text style
  95. dayLabel: {
  96. show: true,
  97. firstDay: 0,
  98. // start end
  99. position: 'start',
  100. margin: '50%',
  101. color: '#000'
  102. },
  103. // month text style
  104. monthLabel: {
  105. show: true,
  106. // start end
  107. position: 'start',
  108. margin: 5,
  109. // center or left
  110. align: 'center',
  111. formatter: null,
  112. color: '#000'
  113. },
  114. // year text style
  115. yearLabel: {
  116. show: true,
  117. // top bottom left right
  118. position: null,
  119. margin: 30,
  120. formatter: null,
  121. color: '#ccc',
  122. fontFamily: 'sans-serif',
  123. fontWeight: 'bolder',
  124. fontSize: 20
  125. }
  126. };
  127. return CalendarModel;
  128. }(ComponentModel);
  129. function mergeAndNormalizeLayoutParams(target, raw) {
  130. // Normalize cellSize
  131. var cellSize = target.cellSize;
  132. var cellSizeArr;
  133. if (!zrUtil.isArray(cellSize)) {
  134. cellSizeArr = target.cellSize = [cellSize, cellSize];
  135. } else {
  136. cellSizeArr = cellSize;
  137. }
  138. if (cellSizeArr.length === 1) {
  139. cellSizeArr[1] = cellSizeArr[0];
  140. }
  141. var ignoreSize = zrUtil.map([0, 1], function (hvIdx) {
  142. // If user have set `width` or both `left` and `right`, cellSizeArr
  143. // will be automatically set to 'auto', otherwise the default
  144. // setting of cellSizeArr will make `width` setting not work.
  145. if (sizeCalculable(raw, hvIdx)) {
  146. cellSizeArr[hvIdx] = 'auto';
  147. }
  148. return cellSizeArr[hvIdx] != null && cellSizeArr[hvIdx] !== 'auto';
  149. });
  150. mergeLayoutParam(target, raw, {
  151. type: 'box',
  152. ignoreSize: ignoreSize
  153. });
  154. }
  155. export default CalendarModel;