Skip to content

Commit

Permalink
Allows any property added directly to props to be used in the ZingCha…
Browse files Browse the repository at this point in the history
…rt render method
  • Loading branch information
Mike Schultz committed Oct 15, 2020
1 parent 805034d commit b024c02
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 43 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ The theme or 'defaults' object defined by ZingChart. More information available

The render type of the chart. **The default is `svg`** but you can also pass the string `canvas` to render the charts in canvas.

Note: All other properties that are added as a prop will be added to the render object. This allows for settings such as 'customprogresslogo' to be set. Any unrecognized properties will be ignored.

## Events
All zingchart events are readily available on the component to listen to. For example, to listen for the 'complete' event when the chart is finished rendering:

Expand Down
187 changes: 187 additions & 0 deletions dist/index.es.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.es.js.map

Large diffs are not rendered by default.

192 changes: 192 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

45 changes: 13 additions & 32 deletions dist/zingchart-react.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/zingchart-react.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zingchart-react",
"version": "3.0.0",
"version": "3.1.0",
"description": "ZingChart React Component wrapper to allow native react syntax for javascript charts, chart events, chart methods and chart styling.",
"author": "ZingSoft Inc.",
"license": "MIT",
Expand Down
20 changes: 11 additions & 9 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ZingChart extends Component {
constructor(props) {
super(props);
this.id = this.props.id || 'zingchart-react-' + window.ZCReact.count++;

console.log(props);
// Bind all methods available to zingchart to be accessed via Refs.
METHOD_NAMES.forEach(name => {
this[name] = args => {
Expand Down Expand Up @@ -84,13 +84,16 @@ class ZingChart extends Component {
}

renderChart() {
const renderObject = {
id: this.id,
width: this.props.width || DEFAULT_WIDTH,
height: this.props.height || DEFAULT_HEIGHT,
data: this.props.data,
output: this.props.output || DEFAULT_OUTPUT,
};
const renderObject = {};
Object.keys(this.props).forEach(prop => {
renderObject[prop] = this.props[prop];
})
// Overwrite some existing props.
renderObject.id = this.id;
renderObject.width = this.props.width || DEFAULT_WIDTH;
renderObject.height = this.props.height || DEFAULT_HEIGHT;
renderObject.data = this.props.data;
renderObject.output = this.props.output || DEFAULT_OUTPUT;

if (this.props.series) {
renderObject.data.series = this.props.series;
Expand All @@ -99,7 +102,6 @@ class ZingChart extends Component {
renderObject.defaults = this.props.theme;
}
zingchart.render(renderObject);

}

componentWillUnmount() {
Expand Down

0 comments on commit b024c02

Please sign in to comment.