Skip to content

Commit

Permalink
Close #26
Browse files Browse the repository at this point in the history
  • Loading branch information
klawr committed Jan 10, 2019
1 parent 5a85561 commit ec208ae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/api/g2.core.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ Draw text string at anchor point.
<a name="g2+use"></a>

### g2.use() ⇒ <code>object</code>
Reference g2 graphics commands from another g2 object.With this command you can reuse instances of grouped graphics commandswhile applying a similarity transformation and style properties on them.In fact you might want to build custom graphics libraries on top of that feature.
Reference g2 graphics commands from another g2 object or a predefined g2.symbol.With this command you can reuse instances of grouped graphics commandswhile applying a similarity transformation and style properties on them.In fact you might want to build custom graphics libraries on top of that feature.

**Kind**: instance method of [<code>g2</code>](#g2)
**Returns**: <code>object</code> - g2
**See**: [predefined symbols in g2.ext](https://github.com/goessner/g2/blob/master/docs/api/g2.ext.md#g2symbol--object)

| Type | Description |
| --- | --- |
Expand Down
6 changes: 3 additions & 3 deletions docs/api/g2.ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ Extensed style values. Not really meant to get overwritten. But if you actually
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| symbol | <code>object</code> | | `g2` symbol namespace. |
| [symbol.tick] | <code>object</code> | | Predefined symbol: a little tick |
| [symbol.dot] | <code>object</code> | | Predefined symbol: a little dot |
| [symbol.sqr] | <code>object</code> | | Predefined symbol: a little square |
| [symbol.nodcolor] | <code>string</code> | <code>&quot;#333&quot;</code> | node color. |
| [symbol.nodfill] | <code>string</code> | <code>&quot;#dedede&quot;</code> | node fill color. |
| [symbol.nodfill2] | <code>string</code> | <code>&quot;#aeaeae&quot;</code> | alternate node fill color, somewhat darker. |
Expand All @@ -115,7 +118,4 @@ Extensed style values. Not really meant to get overwritten. But if you actually
| [symbol.dashdot] | <code>array</code> | <code>[25,6.5,2,6.5]</code> | dashdotted line style. |
| [symbol.labelOffset] | <code>number</code> | <code>5</code> | default label offset distance. |
| [symbol.labelSignificantDigits] | <code>number</code> | <code>3</code> | default label's significant digits after numbering point. |
| [symbol.tick] | <code>method</code> | | creates a little tick |
| [symbol.dot] | <code>method</code> | | creates a little dot |
| [symbol.sqr] | <code>method</code> | | creates a little square |

Expand Down
3 changes: 2 additions & 1 deletion src/g2.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,14 @@ g2.prototype = {
txt({str,x,y,w}) { return this.addCommand({c:'txt',a:arguments[0]}); },

/**
* Reference g2 graphics commands from another g2 object.
* Reference g2 graphics commands from another g2 object or a predefined g2.symbol.
* With this command you can reuse instances of grouped graphics commands
* while applying a similarity transformation and style properties on them.
* In fact you might want to build custom graphics libraries on top of that feature.
* @method
* @returns {object} g2
* @param {object} - use arguments object.
* @see {@link https://github.com/goessner/g2/blob/master/docs/api/g2.ext.md#g2symbol--object predefined symbols in g2.ext}
* @property {object | string} grp - g2 source object or symbol name found in 'g2.symbol' namespace.
* @property {number} [x=0] - translation value x.
* @property {number} [y=0] - translation value y.
Expand Down
13 changes: 7 additions & 6 deletions src/g2.ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ g2.prototype.mark.prototype = {
* Theses styles can be referenced using the comfortable '@' syntax.
* @namespace
* @property {object} symbol `g2` symbol namespace.
* @property {object} [symbol.tick] Predefined symbol: a little tick
* @property {object} [symbol.dot] Predefined symbol: a little dot
* @property {object} [symbol.sqr] Predefined symbol: a little square
* @property {string} [symbol.nodcolor=#333] node color.
* @property {string} [symbol.nodfill=#dedede] node fill color.
* @property {string} [symbol.nodfill2=#aeaeae] alternate node fill color, somewhat darker.
Expand All @@ -442,11 +445,12 @@ g2.prototype.mark.prototype = {
* @property {array} [symbol.dashdot=[25,6.5,2,6.5]] dashdotted line style.
* @property {number} [symbol.labelOffset=5] default label offset distance.
* @property {number} [symbol.labelSignificantDigits=3] default label's significant digits after numbering point.
* @property {method} [symbol.tick] creates a little tick
* @property {method} [symbol.dot] creates a little dot
* @property {method} [symbol.sqr] creates a little square
*/
g2.symbol = g2.symbol || {};
g2.symbol.tick = g2().p().m({x:0,y:-2}).l({x:0,y:2}).stroke({lc:"round",lwnosc:true});
g2.symbol.dot = g2().cir({x:0,y:0,r:2,ls:"transparent"});
g2.symbol.sqr = g2().rec({x:-1.5,y:-1.5,b:3,h:3,ls:"transparent"});

g2.symbol.nodcolor = "#333";
g2.symbol.nodfill = "#dedede";
g2.symbol.nodfill2 = "#aeaeae";
Expand All @@ -459,7 +463,4 @@ g2.symbol.dot = [4,4];
g2.symbol.dashdot = [25,6.5,2,6.5];
g2.symbol.labelSignificantDigits = 3; // 0.1234 => 0.123, 0.01234 => 0.0123, 1.234 => 1.23, 12.34 => 12.3, 123.4 => 123, 1234 => 1234

g2.symbol.tick = g2().p().m({x:0,y:-2}).l({x:0,y:2}).stroke({lc:"round",lwnosc:true});
g2.symbol.dot = g2().cir({x:0,y:0,r:2,ls:"transparent"});
g2.symbol.sqr = g2().rec({x:-1.5,y:-1.5,b:3,h:3,ls:"transparent"});
// Helper methods .. not chainable.
Loading

0 comments on commit ec208ae

Please sign in to comment.