Skip to content

Commit 5133765

Browse files
committed
Remove unnecessary divs. Pass chart styles to dashboard. #237
1 parent 19b294d commit 5133765

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-google-charts",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"type": "react-component",
55
"description": "react-google-charts React component",
66
"main": "dist/index.cjs.js",

Diff for: src/ReactGoogleCharts.tsx

+23-28
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,30 @@ export class Chart extends React.Component<
2828
loader
2929
} = this.props;
3030
return (
31-
<div>
32-
<ContextProvider
33-
value={this.props as ReactGoogleChartPropsWithDefaults}
34-
>
35-
{this.state.loadingStatus === "ready" &&
36-
this.state.google !== null ? (
37-
<GoogleChart
38-
{...this.props as ReactGoogleChartPropsWithDefaults}
39-
google={this.state.google}
40-
/>
41-
) : (
42-
loader
43-
)}
44-
<GoogleChartLoader
45-
{...{ chartLanguage, chartPackages, chartVersion, mapsApiKey }}
46-
onLoad={google => {
47-
this.setState({
48-
loadingStatus: "ready",
49-
google
50-
});
51-
}}
52-
onError={() => {
53-
this.setState({
54-
loadingStatus: "errored"
55-
});
56-
}}
31+
<ContextProvider value={this.props as ReactGoogleChartPropsWithDefaults}>
32+
{this.state.loadingStatus === "ready" && this.state.google !== null ? (
33+
<GoogleChart
34+
{...this.props as ReactGoogleChartPropsWithDefaults}
35+
google={this.state.google}
5736
/>
58-
</ContextProvider>
59-
</div>
37+
) : (
38+
loader
39+
)}
40+
<GoogleChartLoader
41+
{...{ chartLanguage, chartPackages, chartVersion, mapsApiKey }}
42+
onLoad={google => {
43+
this.setState({
44+
loadingStatus: "ready",
45+
google
46+
});
47+
}}
48+
onError={() => {
49+
this.setState({
50+
loadingStatus: "errored"
51+
});
52+
}}
53+
/>
54+
</ContextProvider>
6055
);
6156
}
6257
}

Diff for: src/components/GoogleChart.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,16 @@ export class GoogleChart extends React.Component<Props, State> {
266266
return <div ref={this.toolbar_ref} />;
267267
};
268268
render() {
269+
const { width, height, options, style } = this.props;
270+
271+
const divStyle = {
272+
height: height || (options && options.height),
273+
width: width || (options && options.width),
274+
...style
275+
};
269276
if (this.props.render !== null) {
270277
return (
271-
<div ref={this.dashboard_ref}>
278+
<div ref={this.dashboard_ref} style={divStyle}>
272279
<div ref={this.toolbar_ref} id="toolbar" />
273280
{this.props.render({
274281
renderChart: this.renderChart,
@@ -279,7 +286,7 @@ export class GoogleChart extends React.Component<Props, State> {
279286
);
280287
} else {
281288
return (
282-
<div ref={this.dashboard_ref}>
289+
<div ref={this.dashboard_ref} style={divStyle}>
283290
{this.renderControl(({ controlProp }) => {
284291
return controlProp.controlPosition !== "bottom";
285292
})}

0 commit comments

Comments
 (0)