Commit 481787a7 authored by nikogu's avatar nikogu

fixed charts color style

parent 6404250d
...@@ -55,7 +55,14 @@ class Bar extends Component { ...@@ -55,7 +55,14 @@ class Bar extends Component {
}; };
render() { render() {
const { height, title, forceFit = true, data, color = 'rgba(24, 144, 255, 0.85)', padding } = this.props; const {
height,
title,
forceFit = true,
data,
color = 'rgba(24, 144, 255, 0.85)',
padding,
} = this.props;
const { autoHideXLabels } = this.state; const { autoHideXLabels } = this.state;
...@@ -79,16 +86,21 @@ class Bar extends Component { ...@@ -79,16 +86,21 @@ class Bar extends Component {
return ( return (
<div className={styles.chart} style={{ height }} ref={this.handleRoot}> <div className={styles.chart} style={{ height }} ref={this.handleRoot}>
<div ref={this.handleRef}> <div ref={this.handleRef}>
{title && <h4>{title}</h4>} {title && <h4 style={{ marginBottom: 20 }}>{title}</h4>}
<Chart <Chart
scale={scale} scale={scale}
height={height} height={title ? height - 41 : height}
forceFit={forceFit} forceFit={forceFit}
data={data} data={data}
padding={padding || 'auto'} padding={padding || 'auto'}
> >
<Axis name="x" title={false} label={!autoHideXLabels} tickLine={!autoHideXLabels} /> <Axis
<Axis name="y" title={false} line={false} tickLine={false} min={0} /> name="x"
title={false}
label={autoHideXLabels ? false : {}}
tickLine={autoHideXLabels ? false : {}}
/>
<Axis name="y" min={0} />
<Tooltip showTitle={false} crosshairs={false} /> <Tooltip showTitle={false} crosshairs={false} />
<Geom type="interval" position="x*y" color={color} tooltip={tooltip} /> <Geom type="interval" position="x*y" color={color} tooltip={tooltip} />
</Chart> </Chart>
......
...@@ -11,6 +11,7 @@ export default class MiniArea extends React.Component { ...@@ -11,6 +11,7 @@ export default class MiniArea extends React.Component {
data = [], data = [],
forceFit = true, forceFit = true,
color = 'rgba(24, 144, 255, 0.2)', color = 'rgba(24, 144, 255, 0.2)',
borderColor = '#1089ff',
scale = {}, scale = {},
borderWidth = 2, borderWidth = 2,
line, line,
...@@ -19,8 +20,6 @@ export default class MiniArea extends React.Component { ...@@ -19,8 +20,6 @@ export default class MiniArea extends React.Component {
animate = true, animate = true,
} = this.props; } = this.props;
const borderColor = this.props.borderColor || color;
const padding = [36, 5, 30, 5]; const padding = [36, 5, 30, 5];
const scaleProps = { const scaleProps = {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
width: 100%; width: 100%;
.chartContent { .chartContent {
position: absolute; position: absolute;
bottom: -34px; bottom: -28px;
width: 100%; width: 100%;
> div { > div {
margin: 0 -5px; margin: 0 -5px;
......
// 全局 G2 设置 // 全局 G2 设置
import { track } from 'bizcharts'; import { track, setTheme } from 'bizcharts';
track(false); track(false);
const config = {
defaultColor: '#1089ff',
shape: {
interval: {
fillOpacity: 1,
},
},
};
setTheme(config);
...@@ -330,7 +330,7 @@ export default class Analysis extends Component { ...@@ -330,7 +330,7 @@ export default class Analysis extends Component {
<Row> <Row>
<Col xl={16} lg={12} md={12} sm={24} xs={24}> <Col xl={16} lg={12} md={12} sm={24} xs={24}>
<div className={styles.salesBar}> <div className={styles.salesBar}>
<Bar height={270} title="销售额趋势" data={salesData} /> <Bar height={295} title="销售额趋势" data={salesData} />
</div> </div>
</Col> </Col>
<Col xl={8} lg={12} md={12} sm={24} xs={24}> <Col xl={8} lg={12} md={12} sm={24} xs={24}>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment