zhangjian
2023-06-05 0976d2d0f90cff460cedfdc8bd74e98c2c31a58c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import BoundingRect, { RectLike } from 'zrender/lib/core/BoundingRect.js';
import CalendarModel from './CalendarModel.js';
import GlobalModel from '../../model/Global.js';
import ExtensionAPI from '../../core/ExtensionAPI.js';
import { LayoutOrient, ScaleDataValue, OptionDataValueDate } from '../../util/types.js';
import { ParsedModelFinder } from '../../util/model.js';
import { CoordinateSystem, CoordinateSystemMaster } from '../CoordinateSystem.js';
export interface CalendarParsedDateRangeInfo {
    range: [string, string];
    start: CalendarParsedDateInfo;
    end: CalendarParsedDateInfo;
    allDay: number;
    weeks: number;
    nthWeek: number;
    fweek: number;
    lweek: number;
}
export interface CalendarParsedDateInfo {
    /**
     * local full year, eg., '1940'
     */
    y: string;
    /**
     * local month, from '01' ot '12',
     */
    m: string;
    /**
     * local date, from '01' to '31' (if exists),
     */
    d: string;
    /**
     * It is not date.getDay(). It is the location of the cell in a week, from 0 to 6,
     */
    day: number;
    /**
     * Timestamp
     */
    time: number;
    /**
     * yyyy-MM-dd
     */
    formatedDate: string;
    /**
     * The original date object
     */
    date: Date;
}
export interface CalendarCellRect {
    contentShape: RectLike;
    center: number[];
    tl: number[];
    tr: number[];
    br: number[];
    bl: number[];
}
declare class Calendar implements CoordinateSystem, CoordinateSystemMaster {
    static readonly dimensions: string[];
    static getDimensionsInfo(): (string | {
        name: string;
        type: "time";
    })[];
    readonly type = "calendar";
    readonly dimensions: string[];
    private _model;
    private _rect;
    private _sw;
    private _sh;
    private _orient;
    private _firstDayOfWeek;
    private _rangeInfo;
    private _lineWidth;
    constructor(calendarModel: CalendarModel, ecModel: GlobalModel, api: ExtensionAPI);
    getDimensionsInfo: typeof Calendar.getDimensionsInfo;
    getRangeInfo(): CalendarParsedDateRangeInfo;
    getModel(): CalendarModel;
    getRect(): BoundingRect;
    getCellWidth(): number;
    getCellHeight(): number;
    getOrient(): LayoutOrient;
    /**
     * getFirstDayOfWeek
     *
     * @example
     *     0 : start at Sunday
     *     1 : start at Monday
     *
     * @return {number}
     */
    getFirstDayOfWeek(): number;
    /**
     * get date info
     * }
     */
    getDateInfo(date: OptionDataValueDate): CalendarParsedDateInfo;
    getNextNDay(date: OptionDataValueDate, n: number): CalendarParsedDateInfo;
    update(ecModel: GlobalModel, api: ExtensionAPI): void;
    /**
     * Convert a time data(time, value) item to (x, y) point.
     */
    dataToPoint(data: OptionDataValueDate | OptionDataValueDate[], clamp?: boolean): number[];
    /**
     * Convert a (x, y) point to time data
     */
    pointToData(point: number[]): number;
    /**
     * Convert a time date item to (x, y) four point.
     */
    dataToRect(data: OptionDataValueDate | OptionDataValueDate[], clamp?: boolean): CalendarCellRect;
    /**
     * Convert a (x, y) point to time date
     *
     * @param  {Array} point point
     * @return {Object}       date
     */
    pointToDate(point: number[]): CalendarParsedDateInfo;
    convertToPixel(ecModel: GlobalModel, finder: ParsedModelFinder, value: ScaleDataValue | ScaleDataValue[]): number[];
    convertFromPixel(ecModel: GlobalModel, finder: ParsedModelFinder, pixel: number[]): number;
    containPoint(point: number[]): boolean;
    /**
     * initRange
     * Normalize to an [start, end] array
     */
    private _initRangeOption;
    /**
     * range info
     *
     * @private
     * @param  {Array} range range ['2017-01-01', '2017-07-08']
     *  If range[0] > range[1], they will not be reversed.
     * @return {Object}       obj
     */
    _getRangeInfo(range: OptionDataValueDate[]): CalendarParsedDateRangeInfo;
    /**
     * get date by nthWeeks and week day in range
     *
     * @private
     * @param  {number} nthWeek the week
     * @param  {number} day   the week day
     * @param  {Array} range [d1, d2]
     * @return {Object}
     */
    private _getDateByWeeksAndDay;
    static create(ecModel: GlobalModel, api: ExtensionAPI): Calendar[];
}
export default Calendar;