CalendarModel.js 5.2 KB

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