import $ from 'jquery'; import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; import { Panel } from 'react-bootstrap'; import visMap from '../../../visualizations/main'; import { d3format } from '../../modules/utils'; const propTypes = { sliceName: PropTypes.string.isRequired, vizType: PropTypes.string.isRequired, height: PropTypes.string.isRequired, containerId: PropTypes.string.isRequired, jsonEndpoint: PropTypes.string.isRequired, columnFormats: PropTypes.object, }; class ChartContainer extends React.Component { constructor(props) { super(props); this.state = { selector: `#${this.props.containerId}`, }; } componentDidMount() { this.renderVis(); } componentDidUpdate() { this.renderVis(); } getMockedSliceObject() { return { jsonEndpoint: () => this.props.jsonEndpoint, container: { html: (data) => { // this should be a callback to clear the contents of the slice container $(this.state.selector).html(data); }, css: () => { // dimension can be 'height' // pixel string can be '300px' // should call callback to adjust height of chart }, height: () => parseInt(this.props.height, 10) - 100, find: (classname) => ($(this.state.selector).find(classname)), }, width: () => this.chartContainerRef.getBoundingClientRect().width, height: () => parseInt(this.props.height, 10) - 100, selector: this.state.selector, done: () => { // finished rendering callback }, error(msg, xhr) { let errorMsg = msg; let errHtml = ''; try { const o = JSON.parse(msg); if (o.error) { errorMsg = o.error; } } catch (e) { // pass } errHtml = `