Skip to content

Commit 6aa6a05

Browse files
committed
Code cleanup and minor bug fix.
1 parent 123a2bd commit 6aa6a05

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

example/ChartViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Charts from 'fusioncharts/fusioncharts.charts';
44
import OceanTheme from 'fusioncharts/themes/fusioncharts.theme.ocean';
55
import ReactFC from '../lib/ReactFC';
66

7-
Charts(FusionCharts);
7+
// Charts(FusionCharts);
88
OceanTheme(FusionCharts);
99

1010
const myDataSource = {

example/DrillDown.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ class DrillDown extends React.Component {
1414
this.state = {
1515
selectedChild: 0,
1616
showDrillDown: false,
17-
dataSource: this.props.dataSource, // Parent Chat's Data Source
18-
mappedIds: this.props.mappedIds, // An array of indices which maps each
19-
// data plot of parent with its nested Chart Component.
20-
chartConfig: { // Parent Chart Config.
21-
type: 'column2d',
22-
width: 600,
23-
height: 400,
24-
dataFormat: 'json',
25-
dataSource: this.props.dataSource,
26-
},
17+
// Parent Chat's Data Source
18+
dataSource: this.props.dataSource,
19+
// An array of indices which maps each
20+
// data plot of parent with its nested Chart Component.
21+
mappedIds: this.props.mappedIds,
2722
borderColor: (this.props.overlayBtn && this.props.overlayBtn.borderColor) ? this.props.overlayBtn.borderColor : '#000',
2823
backgroundColor: (this.props.overlayBtn && this.props.overlayBtn.backgroundColor) ? this.props.overlayBtn.backgroundColor : '#F6F6F6',
2924
color: (this.props.overlayBtn && this.props.overlayBtn.color) ? this.props.overlayBtn.color : '#000',
@@ -37,14 +32,18 @@ class DrillDown extends React.Component {
3732
plotClicked(e) {
3833
//Index of the data plot that is clicked.
3934
let index = e.data.index;
35+
if(index <= this.state.mappedIds.length) {
36+
console.log('OUT OF BOUND');
37+
return;
38+
}
4039
//Index of Drilled Down Chart.
4140
let plotPosition = this.state.mappedIds[index];
4241

4342
if (!this.state.showDrillDown && plotPosition >= 0) {
4443
this.setState({
4544
showDrillDown: true,
4645
selectedChild: plotPosition
47-
})
46+
});
4847
}
4948
}
5049

@@ -64,17 +63,23 @@ class DrillDown extends React.Component {
6463
cursor: 'pointer',
6564
};
6665

66+
console.log(btnStyle);
67+
6768
return (
6869
<div style={{
6970
position: 'relative',
7071
}}>
71-
{this.state.showDrillDown ?
72-
<div style={{position: 'relative'}}>
73-
<span style={btnStyle}
72+
{ this.state.showDrillDown ?
73+
<div style={{ position: 'relative' }}>
74+
<span style={ btnStyle }
7475
onClick={() => this.setState({ showDrillDown: false })}>
75-
{this.props.overlayBtn && this.props.overlayBtn.message ? this.props.overlayBtn.message : 'Revert'}
76+
{
77+
this.props.overlayBtn && this.props.overlayBtn.message ?
78+
this.props.overlayBtn.message : 'Revert'
79+
}
7680
</span>
77-
{this.props.children[this.state.selectedChild]} {/* Displaying Correct Drilled Down Chart. */}
81+
{/* Displaying Correct Drilled Down Chart. */}
82+
{ this.props.children[this.state.selectedChild] }
7883
</div> :
7984
<ReactFC
8085
type={this.props.type}

example/Example.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class Example extends React.Component {
123123
super(props)
124124

125125
this.state = {
126-
mappedIds: [0, 1, 2],
126+
mappedIds: [1],
127127
dataSource: {
128128
chart: {
129129
caption: 'PARENT',
@@ -164,10 +164,11 @@ class Example extends React.Component {
164164
height='400'
165165
dataFormat="JSON"
166166
overlayBtn={{ //This object holds the style of the overlay back button.
167-
message: 'Back',
167+
message: 'BACK',
168168
fontColor: '#880000',
169169
bgColor: '#FFEEEE',
170170
borderColor: '#660000',
171+
fontSize: '12px'
171172
}}
172173
dataSource={this.state.dataSource}
173174
mappedIds={this.state.mappedIds}>
@@ -216,6 +217,7 @@ class Example extends React.Component {
216217
height='400'
217218
dataFormat="JSON"
218219
dataSource={thirdDataSource} />
220+
<a href="https://www.google.com">Google</a>
219221
</DrillDown>
220222
</div>
221223
)

example/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import ChartViewer from './ChartViewer';
4-
import DrillDown from './DrillDown';
53
import Example from './Example';
64

75
ReactDOM.render(<Example />, document.getElementById('root'));

0 commit comments

Comments
 (0)