Overview

The timescale is the column header of the gantt chart in a GanttSheet, and it allows you to show smaller or greater time units.

Description
app.vue
index.html
Copy to CodeMine

Tier Mode

There are 3 tiers (top, middle and bottom tier) in the timescale layout.

You can use GC.Spread.Sheets.GanttSheet.TimescaleTierMode to change its layout:

  • middle
  • middleBottom
  • topMiddleBottom
var tierMode = GC.Spread.Sheets.GanttSheet.TimescaleTierMode.middleBottom;
ganttSheet.project.timescale.tierMode = tierMode;

Show Scale Separator

The scale line separates the top and middle tiers.

You can show or hide the scale line:

var showScaleSeparator = true;
ganttSheet.project.timescale.showScaleSeparator = showScaleSeparator;

Tiers Config

Each top, middle and bottom tier is configurable with these properties:

  • unit: GC.Spread.Sheets.GanttSheet.TimescaleUnit
  • count: number
  • labelAlign: "Left" | "Center" | "Right"
  • showTickLines: boolean
  • formatter: string

The formatter can be a Spread Number Format string for Date values like "yyyy-mm-dd", with GanttSheet special keywords, or it can be a callback function that will be executed during formatting.

var timescale = ganttSheet.project.timescale;
var targetTier = "middleTier";
timescale[targetTier].unit = GC.Spread.Sheets.GanttSheet.TimescaleUnit.days;
timescale[targetTier].count = 2;
timescale[targetTier].labelAlign = "Center";
timescale[targetTier].formatter = "dddd";
timescale[targetTier].showTickLines = false;
Tier Mode There are 3 tiers (top, middle and bottom tier) in the timescale layout. You can use GC.Spread.Sheets.GanttSheet.TimescaleTierMode to change its layout: middle middleBottom topMiddleBottom Show Scale Separator The scale line separates the top and middle tiers. You can show or hide the scale line: Tiers Config Each top, middle and bottom tier is configurable with these properties: unit: GC.Spread.Sheets.GanttSheet.TimescaleUnit count: number labelAlign: "Left" | "Center" | "Right" showTickLines: boolean formatter: string The formatter can be a Spread Number Format string for Date values like "yyyy-mm-dd", with GanttSheet special keywords, or it can be a callback function that will be executed during formatting.
<template> <div id="split-view" class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets split-content" @workbookInitialized="initSpread"> </gc-spread-sheets> <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" v-model="timescaleMode" @change="changeTimeScaleMode($event)"> <option value="1">One Tier(middle)</option> <option value="2">Two Tier(middleBottom)</option> <option value="3">Three Tier(topMiddleBottom)</option> </select> </div> <div class="option-row"> <label class="option-checkbox" id="scale-separator" v-bind:class="{ active: showScaleSeparator }" @click="toggleScaleSeparator">Separate Scale</label> <div class="option-info"> * checkbox toggle whether show the scale separator. </div> </div> </div> <div class="option-block" id="top-scale-panel" v-bind:class="{ hide: !showTopScalePanel }"> <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" v-model="topScaleUnit" @change="syncTopScaleFormatOptions($event)"> <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" v-model="topScaleCount" /> <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" v-model="topScaleAlign"> <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" v-model="topScaleFormat"> <option value="">None</option> </select> </div> <div class="option-row"> <label class="option-checkbox" id="top-scale-tick" v-bind:class="{ active: showTopScaleTick }" @click="toggleTopScaleTick">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" v-bind:class="{ hide: !showMiddleScalePanel }"> <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" v-model="middleScaleUnit" @change="syncMiddleScaleFormatOptions($event)"> <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" v-model="middleScaleCount" /> <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" v-model="middleScaleAlign"> <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" v-model="middleScaleFormat"> <option value="">None</option> </select> </div> <div class="option-row"> <label class="option-checkbox" id="middle-scale-tick" v-bind:class="{ active: showMiddleScaleTick }" @click="toggleMiddleScaleTick">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" v-bind:class="{ hide: !showBottomScalePanel }"> <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" v-model="bottomScaleUnit" @change="syncBottomScaleFormatOptions($event)"> <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" v-model="bottomScaleCount" /> <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" v-model="bottomScaleAlign"> <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" v-model="bottomScaleFormat"> <option value="">None</option> </select> </div> <div class="option-row"> <label class="option-checkbox" id="bottom-scale-tick" v-bind:class="{ active: showBottomScaleTick }" @click="toggleBottomScaleTick">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" @click="updateTimeScale" /> </div> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import { ref } from "vue"; import "@mescius/spread-sheets-tablesheet"; import "@mescius/spread-sheets-ganttsheet"; import "@mescius/spread-sheets-vue"; let supposedFormats = [ undefined, [ { value: `yyyy`, info: `2009, 2010,... ` }, { value: `'yy`, info: `'09, '10, ...` }, { value: `yy`, info: `09, 10,...` }, { value: `"Year" {!YEAR_FROM_START}`, info: `Year 1, Year 2 ... (From Start)`, }, { value: `"Y"{!YEAR_FROM_START}`, info: `Y1, Y2, Y3, ... (From Start)`, }, { value: `{!YEAR_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)` }, { value: `"Year" {!YEAR_FROM_END}`, info: `Year 2, Year 1... (From End)`, }, { value: `"Y" {!YEAR_FROM_END}`, info: `Y3, Y2, Y1, ... (From End)` }, { value: `{!YEAR_FROM_END}`, info: `4, 3, 2, 1, ... (From End)` }, ], [ { value: `{!HALF_YEAR("1st","2nd")} "Half"`, info: `1st Half, 2nd Half, ... `, }, { value: `yyyy, "Half" {!HALF_YEAR("1","2")}`, info: `2009, Half 1, 2009, Half 2, ...`, }, { value: `"Half" {!HALF_YEAR("1","2")}`, info: `Half 1, Half 2, ...`, }, { 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" {!HALF_YEAR_FROM_START}`, info: `Half 1, Half 2, Half 3, ... (From Start)`, }, { value: `"H" {!HALF_YEAR_FROM_START}`, info: `H1, H2, H3, ... (From Start)`, }, { value: `{!HALF_YEAR_FROM_START}`, info: `1, 2, 3, ... (From Start)`, }, { value: `"Half" {!HALF_YEAR_FROM_END}`, info: `Half 3, Half 2, Half 1, ... (From End)`, }, { value: `"H"{!HALF_YEAR_FROM_END}`, info: `H3, H2, H1, ... (From End)`, }, { value: `{!HALF_YEAR_FROM_END}`, info: `3, 2, 1, ... (From End)` }, ], [ { value: `{!QUARTER("1st","2nd","3rd","4th")} "Quarter"`, info: `1st Quarter`, }, { value: `yyyy "Qtr" {!QUARTER("1","2","3","4")}`, info: `2009 Qtr 1`, }, { value: `"Qtr" {!QUARTER("1","2","3","4")}`, info: `Qtr 1, Qtr 2, ...`, }, { value: `'yy "Q"{!QUARTER("1","2","3","4")}`, info: `'09 Q1, '09 Q2, ...`, }, { value: `"Q"{!QUARTER("1","2","3","4")}`, info: `Q1, Q2, ...` }, { value: `{!QUARTER("1","2","3","4")}`, info: `1, 2, ...` }, { value: `{!QUARTER("1","2","3","4")}"Q"yy`, info: `1Q09, 2Q09, ...`, }, { value: `"Quarter" {!QUARTER_FROM_START}`, info: `Quarter 1, Quarter 2, ... (From Start)`, }, { value: `"Q"{!QUARTER_FROM_START}`, info: `Q1, Q2, Q3, Q4, ... (From Start)`, }, { value: `{!QUARTER_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)`, }, { value: `"Quarter" {!QUARTER_FROM_END}`, info: `Quarter 2, Quarter 1, ... (From End)`, }, { value: `"Q"{!QUARTER_FROM_END}`, info: `Q4, Q3, Q2, Q1, ... (From End)`, }, { value: `{!QUARTER_FROM_END}`, info: `4, 3, 2, 1, ... (From End)` }, ], [ { value: `yyyy mmmm`, info: `2009 January ` }, { value: `yy mmm`, info: `'09 Jan` }, { value: `mmmm`, info: `January` }, { value: `mmm`, info: `Jan, Feb,..` }, { value: `mmmmm`, info: `J, F, ...` }, { value: `m`, info: `1, 2,...` }, { value: `'yy m`, info: `'09 1` }, { value: `yy/m`, info: `09/1` }, { value: `"Month" {!MONTH_FROM_START}`, info: `Month 1, Month 2, ... (From Start)`, }, { value: `"M" {!MONTH_FROM_START}`, info: `M1, M2, M3, ... (From Start)`, }, { value: `{!MONTH_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)`, }, { value: `"Month" {!MONTH_FROM_END}`, info: `Month 2, Month 1, ... (From End)`, }, { value: `"M"{!MONTH_FROM_END}`, info: `M3, M2, M1, ... (From End)` }, { value: `{!MONTH_FROM_END}`, info: `4, 3, 2, 1, ... (From End)` }, ], [ { value: `d`, info: `1, 11, 21, ... ` }, { value: `{!THIRDS_OF_MONTH("B","M","E")}`, info: `B, M, E,..` }, { value: `{!THIRDS_OF_MONTH("Beginning","Middle","End")}`, info: `Beginning, Middle, End, ...`, }, { 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("Beginning","Middle","End")}`, info: `January Beginning, January Middle, ...`, }, { value: `mmm d`, info: `Jan 1, Jan 11, Jan 21, ...` }, { value: `mmm {!THIRDS_OF_MONTH("B","M","E")}`, info: `Jan B. Jan M, Jan E, ...`, }, { value: `mmmm d`, info: `January 1, January 11, January 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: `'yy mmm d`, info: `'09 Jan 1, '09 Jan 11, '09 Jan 21, ...`, }, { value: `'yy mmm {!THIRDS_OF_MONTH("B","M","E")}`, info: `'09 Jan B, '09 Jan M, '09 Jan E, ...`, }, { value: `yyyy mmmm d`, info: `2009 January 1, 2009 January 11, ...`, }, { value: `yyyy mmmm {!THIRDS_OF_MONTH("Beginning","Middle","End")}`, info: `2009 January Beginning, ...`, }, ], [ { value: `yyyy mmmm d`, info: `2009 January 25 ` }, { value: `'yy mmm d`, info: `'09 Jan 25` }, { value: `mmmm d`, info: `January 25` }, { value: `mmm d`, info: `Jan 25, Feb 1,...` }, { value: `mmmmm d`, info: `J 25, F1, ...` }, { value: `yy/m/d`, info: `09/1/25, 09/2/1, ...` }, { value: `m/d`, info: `1/25, 2/1, ...` }, { value: `d`, info: `25, 1, ...` }, { value: `ddd dd`, info: `Sun 25` }, { value: `ddd yy/m/d`, info: `Sun 09/1/25` }, { value: `ddd 'yy mmmm d`, info: `Sun '09 January 25` }, { value: `ddd 'yy mmm d`, info: `Sun '09 Jan 25` }, { value: `ddd mmmm d`, info: `Sun January 25` }, { value: `ddd mmm d`, info: `Sun Jan 25` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} mmm d`, info: `Su Jan 25`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")} mmm d`, info: `S Jan 25`, }, { value: `ddd dd`, info: `Sun 25` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} d`, info: `Su 25`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")}mmmmm d`, info: `SJ 25`, }, { value: `ddd m/d`, info: `Sun 1/25` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} m/d`, info: `Su 1/25`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")} m/d`, info: `S 1/25`, }, { value: `{!WEEK_OF_YEAR}`, info: `1, 2, ... 52, 1, 2, ...` }, { value: `ddd {!WEEK_OF_YEAR}`, info: `Sun 1, ..., Sun 52, Sun 1, ...`, }, { value: `"Week" {!WEEK_FROM_START}`, info: `Week 1, Week 2, ... (From Start)`, }, { value: `"W"{!WEEK_FROM_START}`, info: `W1, W2, W3, W4, ... (From Start)`, }, { value: `{!WEEK_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)` }, { value: `"Week" {!WEEK_FROM_END}`, info: `Week 2, Week 1, ... (From End)`, }, { value: `"W"{!WEEK_FROM_END}`, info: `W4, W3, W2, W1, ... (From End)`, }, { value: `{!WEEK_FROM_END}`, info: `4, 3, 2, 1, ...(From End)` }, ], [ { value: `ddd 'yy mmm d`, info: `Wed '09 Jan 28 ` }, { value: `ddd mmmm d`, info: `Wed January 28` }, { value: `ddd mmm d`, info: `Wed Jan 28` }, { value: `ddd mmmmm d`, info: `Wed J 28` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} d`, info: `We 28`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")}mmmmm d `, info: `WJ 28`, }, { value: `ddd m/d`, info: `Wed 1/28` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} m/d`, info: `We 1/28`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")} m/d`, info: `W 1/28`, }, { value: `ddd d`, info: `Wed 28` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")} d`, info: `We 28`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")} d `, info: `W 28`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")}d `, info: `W28`, }, { value: `'yy mmm d`, info: `'09 Jan 28` }, { value: `mmm d`, info: `Jan 28, Jan 29, ...` }, { value: `mmmmm d`, info: `J 28, J 29, ...` }, { value: `dddd`, info: `Sunday, Monday, ...` }, { value: `ddd`, info: `Sun, Mon,Tue, ...` }, { value: `{!DAY_OF_WEEK("Su", "Mo","Tu","We","Th","Fr","St")}`, info: `Su, Mo, Tu,...`, }, { value: `{!DAY_OF_WEEK("S", "M","T","W","T","F","S")}`, info: `S, M,T,...`, }, { value: `yy/m/d`, info: `09/1/28, 09/1/29, ...` }, { value: `ddd yy/m/d`, info: `Wed 09/1/28, Thu 09/1/29, ...` }, { value: `m/d`, info: `1/28, 1/29, ...` }, { value: `d`, info: `1, 2, ... ` }, { value: `yyyy {!DAY_OF_YEAR}`, info: `2009 128 (Day of Year)` }, { value: `'yy {!DAY_OF_YEAR}`, info: `'09 128 (Day of Year)` }, { value: `{!DAY_OF_YEAR}`, info: `128 (Day of Year)` }, { value: `"Day"{!DAY_FROM_START}`, info: `Day 1, Day 2 ... (From Start)`, }, { value: `"D" {!DAY_FROM_START}`, info: `D1, D2, D3, ... (From Start)`, }, { value: `{!DAY_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)` }, { value: `"Day" {!DAY_FROM_END}`, info: `Day 2 Day 1, ... (From End) `, }, { value: `"D" {!DAY_FROM_END}`, info: `D3, D2, D1, ... (From End)` }, { value: `{!DAY_FROM_END}`, info: `4, 3, 2, 1, ... (From End)` }, ], [ { value: `ddd mmm d, h`, info: `Wed Jan 28, 11 ` }, { value: `mmm d, h`, info: `Jan 28, 11` }, { value: `m/d h`, info: `1/28 11` }, { value: `h:mm`, info: `11, info: 00, 12, info: 00, ...` }, { value: `h`, info: `11, 12, ...` }, { value: `hh`, info: `11, 12, ...` }, { value: `"Hour" {!HOUR_FROM_START}`, info: `Hour 1, Hour 2, ... (From Start)`, }, { value: `"H"{!HOUR_FROM_START}`, info: `H1, H2, H3, ... (From Start)`, }, { value: `{!HOUR_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)` }, { value: `"Hour" {!HOUR_FROM_END}`, info: `Hour 2, Hour 1, ... (From End)`, }, { value: `"H"{!HOUR_FROM_END}`, info: `H3, H2, H1, ... (From End)` }, { value: `{!HOUR_FROM_END}`, info: `4, 3, 2, 1, ... (From End)` }, ], [ { value: `hh:mm`, info: `13:45, 13:46, ... ` }, { value: `{!Minute}`, info: `45, 46, 47, ..` }, { value: `"Minute" {!Minute_FROM_START}`, info: `Minute 1, Minute 2, ... (From Start)`, }, { value: `"M"{!Minute_FROM_START}`, info: `M1, M2, M3, ... (From Start)`, }, { value: `{!Minute_FROM_START}`, info: `1, 2, 3, 4, ... (From Start)`, }, { value: `"Minute" {!Minute_FROM_END}`, info: `Minute 2, Minute 1, ... (From End)`, }, { value: `"M"{!Minute_FROM_END}`, info: `M3, M2, M1, ... (From End)`, }, { value: `{!Minute_FROM_END}`, info: `4, 3, 2, 1, ... (From End)` }, ], ]; let myTable; let ganttSheet; const showScaleSeparator = ref(true); const showTopScaleTick = ref(true); const showMiddleScaleTick = ref(true); const showBottomScaleTick = ref(true); const timescaleMode = ref("2"); const showTopScalePanel = ref(false); const showMiddleScalePanel = ref(true); const showBottomScalePanel = ref(true); const topScaleUnit = ref(""); const topScaleCount = ref("1"); const topScaleAlign = ref(""); const topScaleFormat = ref(""); const middleScaleUnit = ref("6"); const middleScaleCount = ref("1"); const middleScaleAlign = ref("Left"); const middleScaleFormat = ref(""); const bottomScaleUnit = ref("7"); const bottomScaleCount = ref("1"); const bottomScaleAlign = ref("Center"); const bottomScaleFormat = ref(""); function initSpread(spread) { spread.suspendPaint(); spread.clearSheets(); initDataSource(spread); initGanttSheet(spread); spread.resumePaint(); initSplitView(spread); } 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 toggleScaleSeparator() { showScaleSeparator.value = !showScaleSeparator.value; let timescale = ganttSheet.project.timescale; timescale.showScaleSeparator = showScaleSeparator.value; } function toggleTopScaleTick() { showTopScaleTick.value = !showTopScaleTick.value; } function toggleMiddleScaleTick() { showMiddleScaleTick.value = !showMiddleScaleTick.value; } function toggleBottomScaleTick() { showBottomScaleTick.value = !showBottomScaleTick.value; } function changeTimeScaleMode(event) { timescaleMode.value = event.target.value; let mode = Number(timescaleMode.value); if (mode === 1) { showTopScalePanel.value = false; showMiddleScalePanel.value = true; showBottomScalePanel.value = false; } else if (mode === 2) { showTopScalePanel.value = false; showMiddleScalePanel.value = true; showBottomScalePanel.value = true; } else if (mode === 3) { showTopScalePanel.value = true; showMiddleScalePanel.value = true; showBottomScalePanel.value = true; } syncOptionToPanel(undefined); } function syncTopScaleFormatOptions() { let topScaleFormatItem = document.getElementById("top-scale-format"); let unit = topScaleUnit.value; let formatListItem = createFormatOptionList(unit); topScaleFormatItem.innerHTML = formatListItem; topScaleFormat.value = ""; } function syncMiddleScaleFormatOptions() { let middleScaleFormatItem = document.getElementById( "middle-scale-format" ); let unit = middleScaleUnit.value; let formatListItem = createFormatOptionList(unit); middleScaleFormatItem.innerHTML = formatListItem; middleScaleFormat.value = ""; } function syncBottomScaleFormatOptions() { let bottomScaleFormatItem = document.getElementById( "bottom-scale-format" ); let unit = bottomScaleUnit.value; let formatListItem = createFormatOptionList(unit); bottomScaleFormatItem.innerHTML = formatListItem; bottomScaleFormat.value = ""; } function initSidePanel() { syncOptionToPanel(true); } function syncOptionToPanel(includeMode) { let timescale = ganttSheet.project.timescale; let tierMode = Number(timescaleMode.value); if (includeMode) { if (showScaleSeparator.value !== timescale.showScaleSeparator) { toggleScaleSeparator(); } } if (tierMode === 1 || tierMode === 2 || tierMode === 3) { middleScaleUnit.value = timescale.middleTier.unit; syncMiddleScaleFormatOptions(); middleScaleCount.value = timescale.middleTier.count; middleScaleAlign.value = timescale.middleTier.labelAlign; middleScaleFormat.value = timescale.middleTier.formatter ? timescale.middleTier.formatter : ""; if (showMiddleScaleTick.value !== timescale.middleTier.showTickLines) { toggleMiddleScaleTick(); } } if (tierMode === 2 || tierMode === 3) { bottomScaleUnit.value = timescale.bottomTier.unit; syncBottomScaleFormatOptions(); bottomScaleCount.value = timescale.bottomTier.count; bottomScaleAlign.value = timescale.bottomTier.labelAlign; bottomScaleFormat.value = timescale.bottomTier.formatter ? timescale.bottomTier.formatter : ""; if (showBottomScaleTick.value !== timescale.bottomTier.showTickLines) { toggleBottomScaleTick(); } } if (tierMode === 3) { topScaleUnit.value = timescale.topTier.unit; syncTopScaleFormatOptions(); topScaleCount.value = timescale.topTier.count; topScaleAlign.value = timescale.topTier.labelAlign; topScaleFormat.value = timescale.topTier.formatter ? timescale.topTier.formatter : ""; if (showTopScaleTick.value !== timescale.topTier.showTickLines) { toggleTopScaleTick(); } } ganttSheet.resumePaint(); } function updateTimeScale() { let mode = Number(timescaleMode.value); let timescale = ganttSheet.project.timescale; let unit, formatter; ganttSheet.suspendPaint(); timescale.tierMode = Number(mode); timescale.showScaleSeparator = showScaleSeparator.value; if (mode === 1 || mode === 2 || mode === 3) { unit = Number(middleScaleUnit.value); formatter = middleScaleFormat.value ? middleScaleFormat.value : undefined; timescale.middleTier.unit = unit; timescale.middleTier.count = Number(middleScaleCount.value); timescale.middleTier.labelAlign = middleScaleAlign.value; if (formatter) { timescale.middleTier.formatter = supposedFormats[unit] ? supposedFormats[unit][formatter].value : undefined; } else { timescale.middleTier.formatter = undefined; } timescale.middleTier.showTickLines = showMiddleScaleTick.value; } if (mode === 2 || mode === 3) { unit = Number(bottomScaleUnit.value); formatter = bottomScaleFormat.value ? bottomScaleFormat.value : undefined; timescale.bottomTier.unit = unit; timescale.bottomTier.count = Number(bottomScaleCount.value); timescale.bottomTier.labelAlign = bottomScaleAlign.value; if (formatter) { timescale.bottomTier.formatter = supposedFormats[unit] ? supposedFormats[unit][formatter].value : undefined; } else { timescale.bottomTier.formatter = undefined; } timescale.bottomTier.showTickLines = showBottomScaleTick.value; } if (mode === 3) { unit = Number(topScaleUnit.value); formatter = topScaleFormat.value ? topScaleFormat.value : undefined; timescale.topTier.unit = unit; timescale.topTier.count = Number(topScaleCount.value); timescale.topTier.labelAlign = topScaleAlign.value; if (formatter) { timescale.topTier.formatter = supposedFormats[unit] ? supposedFormats[unit][formatter].value : undefined; } else { timescale.topTier.formatter = undefined; } timescale.topTier.showTickLines = showTopScaleTick.value; } ganttSheet.resumePaint(); } function createFormatOptionList(target) { let formats = supposedFormats[target]; let options = `<option value="">None</option>`; for (let i = 0; i < formats.length; i++) { let format = formats[i]; options += `<option value="${i}">${format.info}</option>`; } return options; } 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(); }, }); } function getBaseApiUrl() { return ( window.location.href.match(/http.+spreadjs\/demos\//)[0] + "server/api" ); } </script> <style scoped> #app { height: 100%; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .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); } </style>
<!DOCTYPE html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/spread/source/splitView/splitView.css"> <script src="$DEMOROOT$/en/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script src="$DEMOROOT$/spread/source/splitView/SplitView.js"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/en/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js', '@mescius/spread-sheets-tablesheet': 'npm:@mescius/spread-sheets-tablesheet/index.js', '@mescius/spread-sheets-ganttsheet': 'npm:@mescius/spread-sheets-ganttsheet/index.js' }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);