Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose symbol registry and factory #230

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

cbt1
Copy link
Collaborator

@cbt1 cbt1 commented Oct 10, 2018

This enables component developers to use existing symbols and register their own symbols.

Register a new symbol

// In this example we'll do a dot symbol. We'll represent it as a circle with a static radius.
// x and y is the centroid of a square, where the length of the sides are represented by the size parameter. 
const symbolFunction = ({ x, y, size, ...additionalOptions }) => {
 return {
  type: 'circle',
  cx: x,
  cy: y,
  r: 2
 };
};

picasso.symbol.add('<name-of-symbol>', symbolFunction);

Using the symbol factory in a custom component

const myComponent = {
 require: ['symbol'], // Require the symbol factory, after which it is exposed on the this context.
 render() {
  const mySymbol = this.symbol({ type: '<name-of-symbol>', x: 10, y: 15, size: 20 });
  return [mySymbol];
 }
};

Implements: #197

As stated in #197, there is more work needed to fully implement support for this, for example adding documentation.

@cbt1 cbt1 merged commit bc9b248 into qlik-oss:master Oct 10, 2018
@cbt1 cbt1 deleted the feat/expose-symbol-factory branch October 10, 2018 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants