概览

时间刻度是甘特表中甘特表的列标题,它允许您显示更小或更大的时间单位。

层级模式 时间刻度布局中有3个层级(顶层、中层和底层)。 您可以使用GC.Spread.Sheets.GanttSheet.TimescaleTierMode来更改其布局: middle middleBottom topMiddleBottom 显示刻度分隔线 刻度线将顶层和中层分隔开。 您可以显示或隐藏刻度线: 层级配置 每个顶层、中层和底层都具有以下属性: unit: GC.Spread.Sheets.GanttSheet.TimescaleUnit count: number labelAlign: "Left" | "Center" | "Right" showTickLines: boolean formatter: string formatter可以是日期值的Spread数字格式字符串,例如"yyyy-mm-dd",带有GanttSheet特殊关键字,也可以是一个在格式化期间执行的回调函数。
/*REPLACE_MARKER*/ /*DO NOT DELETE THESE COMMENTS*/ var myTable; var ganttSheet; var showScaleSeparator = true; var showTopScaleTick = true; var showMiddleScaleTick = true; var showBottomScaleTick = true; var supposedFormats = [ undefined, [ { value: '[DBNum1][$-804]yyyy"年"', info: `二〇〇九年, 二〇一〇年, ... ` }, { value: 'yyyy"年"', info: `2009年, 2010年, ...` }, { value: "yyyy", info: `2009, 2010,...` }, { value: '"第" {!YEAR_FROM_START} "年"', info: `第1年, 第2年 ... (从开始)` }, { value: "{!YEAR_FROM_START}", info: `1, 2, 3, 4, ... (从开始)` }, { value: '"Y"{!YEAR_FROM_START}', info: `Y1, Y2, Y3, ... (从开始)` }, { value: '"第" {!YEAR_FROM_END} "年"', info: `第2年, 第1年 ... (从结束)` }, { value: "{!YEAR_FROM_END}", info: `4, 3, 2, 1, ... (从结束)` }, { value: '"Y" {!YEAR_FROM_END}', info: `Y3, Y2, Y1, ... (从结束)` }, ], [ { value: '{!HALF_YEAR("前半年","后半年")}', info: `前半年, 后半年, ... ` }, { value: 'yyyy, {!HALF_YEAR("上半年","下半年")}', info: `2009, 上半年, 2009, 下半年, ...` }, { value: '{!HALF_YEAR("上半年","下半年")}', info: `上半年, 下半年, ...` }, { value: '\'yy "H"{!HALF_YEAR("1","2")}', info: `'09 H1, '09 H2, ...` }, { value: '"H"{!HALF_YEAR("1","2")}', info: `H1, H2, ...` }, { value: '{!HALF_YEAR("1","2")}', info: `1, 2,…` }, { value: '{!HALF_YEAR("1","2")}"H"yy', info: `1H09, 2H09, ...` }, { value: '"半年" {!HALF_YEAR_FROM_START}', info: `半年 1, 半年 2, 半年 3, ... (从开始)` }, { value: '"H" {!HALF_YEAR_FROM_START}', info: `H1, H2, H3, ... (从开始)` }, { value: "{!HALF_YEAR_FROM_START}", info: `1, 2, 3, ... (从开始)` }, { value: '"半年" {!HALF_YEAR_FROM_END}', info: `半年 3, 半年 2, 半年 1, ... (从结束)` }, { value: '"H"{!HALF_YEAR_FROM_END}', info: `H3, H2, H1, ... (从结束)` }, { value: "{!HALF_YEAR_FROM_END}", info: `3, 2, 1, ... (从结束)` }, ], [ { value: 'yyyy"年第"{!QUARTER("1","2","3","4")}"季度"', info: `2009年第1季度 ` }, { value: '[DBNum1][$-804]yyyy"年第"{!QUARTER("1","2","3","4")}"季度"', info: `二〇〇九年第一季度, 二〇〇九年第二季度, ...` }, { value: '"第"{!QUARTER("一","二","三","四")}"季度"', info: `第一季度` }, { value: '{!QUARTER("1","2","3","4")}', info: `1, 2, ...` }, { value: '"Q"{!QUARTER("1","2","3","4")}', info: `Q1, Q2, ...` }, { value: '"Qtr" {!QUARTER("1","2","3","4")}', info: `Qtr 1, Qtr 2, ...` }, { value: '{!QUARTER("1","2","3","4")}"Q"yy', info: `1Q09, 2Q09,...` }, { value: '"第"{!QUARTER_FROM_START}"季度"', info: `第1季度, 第2季度, ... (从开始)` }, { value: '{!QUARTER_FROM_START}', info: `1, 2, 3, 4, ... (从开始)` }, { value: '"Q"{!QUARTER_FROM_START}', info: `Q1, Q2, Q3, Q4, ... (从开始)` }, { value: '"第"{!QUARTER_FROM_END}"季度"', info: `第2季度, 第1季度, ... (从结束)` }, { value: '{!QUARTER_FROM_END}', info: `4, 3, 2, 1, ... (从结束)` }, { value: '"Q"{!QUARTER_FROM_END}', info: `Q4, Q3, Q2, Q1, ... (从结束)` }, ], [ { value: '[DBNum1][$-804]yyyy"年"m"月"', info: `二〇〇九年一月` }, { value: '[$-804]yyyy"年"m"月"', info: `2009年1月, 2009年2月, ...` }, { value: 'yyyy/m', info: `2009/1` }, { value: 'mmmm', info: `一月, 二月, ...` }, { value: '[$-409]yy mmm', info: `09 Jan` }, { value: 'yy/m', info: `09/1` }, { value: 'm', info: `1, 2,...` }, { value: '"第" {!MONTH_FROM_START} "月"', info: `第1月, 第2月, ... (从开始)` }, { value: '{!MONTH_FROM_START}', info: `1, 2, 3, 4, ... (从开始)` }, { value: '"M" {!MONTH_FROM_START}', info: `M1, M2, M3, ... (从开始)` }, { value: '"第" {!MONTH_FROM_END} "月"', info: `第2月, 第1月, ... (从结束)` }, { value: '{!MONTH_FROM_END}', info: `4, 3, 2, 1, ... (从结束)` }, { value: '"M" {!MONTH_FROM_END}', info: `M3, M2, M1, ... (从结束)` }, ], [ { value: 'd', info: `1, 11, 21, ... ` }, { value: '{!THIRDS_OF_MONTH("B","M","E")}', info: `B, M, E,..` }, { value: '{!THIRDS_OF_MONTH("上旬","中旬","下旬")}', info: `上旬, 中旬, 下旬, ...` }, { value: 'm/d', info: `1/1, 1/11, 1/21, ...` }, { value: 'm/{!THIRDS_OF_MONTH("B","M","E")}', info: `1/B, 1/M, 1/E, ...` }, { value: 'mmmm{!THIRDS_OF_MONTH("上旬","中旬","下旬")}', info: `一月上旬, 一月中旬, ...` }, { value: '[$-409]mmm d', info: `Jan 1, Jan 11, Jan 21, ...` }, { value: '[$-409]mmm {!THIRDS_OF_MONTH("B","M","E")}', info: `Jan B. Jan M, Jan E, ...` }, { value: 'mmmm d', info: `一月 1, 一月 11, 一月 21, ...` }, { value: 'yy/m/d', info: `09/1/1, 09/1/11, 09/1/21, ...` }, { value: 'yy/m/{!THIRDS_OF_MONTH("B","M","E")}', info: `09/1/B, 09/1/M, 09/1/E, ...` }, { value: '[$-409]\'yy mmm d', info: `'09 Jan 1, '09 Jan 11, '09 Jan 21, ...` }, { value: '[$-409]\'yy mmm {!THIRDS_OF_MONTH("B","M","E")}', info: `'09 Jan B, '09 Jan M, '09 Jan E,...` }, { value: 'yyyy mmmm d', info: `2009 一月 1, 2009 一月 11, ...` }, { value: '[DBNum1][$-804]yyyy"年"m"月"{!THIRDS_OF_MONTH("上旬","中旬","下旬")}', info: `二〇〇九年一月上旬, ...` }, ], [ { value: '[DBNum1][$-804]yyyy"年"m"月"d"日";@', info: `二〇〇九年一月二十五日` }, { value: '[$-804]yyyy"年"m"月"d"日"dddd', info: `2009年1月25日星期日` }, { value: '[$-804]yyyy"年"m"月"d"日"', info: `2009年1月25日` }, { value: 'yyyy/m/d({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `2009/1/25(日)` }, { value: 'yyyy/m/d', info: `2009/1/25` }, { value: '[DBNum1][$-804]m"月"d"日"dddd', info: `一月二十五日星期日` }, { value: '[DBNum1][$-804]m"月"d"日"', info: `一月二十五日` }, { value: 'm"月"d"日"dddd', info: `1月25日星期日` }, { value: 'm"月"d"日"({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `1月25日(日)` }, { value: 'm"月"d"日"', info: `1月25日, 2月1日, ...` }, { value: 'm/d dddd', info: `1/25星期日` }, { value: 'm/d({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `1/25(日)` }, { value: 'm/d', info: `1/25, 2/1, ...` }, { value: '[$-804]yyyy mmmm d', info: `2009 一月 25` }, { value: 'dddd yy/m/d', info: `星期日 09/1/25` }, { value: 'yy/m/d', info: `09/1/25, 09/2/1, ...` }, { value: '[$-804]dddd mmmm d', info: `星期日 一月 25` }, { value: 'dddd m/d', info: `星期日 1/25` }, { value: '[$-804]mmmm d', info: `一月 25` }, { value: '[$-409]mmm d', info: `Jan 25, Feb 1, ...` }, { value: 'dddd d', info: `星期日 25` }, { value: 'dddd {!WEEK_FROM_START}', info: `星期日 1, ..., 星期日 52, 星期日 1, ...` }, { value: '{!WEEK_OF_YEAR}', info: `1, 2, ... 52,1,2,...` }, { value: 'd', info: `25, 1, ...` }, { value: 'ddd {!WEEK_OF_YEAR}', info: `1 1, ..., 7 1, 1 2, ..., 7 52` }, { value: '"第" {!WEEK_FROM_START} "周"', info: `第1周, 第2周, ... (从开始)` }, { value: '{!WEEK_FROM_START}', info: `1, 2, 3, 4, ... (从开始)` }, { value: '"W"{!WEEK_FROM_START}', info: `W1, W2, W3, W4, ... (从开始)` }, { value: '"第" {!WEEK_FROM_END} "周"', info: `第2周, 第1周, ... (从结束)` }, { value: '{!WEEK_FROM_END}', info: `4,3,2,1,...(从结束)` }, { value: '"W"{!WEEK_FROM_END}', info: `W4, W3, W2, W1, ... (从结束)` }, ], [ { value: '[DBNum1][$-804]yyyy"年"m"月"d"日";@', info: `二〇〇九年一月二十八日` }, { value: '[$-804]yyyy"年"m"月"d"日"dddd', info: `2009年1月28日星期三` }, { value: 'yyyy"年"m"月"d"日"', info: `2009年1月28日` }, { value: '[$-804]yyyy/m/d({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `2009/1/28(三)` }, { value: 'yyyy/m/d', info: `2009/1/28` }, { value: '[DBNum1][$-804]m"月"d"日"dddd;@', info: `一月二十八日星期三` }, { value: '[DBNum1][$-804]m"月"d"日";@', info: `一月二十八日, 一月二十九日, ...` }, { value: 'm"月"d"日"dddd', info: `1月28日星期三` }, { value: 'm"月"d"日"({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `1月28日(三)` }, { value: 'm"月"d"日"', info: `1月28日, 1月29日, ...` }, { value: '{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} m/d', info: `We 1/28` }, { value: 'm/d({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `1/28(三)` }, { value: 'm/d', info: `1/28, 1/29, ...` }, { value: '[DBNum1][$-804]m"月"d"日"', info: `'二十八日星期三` }, { value: 'dddd', info: `星期日, 星期一, 星期二, ...` }, { value: '({!DAY_OF_WEEK("日","一","二","三","四","五","六")})', info: `日, 一, 二, ...` }, { value: '[$-409]yy mmm d', info: `09 Jan 28` }, { value: 'yy/m/d', info: `09/1/28, 09/1/29, ...` }, { value: 'm"月"d"日" dddd', info: `1月28日 星期三` }, { value: '[$-409]mmm d', info: `Jan 28, Jan 29, ...` }, { value: 'dddd d', info: `星期三 28` }, { value: 'dddd', info: `星期日, 星期一, ...` }, { value: 'dddd', info: `星期日, 星期一, 星期二, ...` }, { value: 'd', info: `1, 2, ... ` }, { value: 'yy"年第" {!DAY_OF_YEAR} "天"', info: `09年第128天 (一年中的一天)` }, { value: 'yyyy"年第" {!DAY_OF_YEAR} "天"', info: `2009年第128天 (一年中的一天)` }, { value: '{!DAY_OF_YEAR}', info: `128 (一年中的一天)` }, { value: '"第" {!DAY_FROM_START} "天"', info: `第1天, 第2天, ... (从开始)` }, { value: '{!DAY_FROM_START}', info: `1, 2, 3, 4, ... (从开始)` }, { value: '"D" {!DAY_FROM_START}', info: `D1, D2, D3, ... (从开始)` }, { value: '"第" {!DAY_FROM_END} "天"', info: `第2天, 第1天, ... (从结束) ` }, { value: '{!DAY_FROM_END}', info: `4, 3, 2, 1, ... (从结束)` }, { value: '"D" {!DAY_FROM_END}', info: `D3, D2, D1, ... (从结束)` }, ], [ { value: 'm"月"d"日", h', info: `1月28日, 11 ` }, { value: 'mmm d, h', info: `Jan 28, 11` }, { value: 'm/d h', info: `1/28 11` }, { value: 'h', info: `11, 12,...` }, { value: 'h:mm', info: `11:00, 12:00, ...` }, { value: 'h', info: `11, 12,...` }, { value: '"第" {!HOUR_FROM_START} "小时"', info: `第1小时, 第2小时, ... (从开始)` }, { value: '{!HOUR_FROM_START}', info: `1, 2, 3, 4, ... (从开始)` }, { value: '"H" {!HOUR_FROM_START}', info: `H1, H2, H3, ... (从开始)` }, { value: '"第" {!HOUR_FROM_END} "小时"', info: `第2小时, 第1小时, ... (从结束)` }, { value: '{!HOUR_FROM_END}', info: `4, 3, 2, 1, ... (从结束)` }, { value: '"H" {!HOUR_FROM_END}', info: `H3, H2, H1, ... (从结束)` }, ], [ { value: 'hh:mm', info: `13:45, 13:46, ... ` }, { value: '{!Minute}', info: `45, 46, 47, ..` }, { value: '"第" {!Minute_FROM_START} "分"', info: `第1分, 第2分, ... (从开始)` }, { value: '{!Minute_FROM_START}', info: `1, 2, 3, 4, ... (从开始)` }, { value: '"M"{!Minute_FROM_START}', info: `M1, M2, M3, ... (从开始)` }, { value: '"第" {!Minute_FROM_END} "分"', info: `第2分, 第1分, ... (从结束)` }, { value: '{!Minute_FROM_END}', info: `4, 3, 2, 1, ... (从结束)` }, { value: '"M"{!Minute_FROM_END}', info: `M3, M2, M1, ... (从结束)` }, ] ]; window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 0 }); initSpread(spread); initSplitView(spread); }; function initSpread(spread) { spread.suspendPaint(); initDataSource(spread); initGanttSheet(spread); spread.resumePaint(); } function initDataSource(spread) { var tableName = "Gantt_Id"; var baseApiUrl = getBaseApiUrl(); var apiUrl = baseApiUrl + "/" + tableName; var dataManager = spread.dataManager(); myTable = dataManager.addTable("myTable", { batch: true, remote: { read: { url: apiUrl } }, schema: { hierarchy: { type: "Parent", column: "parentId" }, columns: { id: { isPrimaryKey: true }, taskNumber: { dataType: "rowOrder" } } } }); } function initGanttSheet(spread) { ganttSheet = spread.addSheetTab(0, "GanttSheet", GC.Spread.Sheets.SheetType.ganttSheet); var view = myTable.addView("ganttView", [ { value: "taskNumber", caption: "NO.", width: 60 }, { value: "name", caption: "Task Name", width: 200 }, { value: "duration", caption: "Duration", width: 90 }, { value: "predecessors", caption: "Predecessors", width: 120 } ]); view.fetch().then(function () { ganttSheet.bindGanttView(view); }); initSidePanel(ganttSheet); } function initSidePanel(ganttSheet) { var topScalePanel = document.getElementById("top-scale-panel"); var middleScalePanel = document.getElementById("middle-scale-panel"); var bottomScalePanel = document.getElementById("bottom-scale-panel"); var timescaleModeItem = document.getElementById("timescale-mode"); var scaleSeparatorItem = document.getElementById("scale-separator"); var topScaleUnitItem = document.getElementById("top-scale-unit"); var topScaleCountItem = document.getElementById("top-scale-count"); var topScaleAlignItem = document.getElementById("top-scale-align"); var topScaleFormatItem = document.getElementById("top-scale-format"); var topScaleTickItem = document.getElementById("top-scale-tick"); var middleScaleUnitItem = document.getElementById("middle-scale-unit"); var middleScaleCountItem = document.getElementById("middle-scale-count"); var middleScaleAlignItem = document.getElementById("middle-scale-align"); var middleScaleFormatItem = document.getElementById("middle-scale-format"); var middleScaleTickItem = document.getElementById("middle-scale-tick"); var bottomScaleUnitItem = document.getElementById("bottom-scale-unit"); var bottomScaleCountItem = document.getElementById("bottom-scale-count"); var bottomScaleAlignItem = document.getElementById("bottom-scale-align"); var bottomScaleFormatItem = document.getElementById("bottom-scale-format"); var bottomScaleTickItem = document.getElementById("bottom-scale-tick"); var setScaleItem = document.getElementById("set-scale"); syncOptionToPanel(true); timescaleModeItem.addEventListener("change", function () { var mode = Number(timescaleModeItem.value); if (mode === 1) { topScalePanel.classList.add("hide"); middleScalePanel.classList.remove("hide"); bottomScalePanel.classList.add("hide"); } else if (mode === 2) { topScalePanel.classList.add("hide"); middleScalePanel.classList.remove("hide"); bottomScalePanel.classList.remove("hide"); } else if (mode === 3) { topScalePanel.classList.remove("hide"); middleScalePanel.classList.remove("hide"); bottomScalePanel.classList.remove("hide"); } syncOptionToPanel(); }); scaleSeparatorItem.addEventListener("click", function () { toggleScaleSeparator(); }); topScaleTickItem.addEventListener("click", function () { toggleTopScaleTick(); }); middleScaleTickItem.addEventListener("click", function () { toggleMiddleScaleTick(); }); bottomScaleTickItem.addEventListener("click", function () { toggleBottomScaleTick(); }); topScaleUnitItem.addEventListener("change", function () { syncTopScaleFormatOptions(); }); middleScaleUnitItem.addEventListener("change", function () { syncMiddleScaleFormatOptions(); }); bottomScaleUnitItem.addEventListener("change", function () { syncBottomScaleFormatOptions(); }); setScaleItem.addEventListener("click", function () { var mode = Number(timescaleModeItem.value); var timescale = ganttSheet.project.timescale; var unit, formatter; ganttSheet.suspendPaint(); timescale.tierMode = Number(mode); timescale.showScaleSeparator = showScaleSeparator; if (mode === 1 || mode === 2 || mode === 3) { unit = Number(middleScaleUnitItem.value); formatter = middleScaleFormatItem.value ? middleScaleFormatItem.value : undefined; timescale.middleTier.unit = unit; timescale.middleTier.count = Number(middleScaleCountItem.value); timescale.middleTier.labelAlign = middleScaleAlignItem.value; if (formatter) { timescale.middleTier.formatter = supposedFormats[unit] ? supposedFormats[unit][formatter].value : undefined; } timescale.middleTier.showTickLines = showMiddleScaleTick; } if (mode === 2 || mode === 3) { unit = Number(bottomScaleUnitItem.value); formatter = bottomScaleFormatItem.value ? bottomScaleFormatItem.value : undefined; timescale.bottomTier.unit = unit; timescale.bottomTier.count = Number(bottomScaleCountItem.value); timescale.bottomTier.labelAlign = bottomScaleAlignItem.value; if (formatter) { timescale.bottomTier.formatter = supposedFormats[unit] ? supposedFormats[unit][formatter].value : undefined; } timescale.bottomTier.showTickLines = showBottomScaleTick; } if (mode === 3) { unit = Number(topScaleUnitItem.value); formatter = topScaleFormatItem.value ? topScaleFormatItem.value : undefined; timescale.topTier.unit = unit; timescale.topTier.count = Number(topScaleCountItem.value); timescale.topTier.labelAlign = topScaleAlignItem.value; if (formatter) { timescale.topTier.formatter = supposedFormats[unit] ? supposedFormats[unit][formatter].value : undefined; } timescale.topTier.showTickLines = showTopScaleTick; } ganttSheet.resumePaint(); }); function toggleScaleSeparator() { if (scaleSeparatorItem.classList.contains("active")) { showScaleSeparator = false; scaleSeparatorItem.classList.remove("active"); } else { showScaleSeparator = true; scaleSeparatorItem.classList.add("active"); } } function toggleTopScaleTick() { if (topScaleTickItem.classList.contains("active")) { showTopScaleTick = false; topScaleTickItem.classList.remove("active"); } else { showTopScaleTick = true; topScaleTickItem.classList.add("active"); } } function toggleMiddleScaleTick() { if (middleScaleTickItem.classList.contains("active")) { showMiddleScaleTick = false; middleScaleTickItem.classList.remove("active"); } else { showMiddleScaleTick = true; middleScaleTickItem.classList.add("active"); } } function toggleBottomScaleTick() { if (bottomScaleTickItem.classList.contains("active")) { showBottomScaleTick = false; bottomScaleTickItem.classList.remove("active"); } else { showBottomScaleTick = true; bottomScaleTickItem.classList.add("active"); } } function syncTopScaleFormatOptions() { var unit = topScaleUnitItem.value; var formatListItem = createFormatOptionList(unit); topScaleFormatItem.innerHTML = formatListItem; topScaleFormatItem.value = ""; } function syncMiddleScaleFormatOptions() { var unit = middleScaleUnitItem.value; var formatListItem = createFormatOptionList(unit); middleScaleFormatItem.innerHTML = formatListItem; middleScaleFormatItem.value = ""; } function syncBottomScaleFormatOptions() { var unit = bottomScaleUnitItem.value; var formatListItem = createFormatOptionList(unit); bottomScaleFormatItem.innerHTML = formatListItem; bottomScaleFormatItem.value = ""; } function syncOptionToPanel(includeMode) { var timescale = ganttSheet.project.timescale; var tierMode = timescale.tierMode; if (includeMode) { timescaleModeItem.value = tierMode; if (showScaleSeparator !== timescale.showScaleSeparator) { toggleScaleSeparator(); } } if (tierMode === 1 || tierMode === 2 || tierMode === 3) { middleScaleUnitItem.value = timescale.middleTier.unit; syncMiddleScaleFormatOptions(); middleScaleCountItem.value = timescale.middleTier.count; middleScaleAlignItem.value = timescale.middleTier.labelAlign; middleScaleFormatItem.value = timescale.middleTier.formatter ? timescale.middleTier.formatter : ""; if (showMiddleScaleTick !== timescale.middleTier.showTickLines) { toggleMiddleScaleTick(); } } if (tierMode === 2 || tierMode === 3) { bottomScaleUnitItem.value = timescale.bottomTier.unit; syncBottomScaleFormatOptions(); bottomScaleCountItem.value = timescale.bottomTier.count; bottomScaleAlignItem.value = timescale.bottomTier.labelAlign; bottomScaleFormatItem.value = timescale.bottomTier.formatter ? timescale.bottomTier.formatter : ""; if (showBottomScaleTick !== timescale.bottomTier.showTickLines) { toggleBottomScaleTick(); } } if (tierMode === 3) { topScaleUnitItem.value = timescale.topTier.unit; syncTopScaleFormatOptions(); topScaleCountItem.value = timescale.topTier.count; topScaleAlignItem.value = timescale.topTier.labelAlign; topScaleFormatItem.value = timescale.topTier.formatter ? timescale.topTier.formatter : ""; if (showTopScaleTick !== timescale.topTier.showTickLines) { toggleTopScaleTick(); } } } } function createFormatOptionList(target) { var formats = supposedFormats[target]; var options = `<option value="">None</option>`; for (let i = 0; i < formats.length; i++) { var format = formats[i]; options += `<option value="${i}">${format.info}</option>`; } return options; } function getBaseApiUrl() { return window.location.href.match(/http.+spreadjs\/SpreadJSTutorial\//)[0] + 'server/api'; } function initSplitView(spread) { var host = document.getElementById("split-view"); var content = host.getElementsByClassName("split-content")[0]; var panel = host.getElementsByClassName("split-panel")[0]; new SplitView({ host: host, content: content, panel: panel, refreshContent: function () { spread.refresh(); } }); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="spreadjs culture" content="zh-cn" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/spread/source/splitView/splitView.css"> <!-- Promise Polyfill for IE, https://www.npmjs.com/package/promise-polyfill --> <script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-ganttsheet/dist/gc.spread.sheets.ganttsheet.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/splitView/splitView.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div id="split-view" class="sample-tutorial"> <div id="ss" class="sample-spreadsheets split-content"></div> <div class="options-container split-panel"> <div class="option-row option-title"> Config the timescale style. </div> <div class="option-block"> <div class="option-row selection-box"> <label for="timescale-mode">Mode</label> <select id="timescale-mode"> <option value="1">One Tier(middle)</option> <option value="2" selected>Two Tier(middleBottom)</option> <option value="3">Three Tier(topMiddleBottom)</option> </select> </div> <div class="option-row"> <label class="option-checkbox active" id="scale-separator">Separate Scale</label> <div class="option-info">* checkbox toggle whether show the scale separator.</div> </div> </div> <div class="option-block hide" id="top-scale-panel"> <div class="option-info toggle">* toggle panel for the "Mode" option.</div> <div class="option-row option-title"> Top Scale Config. </div> <div class="option-row selection-box"> <label for="top-scale-unit">Unit</label> <select id="top-scale-unit"> <option value="1">years</option> <option value="2">halfYears</option> <option value="3">quarters</option> <option value="4">months</option> <option value="5">thirdsOfMonth</option> <option value="6">weeks</option> <option value="7">days</option> <option value="8">hours</option> <option value="9">minutes</option> </select> </div> <div class="option-row input-box"> <label for="top-scale-count">Count</label> <input type="text" id="top-scale-count" value="1" /> <div class="option-info valid">* valid value: integer</div> </div> <div class="option-row selection-box"> <label for="top-scale-align">Align</label> <select id="top-scale-align"> <option value="Left">Left</option> <option value="Center">Center</option> <option value="Right">Right</option> </select> </div> <div class="option-row selection-box"> <label for="top-scale-format">Formatter</label> <select id="top-scale-format"> <option value="">None</option> </select> </div> <div class="option-row"> <label class="option-checkbox active" id="top-scale-tick">Tick Lines</label> <div class="option-info">* checkbox toggle whether show the top scale tick lines.</div> </div> </div> <div class="option-block" id="middle-scale-panel"> <div class="option-info toggle">* toggle panel for the "Mode" option.</div> <div class="option-row option-title"> Middle Scale Config. </div> <div class="option-row selection-box"> <label for="middle-scale-unit">Unit</label> <select id="middle-scale-unit"> <option value="1">years</option> <option value="2">halfYears</option> <option value="3">quarters</option> <option value="4">months</option> <option value="5">thirdsOfMonth</option> <option value="6">weeks</option> <option value="7">days</option> <option value="8">hours</option> <option value="9">minutes</option> </select> </div> <div class="option-row input-box"> <label for="middle-scale-count">Count</label> <input type="text" id="middle-scale-count" value="1" /> <div class="option-info valid">* valid value: integer</div> </div> <div class="option-row selection-box"> <label for="middle-scale-align">Align</label> <select id="middle-scale-align"> <option value="Left">Left</option> <option value="Center">Center</option> <option value="Right">Right</option> </select> </div> <div class="option-row selection-box"> <label for="middle-scale-format">Formatter</label> <select id="middle-scale-format"> <option value="">None</option> </select> </div> <div class="option-row"> <label class="option-checkbox active" id="middle-scale-tick">Tick Lines</label> <div class="option-info">* checkbox toggle whether show the top scale tick lines.</div> </div> </div> <div class="option-block" id="bottom-scale-panel"> <div class="option-info toggle">* toggle panel for the "Mode" option.</div> <div class="option-row option-title"> Bottom Scale Config. </div> <div class="option-row selection-box"> <label for="bottom-scale-unit">Unit</label> <select id="bottom-scale-unit"> <option value="1">years</option> <option value="2">halfYears</option> <option value="3">quarters</option> <option value="4">months</option> <option value="5">thirdsOfMonth</option> <option value="6">weeks</option> <option value="7">days</option> <option value="8">hours</option> <option value="9">minutes</option> </select> </div> <div class="option-row input-box"> <label for="bottom-scale-count">Count</label> <input type="text" id="bottom-scale-count" value="1" /> <div class="option-info valid">* valid value: integer</div> </div> <div class="option-row selection-box"> <label for="bottom-scale-align">Align</label> <select id="bottom-scale-align"> <option value="Left">Left</option> <option value="Center">Center</option> <option value="Right">Right</option> </select> </div> <div class="option-row selection-box"> <label for="bottom-scale-format">Formatter</label> <select id="bottom-scale-format"> <option value="">None</option> </select> </div> <div class="option-row"> <label class="option-checkbox active" id="bottom-scale-tick">Tick Lines</label> <div class="option-info">* checkbox toggle whether show the top scale tick lines.</div> </div> </div> <input type="button" id="set-scale" class="option-button" value="Set Timescale"> </div> </div> </html>
.option-block { background: #fff; padding: 8px; margin: 12px 0; border-radius: 4px; border: 1px dashed #82bc00; box-shadow: 0px 0 6px 0 rgba(0,0,0,0.1); } .option-block.toggle { border: 1px dotted #f7a711; } .option-row { font-size: 14px; box-sizing: border-box; padding: 4px 0; } .option-title { font-weight: bold; color: #656565; } .option-info { font-size: 12px; color: #919191; margin-top: 6px; font-weight: normal; } .option-info.valid { color: #82bc00; } .option-info.toggle { color: #f7a711; } .option-button { width: 100%; padding: 0; line-height: 20px; background: #82bc00; color: #fff; transition: 0.3s; cursor: pointer; outline: none; border-radius: 4px; box-sizing: border-box; box-shadow: 0 1px 4px 0 rgba(0,0,0,0.3); border: none; } .option-button:hover { background: #82bc00; color: #fff; box-shadow: 0 3px 8px 0 rgba(0,0,0,0.4); } .option-checkbox { background: #fff; border: 1px dashed #f7a711; color: #f7a711; padding: 2px 4px; transition: 0.3s; box-sizing: border-box; cursor: pointer; } .option-checkbox.active { color: #fff; background: #f7a711; box-shadow: 0 1px 4px 0 rgba(0,0,0,0.3); border-radius: 4px; } .selection-box { position: relative; } .selection-box > select { text-align: left; width: 100%; height: 20px; padding: 0; line-height: 20px; background: transparent; border: none; border-bottom: 2px solid #656565; color: #656565; transition: 0.3s; cursor: pointer; outline: none; box-sizing: border-box; } .selection-box > select > option { background: white; } .selection-box > select:focus { border-bottom: 2px solid #82bc00; color: #82bc00; box-shadow: 0 2px 6px 0 rgba(0,0,0,0.3); } .selection-box > label { position: absolute; cursor: pointer; font-size: 12px; color: #fff; background: #656565; padding: 0 4px; right: 0; top: 6px; box-shadow: 0 1px 4px 0 rgba(0,0,0,0.3); } .input-box { position: relative; } .input-box > input[type=text] { width: 100%; background: transparent; border: none; color: #656565; border-bottom: 2px solid #656565; outline: none; box-sizing: border-box; transition: 0.3s; } .input-box > input[type=text]:focus { color: #82bc00; border-bottom: 2px solid #82bc00; } .input-box > label { cursor: pointer; position: absolute; right: 0; top: 5px; font-size: 12px; color: #fff; background: #656565; padding: 0 4px; box-shadow: 0 1px 4px 0 rgba(0,0,0,0.3); }