도형 선

SpreadJS에서는 도형의 모양을 사용자 정의하는 데 사용할 수 있는 여러 가지 겹선 종류를 지원합니다. 지원되는 선 종류는 단순형, 이중, 굵고 얇음, 얇고 굵음, 삼중입니다.

도형 선 종류를 변경할 수 있으며, 겹선 종류를 사용할 수 있습니다.
import * as React from 'react'; import * as ReactDOM from 'react-dom'; import './styles.css'; import { AppFunc } from './app-func'; // import { App } from './app-class'; // 1. Functional Component sample ReactDOM.render(<AppFunc />, document.getElementById('app')); // 2. Class Component sample // ReactDOM.render(<App />, document.getElementById('app'));
import * as React from 'react'; import GC from '@mescius/spread-sheets'; import "@mescius/spread-sheets-shapes"; import { SpreadSheets } from "@mescius/spread-sheets-react"; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); let spread = null; export function AppFunc() { const [compoundType, setCompoundType] = React.useState(GC.Spread.Sheets.Shapes.CompoundType.simple); const initSpread = (currSpread) => { spread = currSpread; let sheet = spread.getActiveSheet(); var rectangle = sheet.shapes.add('rectangle', GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 50, 200, 100); var shapeStyle1 = rectangle.style(); shapeStyle1.fill.color = '#FFE4B3'; shapeStyle1.line.color = "black"; shapeStyle1.line.width = 10; shapeStyle1.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.simple; rectangle.style(shapeStyle1); var rightArrow = sheet.shapes.add('rightArrow', GC.Spread.Sheets.Shapes.AutoShapeType.rightArrow, 400, 50, 200, 100); var shapeStyle2 = rightArrow.style(); shapeStyle2.fill.color = '#FFE4B3'; shapeStyle2.line.color = "black"; shapeStyle2.line.width = 10; shapeStyle2.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.double; rightArrow.style(shapeStyle2); var hexagon = sheet.shapes.add('hexagon', GC.Spread.Sheets.Shapes.AutoShapeType.hexagon, 100, 200, 200, 100); var shapeStyle3 = hexagon.style(); shapeStyle3.fill.color = '#FFE4B3'; shapeStyle3.line.color = "black"; shapeStyle3.line.width = 10; shapeStyle3.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.thickThin; hexagon.style(shapeStyle3); var mathMultiply = sheet.shapes.add('mathMultiply', GC.Spread.Sheets.Shapes.AutoShapeType.mathMultiply, 400, 200, 200, 100); var shapeStyle4 = mathMultiply.style(); shapeStyle4.fill.color = '#FFE4B3'; shapeStyle4.line.color = "black"; shapeStyle4.line.width = 10; shapeStyle4.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.thinThick; mathMultiply.style(shapeStyle4); var cross = sheet.shapes.add('cross', GC.Spread.Sheets.Shapes.AutoShapeType.cross, 100, 350, 200, 100); var shapeStyle5 = cross.style(); shapeStyle5.fill.color = '#FFE4B3'; shapeStyle5.line.color = "black"; shapeStyle5.line.width = 10; shapeStyle5.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.triple; cross.style(shapeStyle5); sheet.bind(GC.Spread.Sheets.Events.ShapeSelectionChanged, () => { sheet.shapes.all().forEach((sp) => { if (sp.isSelected() && sp instanceof GC.Spread.Sheets.Shapes.Shape) { setCompoundType(sp.style().line.compoundType); } }); }); } const updateCompoundType = (e) => { switch (e.target.value) { case '0': resetCompoundType(spread, GC.Spread.Sheets.Shapes.CompoundType.simple); setCompoundType(GC.Spread.Sheets.Shapes.CompoundType.simple); return; case '1': resetCompoundType(spread, GC.Spread.Sheets.Shapes.CompoundType.double); setCompoundType(GC.Spread.Sheets.Shapes.CompoundType.double); return; case '2': resetCompoundType(spread, GC.Spread.Sheets.Shapes.CompoundType.thickThin); setCompoundType(GC.Spread.Sheets.Shapes.CompoundType.thickThin); return; case '3': resetCompoundType(spread, GC.Spread.Sheets.Shapes.CompoundType.thinThick); setCompoundType(GC.Spread.Sheets.Shapes.CompoundType.thinThick); return; case '4': resetCompoundType(spread, GC.Spread.Sheets.Shapes.CompoundType.triple); setCompoundType(GC.Spread.Sheets.Shapes.CompoundType.triple); return; default: return; } } const resetCompoundType = (spread, value) => { let activeSheet = spread.getActiveSheet(); let shapes = activeSheet.shapes.all(); for (let i = 0; i < shapes.length; i++) { let shape = shapes[i]; if (shape.isSelected()) { var shapeStyle = shape.style(); shapeStyle.line.compoundType = value; shape.style(shapeStyle); } } } return ( <div class="sample-tutorial"> <div class="sample-spreadsheets"> <SpreadSheets workbookInitialized={spread => initSpread(spread)}> </SpreadSheets> </div> <div class="options-container"> <div class="option-row"> Select a shape then change the line format to see the effect: </div> <hr /> <div class="option-row"> <label>Change Shapes line, use different compound type</label> <select id="changeCompoundType" value={compoundType} onChange={($event) => { updateCompoundType($event); }}> <option value="0" selected>Simple</option> <option value="1">Double</option> <option value="2">Thick Thin</option> <option value="3">Thin Thick</option> <option value="4">Triple</option> </select> <br /> </div> </div> </div>); }
import * as React from 'react'; import GC from '@mescius/spread-sheets'; import "@mescius/spread-sheets-shapes"; import { SpreadSheets } from "@mescius/spread-sheets-react"; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); const Component = React.Component; export class App extends Component { constructor(props) { super(props); this.spread = null; this.state = { compoundType: GC.Spread.Sheets.Shapes.CompoundType.simple, } } render() { return ( <div class="sample-tutorial"> <div class="sample-spreadsheets"> <SpreadSheets workbookInitialized={spread => this.initSpread(spread)}> </SpreadSheets> </div> <div class="options-container"> <div class="option-row"> Select a shape then change the line format to see the effect: </div> <hr /> <div class="option-row"> <label>Change Shapes line, use different compound type</label> <select id="changeCompoundType" value={this.state.compoundType} onChange={($event) => { this.updateCompoundType($event); }}> <option value="0" selected>Simple</option> <option value="1">Double</option> <option value="2">Thick Thin</option> <option value="3">Thin Thick</option> <option value="4">Triple</option> </select> <br /> </div> </div> </div>); } initSpread(spread) { let self = this; self.spread = spread; let sheet = spread.getActiveSheet(); var rectangle = sheet.shapes.add('rectangle', GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 50, 200, 100); var shapeStyle1 = rectangle.style(); shapeStyle1.fill.color = '#FFE4B3'; shapeStyle1.line.color = "black"; shapeStyle1.line.width = 10; shapeStyle1.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.simple; rectangle.style(shapeStyle1); var rightArrow = sheet.shapes.add('rightArrow', GC.Spread.Sheets.Shapes.AutoShapeType.rightArrow, 400, 50, 200, 100); var shapeStyle2 = rightArrow.style(); shapeStyle2.fill.color = '#FFE4B3'; shapeStyle2.line.color = "black"; shapeStyle2.line.width = 10; shapeStyle2.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.double; rightArrow.style(shapeStyle2); var hexagon = sheet.shapes.add('hexagon', GC.Spread.Sheets.Shapes.AutoShapeType.hexagon, 100, 200, 200, 100); var shapeStyle3 = hexagon.style(); shapeStyle3.fill.color = '#FFE4B3'; shapeStyle3.line.color = "black"; shapeStyle3.line.width = 10; shapeStyle3.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.thickThin; hexagon.style(shapeStyle3); var mathMultiply = sheet.shapes.add('mathMultiply', GC.Spread.Sheets.Shapes.AutoShapeType.mathMultiply, 400, 200, 200, 100); var shapeStyle4 = mathMultiply.style(); shapeStyle4.fill.color = '#FFE4B3'; shapeStyle4.line.color = "black"; shapeStyle4.line.width = 10; shapeStyle4.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.thinThick; mathMultiply.style(shapeStyle4); var cross = sheet.shapes.add('cross', GC.Spread.Sheets.Shapes.AutoShapeType.cross, 100, 350, 200, 100); var shapeStyle5 = cross.style(); shapeStyle5.fill.color = '#FFE4B3'; shapeStyle5.line.color = "black"; shapeStyle5.line.width = 10; shapeStyle5.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.triple; cross.style(shapeStyle5); sheet.bind(GC.Spread.Sheets.Events.ShapeSelectionChanged, () => { sheet.shapes.all().forEach((sp) => { if (sp.isSelected() && sp instanceof GC.Spread.Sheets.Shapes.Shape) { self.setState({ compoundType: sp.style().line.compoundType }); } }); }); } updateCompoundType(e) { switch (e.target.value) { case '0': this.setCompoundType(this.spread, GC.Spread.Sheets.Shapes.CompoundType.simple); this.setState({ compoundType: GC.Spread.Sheets.Shapes.CompoundType.simple }); return; case '1': this.setCompoundType(this.spread, GC.Spread.Sheets.Shapes.CompoundType.double); this.setState({ compoundType: GC.Spread.Sheets.Shapes.CompoundType.double }); return; case '2': this.setCompoundType(this.spread, GC.Spread.Sheets.Shapes.CompoundType.thickThin); this.setState({ compoundType: GC.Spread.Sheets.Shapes.CompoundType.thickThin }); return; case '3': this.setCompoundType(this.spread, GC.Spread.Sheets.Shapes.CompoundType.thinThick); this.setState({ compoundType: GC.Spread.Sheets.Shapes.CompoundType.thinThick }); return; case '4': this.setCompoundType(this.spread, GC.Spread.Sheets.Shapes.CompoundType.triple); this.setState({ compoundType: GC.Spread.Sheets.Shapes.CompoundType.triple }); return; default: return; } } setCompoundType(spread, value) { let activeSheet = spread.getActiveSheet(); let shapes = activeSheet.shapes.all(); for (let i = 0; i < shapes.length; i++) { let shape = shapes[i]; if (shape.isSelected()) { var shapeStyle = shape.style(); shapeStyle.line.compoundType = value; shape.style(shapeStyle); } } } }
<!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$/ko/react/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- SystemJS --> <script src="$DEMOROOT$/ko/react/node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('$DEMOROOT$/ko/lib/react/license.js').then(function () { System.import('./src/app'); }); </script> </head> <body> <div id="app"></div> </body> </html>
.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: 5px; } .sample-options { z-index: 1000; } label { display: block; margin-bottom: 6px; } p{ padding:2px 10px; background-color:#F4F8EB; } input { padding: 4px 6px; width: 160px; } input[type=button] { margin-top: 6px; display: block; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { height: 100%; }
(function (global) { System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true, react: true }, meta: { '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@mescius/spread-sheets-react': 'npm:@mescius/spread-sheets-react/index.js', '@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js', 'react': 'npm:react/umd/react.production.min.js', 'react-dom': 'npm:react-dom/umd/react-dom.production.min.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' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'jsx' }, "node_modules": { defaultExtension: 'js' }, } }); })(this);