Commit ff762ec5b3bd97ebb1085196cb5057fff81ea16a
1 parent
563e14b7
feat(chrt component): support color theme !#zh: echart 支持配色
Showing
5 changed files
with
50 additions
and
15 deletions
front-end/h5/src/components/core/support/colors-panel.js
0 → 100644
| 1 | +export default { | |
| 2 | + name: 'colors-panel', | |
| 3 | + props: { | |
| 4 | + value: { | |
| 5 | + type: Array, | |
| 6 | + default: () => [] | |
| 7 | + } | |
| 8 | + }, | |
| 9 | + render () { | |
| 10 | + return <div> | |
| 11 | + { | |
| 12 | + this.value.map((colorString, index) => { | |
| 13 | + return <el-color-picker | |
| 14 | + size="small" | |
| 15 | + value={colorString} | |
| 16 | + onChange={newColorString => { | |
| 17 | + const colors = this.value.slice(0) | |
| 18 | + colors[index] = newColorString | |
| 19 | + this.$emit('change', colors) | |
| 20 | + }} | |
| 21 | + /> | |
| 22 | + }) | |
| 23 | + } | |
| 24 | + </div> | |
| 25 | + } | |
| 26 | +} | ... | ... |
front-end/h5/src/components/core/support/csv-import.js
| ... | ... | @@ -63,8 +63,8 @@ export default { |
| 63 | 63 | }, |
| 64 | 64 | render () { |
| 65 | 65 | const randomId = +new Date() |
| 66 | - return <div style="height: 50px;"> | |
| 67 | - <label for={randomId} class="ant-btn ant-btn-primary ant-btn-sm">请选择CSV文件</label> | |
| 66 | + return <div style="height: 24px;"> | |
| 67 | + <label for={randomId} class="ant-btn ant-btn-primary ant-btn-sm">选择导入 csv 文件</label> | |
| 68 | 68 | {/* <input id={randomId} style="visibility:hidden;" type="file"></input> */} |
| 69 | 69 | <input ref="input" id={randomId} ref="csv" type="file" onChange={this.validFileMimeType} style="visibility:hidden;" name="csv">xxxx</input> |
| 70 | 70 | </div> | ... | ... |
front-end/h5/src/components/core/support/excel.js
| ... | ... | @@ -46,11 +46,12 @@ export default { |
| 46 | 46 | } |
| 47 | 47 | }, |
| 48 | 48 | render () { |
| 49 | - return <div> | |
| 50 | - <span>方案1: 选择导入 csv 文件</span> | |
| 51 | - <CsvImport onParse={this.parseCSV} /> | |
| 52 | - <span>方案2: 直接编辑 Excel</span> | |
| 53 | - <div id="excel-wrapper" ref="excel" style="margin-right: 12px;width: 100%;overflow: scroll"></div> | |
| 49 | + return <div style="max-height: 320px;overflow:scroll;"> | |
| 50 | + <div style="line-height:2;"> | |
| 51 | + <span>方案1: <CsvImport onParse={this.parseCSV} /></span> | |
| 52 | + <span>方案2: 直接编辑 Excel</span> | |
| 53 | + <div id="excel-wrapper" ref="excel" style="margin-right: 12px;width: 100%;overflow: scroll"></div> | |
| 54 | + </div> | |
| 54 | 55 | </div> |
| 55 | 56 | }, |
| 56 | 57 | mounted () { | ... | ... |
front-end/h5/src/components/core/support/index.js
| ... | ... | @@ -14,6 +14,7 @@ import PropMultiTextItemsEditor from './prop-multi-items-editor/text.js' |
| 14 | 14 | import ImageGallery from './image-gallery/gallery.js' |
| 15 | 15 | import VideoGallery from './video-gallery/gallery.js' |
| 16 | 16 | import LbsExcelEditor from './excel' |
| 17 | +import ColorsPanel from './colors-panel' | |
| 17 | 18 | import LbpTextAlign from '@luban-h5/lbs-text-align' |
| 18 | 19 | |
| 19 | 20 | Vue.component(PropMultiTextItemsEditor.name, PropMultiTextItemsEditor) |
| ... | ... | @@ -21,3 +22,4 @@ Vue.component(ImageGallery.name, ImageGallery) |
| 21 | 22 | Vue.component(VideoGallery.name, VideoGallery) |
| 22 | 23 | Vue.component('lbs-text-align', LbpTextAlign) |
| 23 | 24 | Vue.component(LbsExcelEditor.name, LbsExcelEditor) |
| 25 | +Vue.component(ColorsPanel.name, ColorsPanel) | ... | ... |
front-end/h5/src/components/plugins/charts/line.js
| ... | ... | @@ -34,6 +34,17 @@ export default { |
| 34 | 34 | label: '类型', |
| 35 | 35 | defaultValue: 'line', |
| 36 | 36 | visible: false |
| 37 | + }), | |
| 38 | + colors: PropTypes.colors({ | |
| 39 | + label: '颜色面板', | |
| 40 | + defaultValue: () => [ | |
| 41 | + // https://github.com/ElemeFE/v-charts/blob/01ebb541a5d905047dd52957ae0898d529342235/src/constants.js#L20 | |
| 42 | + '#19d4ae', '#5ab1ef', '#fa6e86', | |
| 43 | + '#ffb980', '#0067a6', '#c4b4e4', | |
| 44 | + '#d87a80', '#9cbbff', '#d9d0c7', | |
| 45 | + '#87a997', '#d49ea2', '#5b4947', | |
| 46 | + '#7ba3a8' | |
| 47 | + ] | |
| 37 | 48 | }) |
| 38 | 49 | }, |
| 39 | 50 | data () { |
| ... | ... | @@ -43,19 +54,14 @@ export default { |
| 43 | 54 | }, |
| 44 | 55 | render () { |
| 45 | 56 | const chartData = Parser.csv2VChartJson(this.dataset) |
| 46 | - const settings = { | |
| 47 | - // metrics: ['日期', '销售量'], | |
| 48 | - // dimension: ['日期'] | |
| 49 | - } | |
| 50 | 57 | switch (this.type) { |
| 51 | 58 | case 'line': |
| 52 | - return <VeLine data={chartData} settings={settings} /> | |
| 53 | 59 | case 'histogram': |
| 54 | - return <VeHistogram data={chartData} settings={settings} /> | |
| 60 | + return <VeHistogram data={chartData} colors={this.colors} /> | |
| 55 | 61 | case 'pie': |
| 56 | - return <VePie data={chartData} settings={settings} /> | |
| 62 | + return <VePie data={chartData} /> | |
| 57 | 63 | case 'funnel': |
| 58 | - return <VeFunnel data={chartData} settings={settings} /> | |
| 64 | + return <VeFunnel data={chartData} /> | |
| 59 | 65 | default: |
| 60 | 66 | return null |
| 61 | 67 | } | ... | ... |