bar.jsx 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. import React from 'react'
  2. import { connect } from 'dva'
  3. import { Input, InputNumber, Form, Checkbox, Select, Tooltip, Divider, Row, Col } from 'antd'
  4. import { deepAssign } from '../../../../utils/baseUtils'
  5. import EChartsMedia from '../../../../models/EChartsMedia'
  6. const FormItem = Form.Item
  7. class BarStyle extends React.Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. formItemLayout: {
  12. labelCol: { span: 8 },
  13. wrapperCol: { span: 16 },
  14. },
  15. }
  16. }
  17. render() {
  18. const { formItemLayout } = this.state;
  19. const { chartDesigner, dispatch } = this.props;
  20. const { styleConfig, chartOption, barConfig } = chartDesigner;
  21. const { groupBy } = barConfig;
  22. const barStyle = styleConfig.bar || {};
  23. return <Form>
  24. <Divider>柱条</Divider>
  25. <FormItem label={<Tooltip title="柱条的最大宽度,支持设置成绝对数值或相对于类目宽度的百分比">柱条最大宽度</Tooltip>} {...formItemLayout}>
  26. <Input
  27. defaultValue={barStyle.barMaxWidth ? barStyle.barMaxWidth : null}
  28. placeholder='60'
  29. onBlur={e => {
  30. let value = e.target.value;
  31. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { barMaxWidth: value } }) }];
  32. if(!!chartOption.baseOption) {
  33. let seriesArr = [];
  34. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  35. seriesArr.push({
  36. barMaxWidth: value || '60'
  37. });
  38. }
  39. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } } ) });
  40. }
  41. dispatch({ type: 'chartDesigner/setFields', fields });
  42. }}
  43. onKeyDown={e => {
  44. if(e.keyCode === 13) {
  45. let value = e.target.value;
  46. let fields = [
  47. { name: 'styleConfig', value: deepAssign(styleConfig, { bar: { barMaxWidth: value } }) }
  48. ]
  49. if(!!chartOption.baseOption) {
  50. let seriesArr = [];
  51. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  52. seriesArr.push({
  53. barMaxWidth: value || '60'
  54. });
  55. }
  56. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } } ) });
  57. }
  58. dispatch({ type: 'chartDesigner/setFields', fields });
  59. }
  60. }}
  61. />
  62. </FormItem>
  63. <FormItem label={<Tooltip title="柱条最小高度,可用于防止某数据项的值过小而影响交互">柱条最小高度</Tooltip>} {...formItemLayout}>
  64. <InputNumber
  65. defaultValue={(barStyle.barMinHeight === '' || barStyle.barMinHeight === null || barStyle.barMinHeight === undefined) ? null : barStyle.barMinHeight}
  66. placeholder={0}
  67. onBlur={e => {
  68. let value = e.target.value;
  69. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { barMinHeight: value } }) }];
  70. if(!!chartOption.baseOption) {
  71. let seriesArr = [];
  72. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  73. seriesArr.push({
  74. barMinHeight: value || 0
  75. });
  76. }
  77. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  78. }
  79. dispatch({ type: 'chartDesigner/setFields', fields });
  80. }}
  81. onKeyDown={e => {
  82. if(e.keyCode === 13) {
  83. let value = e.target.value;
  84. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { barMinHeight: value } }) }];
  85. if(!!chartOption.baseOption) {
  86. let seriesArr = [];
  87. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  88. seriesArr.push({
  89. barMinHeight: value || 0
  90. });
  91. }
  92. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  93. }
  94. dispatch({ type: 'chartDesigner/setFields', fields });
  95. }
  96. }}
  97. />
  98. </FormItem>
  99. <FormItem label={<Tooltip title="柱间距离,为相对柱子宽度的百分比。如果想要分组的柱子重叠而不使用数据堆叠,可以设置为 '-100%'">柱间距离</Tooltip>} {...formItemLayout}>
  100. <Input
  101. defaultValue={barStyle.barGap ? barStyle.barGap : null}
  102. placeholder={'30%'}
  103. onBlur={e => {
  104. let value = e.target.value;
  105. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { barGap: value } }) }];
  106. if(!!chartOption.baseOption) {
  107. let seriesArr = [];
  108. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  109. seriesArr.push({
  110. barGap: value || '30%'
  111. });
  112. }
  113. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  114. }
  115. dispatch({ type: 'chartDesigner/setFields', fields });
  116. }}
  117. onKeyDown={e => {
  118. if(e.keyCode === 13) {
  119. let value = e.target.value;
  120. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { barGap: value } }) }];
  121. if(!!chartOption.baseOption) {
  122. let seriesArr = [];
  123. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  124. seriesArr.push({
  125. barGap: value || '30%'
  126. });
  127. }
  128. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  129. }
  130. dispatch({ type: 'chartDesigner/setFields', fields });
  131. }
  132. }}
  133. />
  134. </FormItem>
  135. <Divider>标注</Divider>
  136. <Row>
  137. <Col span={12}>
  138. <FormItem label='显示' labelCol={{ span: 16 }} wrapperCol={{ span: 8 }}>
  139. <Checkbox
  140. checked={!!barStyle.labelVisible}
  141. onChange={e => {
  142. let checked = e.target.checked;
  143. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelVisible: checked } }) }];
  144. if(!!chartOption.baseOption) {
  145. let seriesArr = [];
  146. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  147. seriesArr.push({
  148. label: { normal: { show: checked } },
  149. labelLine: { normal: { show: checked } }
  150. });
  151. }
  152. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  153. }
  154. dispatch({ type: 'chartDesigner/setFields', fields });
  155. }}
  156. />
  157. </FormItem>
  158. </Col>
  159. <Col span={12}>
  160. {!!barStyle.labelVisible && <FormItem label='显示0标注' labelCol={{ span: 16 }} wrapperCol={{ span: 8 }}>
  161. <Checkbox
  162. checked={!!barStyle.labelZeroVisible}
  163. onChange={e => {
  164. let checked = e.target.checked;
  165. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelZeroVisible: checked } }) }];
  166. if(!!chartOption.baseOption) {
  167. let seriesArr = [];
  168. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  169. seriesArr.push({
  170. label: { normal: {
  171. formatterKey: checked,
  172. formatter: !checked ? (params) => {
  173. const { value } = params;
  174. return Number(value) === 0 ? '' : value;
  175. } : '{c}'
  176. } },
  177. });
  178. }
  179. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  180. }
  181. dispatch({ type: 'chartDesigner/setFields', fields });
  182. }}
  183. />
  184. </FormItem>}
  185. </Col>
  186. </Row>
  187. {!!barStyle.labelVisible && <Form.Item label='位置' {...formItemLayout}>
  188. <Select
  189. defaultValue={barStyle.labelPosition || 'inside'}
  190. onChange={(value, item) => {
  191. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelPosition: value } }) }];
  192. if(!!chartOption.baseOption) {
  193. let seriesArr = [];
  194. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  195. seriesArr.push({
  196. label: { normal: { position: value } }
  197. });
  198. }
  199. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  200. }
  201. dispatch({ type: 'chartDesigner/setFields', fields });
  202. }}
  203. >
  204. <Select.Option value='top'>外上</Select.Option>
  205. <Select.Option value='left'>外左</Select.Option>
  206. <Select.Option value='right'>外右</Select.Option>
  207. <Select.Option value='bottom'>外下</Select.Option>
  208. <Select.Option value='inside'>内中</Select.Option>
  209. <Select.Option value='insideLeft'>内左</Select.Option>
  210. <Select.Option value='insideRight'>内右</Select.Option>
  211. <Select.Option value='insideTop'>内上</Select.Option>
  212. <Select.Option value='insideBottom'>内下</Select.Option>
  213. <Select.Option value='insideTopLeft'>内上左</Select.Option>
  214. <Select.Option value='insideBottomLeft'>内下左</Select.Option>
  215. <Select.Option value='insideTopRight'>内上右</Select.Option>
  216. <Select.Option value='insideBottomRight'>内下右</Select.Option>
  217. </Select>
  218. </Form.Item>}
  219. {!!barStyle.labelVisible && <FormItem label={<Tooltip title="标注相对设置位置方向的距离">位置距离</Tooltip>} {...formItemLayout}>
  220. <InputNumber
  221. defaultValue={(barStyle.labelDistance === '' || barStyle.labelDistance === null || barStyle.labelDistance === undefined) ? null : barStyle.labelDistance}
  222. placeholder={5}
  223. onBlur={e => {
  224. let value = e.target.value;
  225. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelDistance: value } }) }];
  226. if(!!chartOption.baseOption) {
  227. let seriesArr = [];
  228. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  229. seriesArr.push({
  230. label: {
  231. normal: { distance: (value === '' || value === null || value === undefined) ? 5 : Number(value) }
  232. }
  233. });
  234. }
  235. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  236. }
  237. dispatch({ type: 'chartDesigner/setFields', fields });
  238. }}
  239. onKeyDown={e => {
  240. if(e.keyCode === 13) {
  241. let value = e.target.value;
  242. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelDistance: value } }) }];
  243. if(!!chartOption.baseOption) {
  244. let seriesArr = [];
  245. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  246. seriesArr.push({
  247. label: {
  248. normal: { distance: (value === '' || value === null || value === undefined) ? 5 : Number(value) }
  249. }
  250. });
  251. }
  252. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  253. }
  254. dispatch({ type: 'chartDesigner/setFields', fields });
  255. }
  256. }}
  257. />
  258. </FormItem>}
  259. {!!barStyle.labelVisible && <FormItem label={<Tooltip title="标注旋转度数,正值是逆时针">旋转</Tooltip>} {...formItemLayout}>
  260. <InputNumber
  261. defaultValue={(barStyle.labelRotate === '' || barStyle.labelRotate === null || barStyle.labelRotate === undefined) ? null : barStyle.labelRotate}
  262. placeholder={0}
  263. onBlur={e => {
  264. let value = e.target.value;
  265. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelRotate: value } }) }];
  266. if(!!chartOption.baseOption) {
  267. let seriesArr = [];
  268. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  269. seriesArr.push({
  270. label: {
  271. normal: { rotate: (value === '' || value === null || value === undefined) ? 0 : Number(value) }
  272. }
  273. });
  274. }
  275. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  276. }
  277. dispatch({ type: 'chartDesigner/setFields', fields });
  278. }}
  279. onKeyDown={e => {
  280. if(e.keyCode === 13) {
  281. let value = e.target.value;
  282. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { labelRotate: value } }) }];
  283. if(!!chartOption.baseOption) {
  284. let seriesArr = [];
  285. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  286. seriesArr.push({
  287. label: {
  288. normal: { rotate: (value === '' || value === null || value === undefined) ? 0 : Number(value) }
  289. }
  290. });
  291. }
  292. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  293. }
  294. dispatch({ type: 'chartDesigner/setFields', fields });
  295. }
  296. }}
  297. />
  298. </FormItem>}
  299. <Divider>横轴名称</Divider>
  300. <FormItem label={<Tooltip title="名称相对横轴显示位置">位置</Tooltip>} {...formItemLayout}>
  301. <Select
  302. defaultValue={barStyle.xNameLocation || 'end'}
  303. onChange={(value, item) => {
  304. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xNameLocation: value } }) }];
  305. if(!!chartOption.baseOption) {
  306. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  307. nameLocation: (value === '' || value === null || value === undefined) ? 'end' : value
  308. }} } }) });
  309. }
  310. dispatch({ type: 'chartDesigner/setFields', fields });
  311. }}
  312. >
  313. <Select.Option value='start'>头部</Select.Option>
  314. <Select.Option value='center'>中间</Select.Option>
  315. <Select.Option value='end'>尾部</Select.Option>
  316. </Select>
  317. </FormItem>
  318. <FormItem label={<Tooltip title="横轴名称与横轴之间的距离">位置距离</Tooltip>} {...formItemLayout}>
  319. <InputNumber
  320. defaultValue={(barStyle.xNameGap === '' || barStyle.xNameGap === null || barStyle.xNameGap === undefined) ? null : barStyle.xNameGap}
  321. placeholder={15}
  322. onBlur={e => {
  323. let value = e.target.value;
  324. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xNameGap: value } }) }];
  325. if(!!chartOption.baseOption) {
  326. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  327. nameGap: (value === '' || value === null || value === undefined) ? 15 : Number(value)
  328. } } } }) });
  329. }
  330. dispatch({ type: 'chartDesigner/setFields', fields });
  331. }}
  332. onKeyDown={e => {
  333. if(e.keyCode === 13) {
  334. let value = e.target.value;
  335. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xNameGap: value } }) }];
  336. if(!!chartOption.baseOption) {
  337. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  338. nameGap: (value === '' || value === null || value === undefined) ? 15 : Number(value)
  339. } } } }) });
  340. }
  341. dispatch({ type: 'chartDesigner/setFields', fields });
  342. }
  343. }}
  344. />
  345. </FormItem>
  346. <FormItem label={<Tooltip title="横轴名称旋转度数,正值是逆时针">旋转</Tooltip>} {...formItemLayout}>
  347. <InputNumber
  348. defaultValue={(barStyle.xNameRotate === '' || barStyle.xNameRotate === null || barStyle.xNameRotate === undefined) ? null : barStyle.xNameRotate}
  349. placeholder={0}
  350. onBlur={e => {
  351. let value = e.target.value;
  352. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xNameRotate: value } }) }];
  353. if(!!chartOption.baseOption) {
  354. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  355. nameRotate: (value === '' || value === null || value === undefined) ? 0 : Number(value)
  356. } } } }) });
  357. }
  358. dispatch({ type: 'chartDesigner/setFields', fields });
  359. }}
  360. onKeyDown={e => {
  361. if(e.keyCode === 13) {
  362. let value = e.target.value;
  363. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xNameRotate: value } }) }];
  364. if(!!chartOption.baseOption) {
  365. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  366. nameRotate: (value === '' || value === null || value === undefined) ? 0 : Number(value)
  367. } } } }) });
  368. }
  369. dispatch({ type: 'chartDesigner/setFields', fields });
  370. }
  371. }}
  372. />
  373. </FormItem>
  374. <Divider>横轴标签</Divider>
  375. <FormItem label={<Tooltip title="当横轴标签文本全部显示会相互覆盖时可以隐藏部分标签文本">隐藏重叠标签</Tooltip>} {...formItemLayout}>
  376. <Checkbox
  377. checked={barStyle.xLabelHiddenCover === undefined ? true : barStyle.xLabelHiddenCover}
  378. onChange={e => {
  379. let checked = e.target.checked;
  380. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xLabelHiddenCover: checked } }) }];
  381. if(!!chartOption.baseOption) {
  382. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  383. axisLabel: {
  384. interval: checked ? 'auto' : 0
  385. }
  386. } } } }) });
  387. }
  388. dispatch({ type: 'chartDesigner/setFields', fields });
  389. }}
  390. />
  391. </FormItem>
  392. <FormItem label={<Tooltip title="横轴标签与横轴之间的距离">位置距离</Tooltip>} {...formItemLayout}>
  393. <InputNumber
  394. defaultValue={(barStyle.xLabelMargin === '' || barStyle.xLabelMargin === null || barStyle.xLabelMargin === undefined) ? null : barStyle.xLabelMargin}
  395. placeholder={8}
  396. onBlur={e => {
  397. let value = e.target.value;
  398. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xLabelMargin: value } }) }];
  399. if(!!chartOption.baseOption) {
  400. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  401. axisLabel: {
  402. margin: (value === '' || value === null || value === undefined) ? 8 : Number(value)
  403. }
  404. } } } }) });
  405. }
  406. dispatch({ type: 'chartDesigner/setFields', fields });
  407. }}
  408. onKeyDown={e => {
  409. if(e.keyCode === 13) {
  410. let value = e.target.value;
  411. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xLabelMargin: value } }) }];
  412. if(!!chartOption.baseOption) {
  413. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  414. axisLabel: {
  415. margin: (value === '' || value === null || value === undefined) ? 8 : Number(value)
  416. }
  417. } } } }) });
  418. }
  419. dispatch({ type: 'chartDesigner/setFields', fields });
  420. }
  421. }}
  422. />
  423. </FormItem>
  424. <FormItem label={<Tooltip title="横轴标签旋转度数,正值是逆时针">旋转</Tooltip>} {...formItemLayout}>
  425. <InputNumber
  426. defaultValue={(barStyle.xLabelRotate === '' || barStyle.xLabelRotate === null || barStyle.xLabelRotate === undefined) ? null : barStyle.xLabelRotate}
  427. placeholder={0}
  428. onBlur={e => {
  429. let value = e.target.value;
  430. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xLabelRotate: value } }) }];
  431. if(!!chartOption.baseOption) {
  432. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  433. axisLabel: {
  434. rotate: (value === '' || value === null || value === undefined) ? 0 : Number(value)
  435. }
  436. } } } }) });
  437. }
  438. dispatch({ type: 'chartDesigner/setFields', fields });
  439. }}
  440. onKeyDown={e => {
  441. if(e.keyCode === 13) {
  442. let value = e.target.value;
  443. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { xLabelRotate: value } }) }];
  444. if(!!chartOption.baseOption) {
  445. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { xAxis: { 0: {
  446. axisLabel: {
  447. rotate: (value === '' || value === null || value === undefined) ? 0 : Number(value)
  448. }
  449. } } } }) });
  450. }
  451. dispatch({ type: 'chartDesigner/setFields', fields });
  452. }
  453. }}
  454. />
  455. </FormItem>
  456. <Divider>纵轴名称</Divider>
  457. <FormItem label={<Tooltip title="名称相对纵轴显示位置">位置</Tooltip>} {...formItemLayout}>
  458. <Select
  459. defaultValue={barStyle.yNameLocation || 'end'}
  460. onChange={(value, item) => {
  461. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { yNameLocation: value } }) }];
  462. if(!!chartOption.baseOption) {
  463. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { yAxis: { 0: {
  464. nameLocation: (value === '' || value === null || value === undefined) ? 'end' : value,
  465. }} } }) });
  466. }
  467. dispatch({ type: 'chartDesigner/setFields', fields });
  468. }}
  469. >
  470. <Select.Option value='start'>头部</Select.Option>
  471. <Select.Option value='center'>中间</Select.Option>
  472. <Select.Option value='end'>尾部</Select.Option>
  473. </Select>
  474. </FormItem>
  475. <FormItem label={<Tooltip title="纵轴名称与纵轴之间的距离">位置距离</Tooltip>} {...formItemLayout}>
  476. <InputNumber
  477. defaultValue={(barStyle.yNameGap === '' || barStyle.yNameGap === null || barStyle.yNameGap === undefined) ? null : barStyle.yNameGap}
  478. placeholder={15}
  479. onBlur={e => {
  480. let value = e.target.value;
  481. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { yNameGap: value } }) }];
  482. if(!!chartOption.baseOption) {
  483. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { yAxis: { 0: {
  484. nameGap: (value === '' || value === null || value === undefined) ? 15 : Number(value)
  485. } } } }) });
  486. }
  487. dispatch({ type: 'chartDesigner/setFields', fields });
  488. }}
  489. onKeyDown={e => {
  490. if(e.keyCode === 13) {
  491. let value = e.target.value;
  492. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { yNameGap: value } }) }];
  493. if(!!chartOption.baseOption) {
  494. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { yAxis: { 0: {
  495. nameGap: (value === '' || value === null || value === undefined) ? 15 : Number(value)
  496. } } } }) });
  497. }
  498. dispatch({ type: 'chartDesigner/setFields', fields });
  499. }
  500. }}
  501. />
  502. </FormItem>
  503. <FormItem label={<Tooltip title="纵轴名称旋转度数,正值是逆时针">旋转</Tooltip>} {...formItemLayout}>
  504. <InputNumber
  505. defaultValue={(barStyle.yNameRotate === '' || barStyle.yNameRotate === null || barStyle.yNameRotate === undefined) ? null : barStyle.yNameRotate}
  506. placeholder={0}
  507. onBlur={e => {
  508. let value = e.target.value;
  509. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { yNameRotate: value } }) }];
  510. if(!!chartOption.baseOption) {
  511. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { yAxis: { 0: {
  512. nameRotate: (value === '' || value === null || value === undefined) ? 0 : Number(value)
  513. } } } }) });
  514. }
  515. dispatch({ type: 'chartDesigner/setFields', fields });
  516. }}
  517. onKeyDown={e => {
  518. if(e.keyCode === 13) {
  519. let value = e.target.value;
  520. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { yNameRotate: value } }) }];
  521. if(!!chartOption.baseOption) {
  522. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { yAxis: { 0: {
  523. nameRotate: (value === '' || value === null || value === undefined) ? 0 : Number(value)
  524. } } } }) });
  525. }
  526. dispatch({ type: 'chartDesigner/setFields', fields });
  527. }
  528. }}
  529. />
  530. </FormItem>
  531. {!!groupBy && !!groupBy.key && <Divider>数据堆叠</Divider>}
  532. {!!groupBy && !!groupBy.key && <FormItem label='启用' {...formItemLayout}>
  533. <Checkbox
  534. checked={!!barStyle.stack}
  535. onChange={e => {
  536. let checked = e.target.checked;
  537. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { stack: checked } }) }];
  538. if(!!chartOption.baseOption) {
  539. let seriesArr = [];
  540. for(let i = 0; i < chartOption.baseOption.series.length; i++) {
  541. seriesArr.push({
  542. stack: checked
  543. });
  544. }
  545. fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: seriesArr } }) });
  546. }
  547. dispatch({ type: 'chartDesigner/setFields', fields });
  548. }}
  549. />
  550. </FormItem>}
  551. <Divider>区域缩放</Divider>
  552. <FormItem label='启用' {...formItemLayout}>
  553. <Checkbox
  554. checked={!!barStyle.dataZoomVisible}
  555. onChange={e => {
  556. let checked = e.target.checked;
  557. let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { bar: { dataZoomVisible: checked } }) }];
  558. if(!!chartOption.baseOption) {
  559. let legendVisible = chartOption.baseOption.legend ? chartOption.baseOption.legend.show : false;
  560. fields.push({ name: 'chartOption', value: deepAssign(chartOption, {
  561. baseOption: { dataZoom: { show: checked } },
  562. media: EChartsMedia('bar', legendVisible, checked)
  563. }) });
  564. }
  565. dispatch({ type: 'chartDesigner/setFields', fields });
  566. }}
  567. />
  568. </FormItem>
  569. </Form>
  570. }
  571. }
  572. export default connect(({ present: { chartDesigner } }) => ({ chartDesigner }))(BarStyle);