| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- Ext.define('saas.view.home.charts.SaleTrend', {
- extend: 'saas.view.core.chart.ChartBase',
- xtype: 'sale-trend',
- id: 'sale_trend',
- bind: {
- title: '近六月销售趋势图(万元)'
- },
- initComponent: function() {
- var me = this;
- Ext.apply(me, {
- items: [{
- xtype: 'cartesian',
- colors: [
- '#64B0E4',
- '#FF1038'
- ],
- bind: {
- insetPadding: '{insetPadding}',
- store: '{sale_trend}',
- },
- // legend: {
- // type: 'dom',
- // docked: 'top',
- // },
- axes: [{
- // title: {
- // text: '月',
- // fontSize: 14,
- // },
- type: 'category',
- fields: ['x'],
- position: 'bottom',
- label: {
- fontSize: '12px',
- fillStyle: '#485465',
- },
- style: {
- fill: '#E5EAEF',
- strokeStyle: 'transparent'
- },
- renderer: me.categoryRender
- },{
- type: 'numeric',
- fields: ['sale', 'saleback'],
- position: 'left',
- grid: {
- even: {
- stroke: '#E5EAEF',
- },
- odd: {
- stroke: '#E5EAEF',
- }
- },
- label: {
- fontSize: '12px',
- fillStyle: '#485465',
- },
- style: {
- fill: '#fff',
- strokeStyle: 'transparent'
- },
- }],
- series: [{
- type: 'line',
- // smooth: true,
- title: '销售额',
- xField: 'x',
- yField: 'sale',
- label: {
- field: 'sale',
- display: 'over',
- fontSize: '12px',
- strokeStyle: '#A3D0EE',
- },
- marker: {
- radius: 0,
- lineWidth: 0
- },
- highlight: {
- fillStyle: '#53A8E2',
- fillOpacity: 1,
- strokeStyle: '#A3D0EE',
- radius: 5,
- lineWidth: 2,
- },
- style: {
- lineWidth: 2,
- fillStyle: '#53A8E2',
- fillOpacity: 0.1,
- },
- tooltip: {
- trackMouse: true,
- renderer: me.onSeriesTooltipRender
- },
- // renderer: me.onSeriesRenderer
- }, {
- type: 'line',
- // smooth: true,
- title: '销售回款',
- xField: 'x',
- yField: 'saleback',
- label: {
- field: 'saleback',
- display: 'over',
- fontSize: '12px',
- strokeStyle: '#D54F65',
- },
- tooltip: {
- trackMouse: true,
- renderer: me.onSeriesTooltipRender
- },
- marker: {
- radius: 0,
- lineWidth: 0
- },
- highlight: {
- fillStyle: '#D54F65',
- fillOpacity: 1,
- strokeStyle: '#FF9BAC',
- radius: 5,
- lineWidth: 2,
- },
- style: {
- lineWidth: 2,
- fillStyle: '#D54F65',
- fillOpacity: 0.1,
- },
- }],
- legend: {
- type: 'dom',
- docked: 'top',
- padding: 0,
- bodyPadding: 0,
- border: 0,
- cls: 'x-saletrend-legend'
- },
- listeners: {
- itemhighlightchange: me.itemhighlightchange
- }
- }]
- });
- me.callParent(arguments);
- },
- onSeriesRender: function (sprite, config, rendererData, index) {
- var store = rendererData.store,
- storeItems = store.getData().items,
- currentRecord = storeItems[index],
- previousRecord = (index > 0 ? storeItems[index-1] : currentRecord),
- current = currentRecord && currentRecord.data['g1'],
- previous = previousRecord && previousRecord.data['g1'],
- isUp = current >= previous,
- changes = {};
- switch (config.type) {
- case 'marker':
- changes.strokeStyle = (isUp ? 'cornflowerblue' : 'tomato');
- changes.fillStyle = (isUp ? 'aliceblue' : 'lightpink');
- break;
- case 'line':
- changes.strokeStyle = (isUp ? 'cornflowerblue' : 'tomato');
- changes.fillStyle = (isUp ? 'rgba(100, 149, 237, 0.4)' : 'rgba(255, 99, 71, 0.4)');
- break;
- }
- return changes;
- },
- onSeriesTooltipRender: function (tooltip, record, item) {
- tooltip.setHtml(record.get('x') + '月: ' + Ext.util.Format.number(record.get(item.series.getYField()), '0,000.00') + '万元');
- },
- categoryRender: function(axis, label, layoutContext, lastLabel) {
- return label + '月';
- },
- itemhighlightchange: function(chart, newHighlightItem, oldHighlightItem) {
- this.setSeriesLineWidth(newHighlightItem, 4);
- this.setSeriesLineWidth(oldHighlightItem, 2);
- },
- setSeriesLineWidth: function (item, lineWidth) {
- console.log('xxxx');
- if (item) {
- item.series.setStyle({
- lineWidth: lineWidth
- });
- }
- },
- });
|