迷你图配置

创建迷你图后,可以控制显示哪些值点 (例如高、 低、 姓或任何负值)、 更改 (行、 列或盈亏) 迷你图的类型,应用样式,以及控制是否显示水平轴。

你可以通过使一些或所有标记可见来突出显示折线迷你图中的各个数据标记(值)。 showFirst: 迷你图组中的每一个迷你图的第一个数据点的的格式是否不同。 showHigh: 迷你图组中的每一个迷你图的最高点所对应的数据点的格式是否不同。 showLast: 迷你图组中的每一个迷你图的最末点所对应的数据点的格式是否不同。 showLow: 迷你图组中的每一个迷你图的最低点所对应的数据点的格式是否不同。 showNegative: 迷你图组中的每一个迷你图的负数数据点的格式是否不同。 showMarkers: 迷你图组中的每一个迷你图的数据标记是否显示。 你可以通过下面这些方法来设置迷你图的样式和格式: axisColor: 轴线的颜色。 firstMarkerColor: 迷你图组中的每一个迷你图的第一个数据点的颜色。 highMarkerColor: 迷你图组中的每一个迷你图的最高数据点的颜色。 lastMarkerColor: 迷你图组中的每一个迷你图的最末数据点的颜色。 lowMarkerColor: 迷你图组中的每一个迷你图的最低数据点的颜色。 markersColor:迷你图组中的每一个迷你图的数据标记的颜色。 negativeColor: 迷你图组中的每一个迷你图的负数数据点的颜色。 seriesColor: 迷你图组中的每一个迷你图的颜色。 迷你图还提供了一些额外的配置。比如,当数据系列中有空值的时候,你可以使用 displayEmptyCellsAs 方法来控制是否显示空值。例如: 这个示例演示了如何应用这些配置:
import { Component, NgModule, enableProdMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import '@grapecity-software/spread-sheets-resources-zh'; GC.Spread.Common.CultureManager.culture("zh-cn"); import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { SpreadSheetsModule } from '@grapecity-software/spread-sheets-angular'; import GC from '@grapecity-software/spread-sheets'; import './styles.css'; @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { spread: GC.Spread.Sheets.Workbook; firstMarkerColor = '(none)'; buttonDisable = true; type = 0; highMarkerColor = 'Blue'; lastMarkerColor = '(none)'; lowMarkerColor = 'Blue'; negativeMarkerColor = 'Brown'; markersColor = '(none)'; axisColor = 'black'; seriesColor = '(none)'; showFirst = false; showHigh = false; showLast = false; showLow = false; showNegative = true; showMarkers = false; displayXAxis = true; hostStyle = { width: 'calc(100% - 280px)', height: '100%', overflow: 'hidden', float: 'left' }; buttonClick() { let sheet = this.spread.getActiveSheet(); sheet.suspendPaint(); let sels = sheet.getSelections(); let setting = new GC.Spread.Sheets.Sparklines.SparklineSetting(); let sparklineType = this.type; if (sels && sels.length > 0) { let sel = this.getActualRange(sels[0], sheet.getRowCount(), sheet.getColumnCount()); let sparkline = this.findSparkLine(sheet, sel); if (sparkline != null) { sparkline.setting(this.buildSparklineSettings(setting)); sparkline.sparklineType(sparklineType); } } sheet.resumePaint(); } showFirstChange(e: any) { this.showFirst = e.target.checked; } showHighChange(e: any) { this.showHigh = e.target.checked; } showLastChange(e: any) { this.showLast = e.target.checked; } showLowChange(e: any) { this.showLow = e.target.checked; } showNegativeChange(e: any) { this.showNegative = e.target.checked; } showMarkersChange(e: any) { this.showMarkers = e.target.checked; } displayXAxisChange(e: any) { this.displayXAxis = e.target.checked; } firstMarkerColorChange(e: any) { this.firstMarkerColor = e.target.value; } typeChange(e: any) { this.type = parseInt(e.target.value); } highMarkerColorChange(e: any) { this.highMarkerColor = e.target.value; } lastMarkerColorChange(e: any) { this.lastMarkerColor = e.target.value; } lowMarkerColorChange(e: any) { this.lowMarkerColor = e.target.value; } negativeMarkerColorChange(e: any) { this.negativeMarkerColor = e.target.value; } markersColorChange(e: any) { this.markersColor = e.terget.value; } axisColorChange(e: any) { this.axisColor = e.target.value; } seriesColorChange(e: any) { this.seriesColor = e.target.value; } getActualRange(range: any, maxRowCount: number, maxColCount: number) { let row = range.row < 0 ? 0 : range.row; let col = range.col < 0 ? 0 : range.col; let rowCount = range.rowCount < 0 ? maxRowCount : range.rowCount; let colCount = range.colCount < 0 ? maxColCount : range.colCount; return new GC.Spread.Sheets.Range(row, col, rowCount, colCount); } findSparkLine(sheet: GC.Spread.Sheets.Worksheet, range: any) { let row = range.row, col = range.col, rowCount = range.rowCount, colCount = range.colCount; for (let i = 0; i < rowCount; i++) { for (let j = 0; j < colCount; j++) { let sparkline = sheet.getSparkline(row + i, col + j); if (sparkline != null) { return sparkline; } } } return null; } buildSparklineSettings(setting: any) { if (setting == null) setting = new GC.Spread.Sheets.Sparklines.SparklineSetting(); let firstMarkerColor = this.firstMarkerColor; if (firstMarkerColor != '(none)') setting.options.firstMarkerColor = firstMarkerColor; let highMarkerColor = this.highMarkerColor; if (highMarkerColor != '(none)') setting.options.highMarkerColor = highMarkerColor; let lastMarkerColor = this.lastMarkerColor; if (lastMarkerColor != '(none)') setting.options.lastMarkerColor = lastMarkerColor; let lowMarkerColor = this.lowMarkerColor; if (lowMarkerColor != '(none)') setting.options.lowMarkerColor = lowMarkerColor; let negativeMarkerColor = this.negativeMarkerColor; if (negativeMarkerColor != '(none)') setting.options.negativeColor = negativeMarkerColor; let markersColor = this.markersColor; if (markersColor != '(none)') setting.options.markersColor = markersColor; let AxisColor = this.axisColor; if (AxisColor != '(none)') setting.options.axisColor = AxisColor; let SeriesColor = this.seriesColor; if (SeriesColor != '(none)') setting.options.seriesColor = SeriesColor; setting.options.showFirst = this.showFirst; setting.options.showHigh = this.showHigh; setting.options.showLast = this.showLast; setting.options.showLow = this.showLow; setting.options.showNegative = this.showNegative; setting.options.showMarkers = this.showMarkers; setting.options.displayXAxis = this.displayXAxis; return setting; } initSpread($event: any) { this.spread = $event.spread; let self = this; let sheet = this.spread.getSheet(0); sheet.suspendPaint(); sheet.options.allowCellOverflow = true; let spreadNS = GC.Spread.Sheets; var data = [1, -2, -1, 6, 4, -4, 3, 8]; var dateAxis = [new Date(2011, 0, 5), new Date(2011, 0, 1), new Date(2011, 1, 11), new Date(2011, 2, 1), new Date(2011, 1, 1), new Date(2011, 1, 3), new Date(2011, 2, 6), new Date(2011, 1, 19)]; sheet.setValue(0, 0, "Series 1"); sheet.setValue(0, 1, "Series 2"); for (let i = 0; i < 8; i++) { sheet.setValue(i + 1, 0, data[i]); sheet.getCell(i + 1, 1).value(dateAxis[i]).formatter("yyyy-mm-dd"); } sheet.setColumnWidth(1, 100); sheet.setValue(10, 0, "*Data Range is A2-A9"); sheet.setValue(11, 0, "*Date axis range is B2-B9"); var dataRange = new spreadNS.Range(1, 0, 8, 1); var dateAxisRange = new spreadNS.Range(1, 1, 8, 1); sheet.getCell(13, 0).text("Sparkline with dateAxis:"); sheet.getCell(14, 0).text("(1) Line"); sheet.getCell(14, 3).text("(2)Column"); sheet.getCell(14, 6).text("(3)Winloss"); //line sheet.addSpan(15, 0, 4, 3); var setting = new spreadNS.Sparklines.SparklineSetting(); setting.options.showMarkers = true; setting.options.displayXAxis = true; setting.options.showFirst = true; setting.options.showLast = true; setting.options.showLow = true; setting.options.showHigh = true; setting.options.showNegative = true; sheet.setSparkline(15, 0, dataRange , spreadNS.Sparklines.DataOrientation.vertical , spreadNS.Sparklines.SparklineType.line , setting , dateAxisRange , spreadNS.Sparklines.DataOrientation.vertical ); //column sheet.addSpan(15, 3, 4, 3); setting = new spreadNS.Sparklines.SparklineSetting(); setting.options.displayXAxis = true; setting.options.showFirst = true; setting.options.showLast = true; setting.options.showLow = true; setting.options.showHigh = true; setting.options.showNegative = true; sheet.setSparkline(15, 3, dataRange , spreadNS.Sparklines.DataOrientation.vertical , spreadNS.Sparklines.SparklineType.column , setting , dateAxisRange , spreadNS.Sparklines.DataOrientation.vertical ); //winloss sheet.addSpan(15, 6, 4, 3); setting = new spreadNS.Sparklines.SparklineSetting(); setting.options.displayXAxis = true; setting.options.showNegative = true; sheet.setSparkline(15, 6, dataRange , spreadNS.Sparklines.DataOrientation.vertical , spreadNS.Sparklines.SparklineType.winloss , setting , dateAxisRange , spreadNS.Sparklines.DataOrientation.vertical); sheet.bind(GC.Spread.Sheets.Events.SelectionChanged, selectionChangedCallback); sheet.resumePaint(); function selectionChangedCallback() { let sheet = self.spread.getActiveSheet(); let sparkline = sheet.getSparkline(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex()); if (sparkline) { getSparklineSettings(sparkline); self.buttonDisable = false; } else { initSparklineSettings(); self.buttonDisable = true; } } function initSparklineSettings() { self.type = 0; self.firstMarkerColor = '(none)'; self.highMarkerColor = 'Blue'; self.lastMarkerColor = '(none)'; self.lowMarkerColor = 'Blue'; self.negativeMarkerColor = 'Brown'; self.markersColor = '(none)'; self.axisColor = 'Black'; self.seriesColor = '(none)'; self.showFirst = false; self.showHigh = false; self.showLow = false; self.showLast = false; self.showNegative = false; self.showMarkers = false; self.displayXAxis = true; } function getSparklineSettings(sparkline: any) { let setting = sparkline.setting(); self.type = sparkline.sparklineType(); self.firstMarkerColor = setting.options.firstMarkerColor; self.highMarkerColor = setting.options.highMarkerColor; self.lastMarkerColor = setting.options.lastMarkerColor; self.lowMarkerColor = setting.options.lowMarkerColor; self.negativeMarkerColor = setting.options.negativeColor; self.markersColor = setting.options.markersColor; self.axisColor = setting.options.axisColor; self.seriesColor = setting.options.seriesColor; self.showFirst = setting.options.showFirst; self.showHigh = setting.options.showHigh; self.showLow = setting.options.showLow; self.showLast = setting.options.showLast; self.showNegative = setting.options.showNegative; self.showMarkers = setting.options.showMarkers; self.displayXAxis = setting.options.displayXAxis; } } } @NgModule({ imports: [BrowserModule, SpreadSheetsModule], declarations: [AppComponent], exports: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule);
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/angular/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- Polyfills --> <script src="$DEMOROOT$/zh/angular/node_modules/core-js/client/shim.min.js"></script> <script src="$DEMOROOT$/zh/angular/node_modules/zone.js/fesm2015/zone.min.js"></script> <!-- SystemJS --> <script src="$DEMOROOT$/zh/angular/node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.import('@angular/compiler'); System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('$DEMOROOT$/zh/lib/angular/license.ts'); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html>
<div class="sample-tutorial"> <gc-spread-sheets [hostStyle]="hostStyle" (workbookInitialized)="initSpread($event)"> <gc-worksheet> </gc-worksheet> </gc-spread-sheets> <div class="options-container"> <div class="option-row"> <label>*Select a sparkline in the spreadsheet then change its properties</label> </div> <div class="option-row"> <div class="option"> <input id='btnChangeSetting' type='button' [disabled] = "buttonDisable" value='Change Settings' (click) = "buttonClick($event)"/> </div> </div> <div class="option-row"> <div class="option"> <input [checked]="showFirst" id='showFirst' type='checkbox' (change) = "showFirstChange($event)"/> <label for="showFirst">showFirst</label> </div> <div class="option"> <input [checked]="showHigh" id='showHigh' type='checkbox' (change) = "showHighChange($event)"/> <label for="showHigh">showHigh</label> </div> <div class="option"> <input id='showLast' type='checkbox' [checked]="showLast" (change) = "showLastChange($event)"/> <label for="showLast">showLast</label> </div> <div class="option"> <input id='showLow' type='checkbox' [checked]="showLow" (change) = "showLowChange($event)"/> <label for="showLow">showLow</label> </div> <div class="option"> <input id='showNegative' type='checkbox' [checked]="showNegative" (change) = "showNegativeChange($event)"/> <label for="showNegative">showNegative</label> </div> <div class="option"> <input id='showMarkers' type='checkbox' [checked]="showMarkers" (change) = "showMarkersChange($event)"/> <label for="showMarkers">showMarkers</label> </div> <div class="option"> <input id="displayXAxis" type="checkbox" [checked]="displayXAxis" (change) = "displayXAxisChange($event)"/> <label for="displayXAxis">displayXAxis</label> </div> </div> <div class="option-row"> <div class="option"> <label for="firstMarkerColor" class="block">First Marker Color</label> <input id='firstMarkerColor' class="control" [value]="firstMarkerColor" (change) = "firstMarkerColorChange($event)"/> </div> <div class="option"> <label for="sparklinetype" class="block">Type:</label> <select id="sparklinetype" class="control" [value] = "type" (change) = "typeChange($event)"> <option value="0">line</option> <option value="1">column</option> <option value="2">winloss</option> </select> </div> <div class="option"> <label for="highMarkerColor" class="block">High Marker Color</label> <input id='highMarkerColor' class="control" [value]="highMarkerColor" (change) = "highMarkerColorChange($event)"/> </div> <div class="option"> <label for="lastMarkerColor" class="block">Last Marker Color</label> <input id='lastMarkerColor' class="control" [value]="lastMarkerColor" (change) = "lastMarkerColorChange($event)"/> </div> <div class="option"> <label for="lowMarkerColor" class="block">Low Marker Color</label> <input id='lowMarkerColor' class="control" [value]="lowMarkerColor" (change) = "lowMarkerColorChange($event)"/> </div> <div class="option"> <label for="negativeMarkerColor" class="block">Negative Marker Color</label> <input id='negativeMarkerColor' class="control" [value]="negativeMarkerColor" (change) = "negativeMarkerColorChange($event)"/> </div> <div class="option"> <label for="markersColor" class="block">Markers Color</label> <input id='markersColor' class="control" [value]="markersColor" (change) = "markersColorChange($event)"/> </div> <div class="option"> <label for="AxisColor" class="block">Axis Color</label> <input id='AxisColor' class="control" [value]="axisColor" (change) = "axisColorChange($event)"/> </div> <div class="option"> <label for="SeriesColor" class="block">SeriesColor</label> <input id='SeriesColor' class="control" [value]="seriesColor" (change) = "seriesColorChange($event)"/> </div> </div> </div> </div>
.sample { position: relative; height: 100%; overflow: auto; } .sample::after { display: block; content: ""; clear: both; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 280px); height: 100%; overflow: hidden; float: left; } .options-container { float: right; width: 280px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row { font-size: 14px; padding: 5px; margin-top: 10px; } .option { padding-bottom: 6px; } .block { display: block; padding: 6px 0; } .control { padding: 4px 8px; box-sizing: border-box; width: 100%; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }
(function(global) { System.config({ transpiler: 'ts', typescriptOptions: { tsconfig: true }, meta: { 'typescript': { "exports": "ts" }, '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { 'core-js': 'npm:core-js/client/shim.min.js', 'zone': 'npm:zone.js/fesm2015/zone.min.js', 'rxjs': 'npm:rxjs/dist/bundles/rxjs.umd.min.js', '@angular/core': 'npm:@angular/core/fesm2022', '@angular/common': 'npm:@angular/common/fesm2022/common.mjs', '@angular/compiler': 'npm:@angular/compiler/fesm2022/compiler.mjs', '@angular/platform-browser': 'npm:@angular/platform-browser/fesm2022/platform-browser.mjs', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/fesm2022/platform-browser-dynamic.mjs', '@angular/common/http': 'npm:@angular/common/fesm2022/http.mjs', '@angular/router': 'npm:@angular/router/fesm2022/router.mjs', '@angular/forms': 'npm:@angular/forms/fesm2022/forms.mjs', 'jszip': 'npm:jszip/dist/jszip.min.js', 'typescript': 'npm:typescript/lib/typescript.js', 'ts': './plugin.js', 'tslib':'npm:tslib/tslib.js', 'css': 'npm:systemjs-plugin-css/css.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js', '@grapecity-software/spread-sheets': 'npm:@grapecity-software/spread-sheets/index.js', '@grapecity-software/spread-sheets-resources-zh': 'npm:@grapecity-software/spread-sheets-resources-zh/index.js', '@grapecity-software/spread-sheets-angular': 'npm:@grapecity-software/spread-sheets-angular/fesm2020/grapecity-software-spread-sheets-angular.mjs', '@grapecity-software/jsob-test-dependency-package/react-components': 'npm:@grapecity-software/jsob-test-dependency-package/react-components/index.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'ts' }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, "node_modules/@angular": { defaultExtension: 'mjs' }, "@grapecity-software/spread-sheets-angular": { defaultExtension: 'mjs' }, '@angular/core': { defaultExtension: 'mjs', main: 'core.mjs' } } }); })(this);