CalendarModel.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 =
  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. color: '#000'
  104. },
  105. // month text style
  106. monthLabel: {
  107. show: true,
  108. // start end
  109. position: 'start',
  110. margin: 5,
  111. // center or left
  112. align: 'center',
  113. formatter: null,
  114. color: '#000'
  115. },
  116. // year text style
  117. yearLabel: {
  118. show: true,
  119. // top bottom left right
  120. position: null,
  121. margin: 30,
  122. formatter: null,
  123. color: '#ccc',
  124. fontFamily: 'sans-serif',
  125. fontWeight: 'bolder',
  126. fontSize: 20
  127. }
  128. };
  129. return CalendarModel;
  130. }(ComponentModel);
  131. function mergeAndNormalizeLayoutParams(target, raw) {
  132. // Normalize cellSize
  133. var cellSize = target.cellSize;
  134. var cellSizeArr;
  135. if (!zrUtil.isArray(cellSize)) {
  136. cellSizeArr = target.cellSize = [cellSize, cellSize];
  137. } else {
  138. cellSizeArr = cellSize;
  139. }
  140. if (cellSizeArr.length === 1) {
  141. cellSizeArr[1] = cellSizeArr[0];
  142. }
  143. var ignoreSize = zrUtil.map([0, 1], function (hvIdx) {
  144. // If user have set `width` or both `left` and `right`, cellSizeArr
  145. // will be automatically set to 'auto', otherwise the default
  146. // setting of cellSizeArr will make `width` setting not work.
  147. if (sizeCalculable(raw, hvIdx)) {
  148. cellSizeArr[hvIdx] = 'auto';
  149. }
  150. return cellSizeArr[hvIdx] != null && cellSizeArr[hvIdx] !== 'auto';
  151. });
  152. mergeLayoutParam(target, raw, {
  153. type: 'box',
  154. ignoreSize: ignoreSize
  155. });
  156. }
  157. export default CalendarModel;