Skip to content

Commit b024c02

Browse files
author
Mike Schultz
committed
Allows any property added directly to props to be used in the ZingChart render method
1 parent 805034d commit b024c02

File tree

9 files changed

+409
-43
lines changed

9 files changed

+409
-43
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ The theme or 'defaults' object defined by ZingChart. More information available
169169

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

172+
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.
173+
172174
## Events
173175
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:
174176

dist/index.es.js

Lines changed: 187 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.es.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zingchart-react.js

Lines changed: 13 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zingchart-react.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zingchart-react",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"description": "ZingChart React Component wrapper to allow native react syntax for javascript charts, chart events, chart methods and chart styling.",
55
"author": "ZingSoft Inc.",
66
"license": "MIT",

src/index.jsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ZingChart extends Component {
1515
constructor(props) {
1616
super(props);
1717
this.id = this.props.id || 'zingchart-react-' + window.ZCReact.count++;
18-
18+
console.log(props);
1919
// Bind all methods available to zingchart to be accessed via Refs.
2020
METHOD_NAMES.forEach(name => {
2121
this[name] = args => {
@@ -84,13 +84,16 @@ class ZingChart extends Component {
8484
}
8585

8686
renderChart() {
87-
const renderObject = {
88-
id: this.id,
89-
width: this.props.width || DEFAULT_WIDTH,
90-
height: this.props.height || DEFAULT_HEIGHT,
91-
data: this.props.data,
92-
output: this.props.output || DEFAULT_OUTPUT,
93-
};
87+
const renderObject = {};
88+
Object.keys(this.props).forEach(prop => {
89+
renderObject[prop] = this.props[prop];
90+
})
91+
// Overwrite some existing props.
92+
renderObject.id = this.id;
93+
renderObject.width = this.props.width || DEFAULT_WIDTH;
94+
renderObject.height = this.props.height || DEFAULT_HEIGHT;
95+
renderObject.data = this.props.data;
96+
renderObject.output = this.props.output || DEFAULT_OUTPUT;
9497

9598
if (this.props.series) {
9699
renderObject.data.series = this.props.series;
@@ -99,7 +102,6 @@ class ZingChart extends Component {
99102
renderObject.defaults = this.props.theme;
100103
}
101104
zingchart.render(renderObject);
102-
103105
}
104106

105107
componentWillUnmount() {

0 commit comments

Comments
 (0)