@smt-ui/component
Advanced tools
Comparing version 1.1.80 to 1.1.81
{ | ||
"name": "@smt-ui/component", | ||
"version": "1.1.80", | ||
"version": "1.1.81", | ||
"description": "extension base", | ||
@@ -48,3 +48,3 @@ "author": "jialipeng <jialipeng@baidu.com>", | ||
}, | ||
"gitHead": "be2d8894dbf2092b2554da2481e37c88552cbe75" | ||
"gitHead": "5d2bdffbb18957fafa4f0d774c608fa438ecbc91" | ||
} |
@@ -51,8 +51,8 @@ #### 组件名称 | ||
data: { | ||
img: 'https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=2249811055,2059931732&fm=179&app=35&f=PNG?w=1242&h=1003&s=F99425D50E5774D64A1CF50A0300F0D2', | ||
img: 'https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=915215205,3768974202&fm=179&app=35&f=PNG?w=1242&h=1002&s=A363DA141F32669685BD1CC90300A0E0', | ||
originWidth: 960, | ||
originHeight: 960, | ||
list: [{ | ||
abscissa: 400, | ||
ordinate: 220, | ||
abscissa: 600, | ||
ordinate: 160, | ||
text: '自然棕色染', | ||
@@ -59,0 +59,0 @@ position: 'left' |
@@ -377,1 +377,40 @@ /** | ||
} | ||
/** | ||
* | ||
* 对柱图数据浅cpoy | ||
* | ||
* @param {*} points [{value: 42, height: 280.56, x: 68, y: 91}] | ||
* @param {*} eachSpacing 坐标点间隔 | ||
* @param {*} columnLen 一个分类里数据总数 | ||
* @param {*} index 当前index | ||
* @param {*} config 用户配置 | ||
* @return {Object} | ||
*/ | ||
export function fixColumnData(points, eachSpacing, columnLen, index, config) { | ||
const { | ||
xAxis: { | ||
type | ||
}, | ||
styleConfig: { | ||
columnPadding | ||
} | ||
} = config; | ||
return points.map(item => { | ||
if (item === null) { | ||
return null; | ||
} | ||
const itemCopy = { | ||
...item, | ||
width: Math.min((eachSpacing - 2 * columnPadding) / columnLen, 30) | ||
}; | ||
if (type === 'value') { | ||
itemCopy.y += (index + 0.5 - (columnLen) / 2) * itemCopy.width; | ||
} | ||
else { | ||
itemCopy.x += (index + 0.5 - (columnLen) / 2) * itemCopy.width; | ||
} | ||
return itemCopy; | ||
}); | ||
} |
@@ -12,7 +12,8 @@ | ||
import { | ||
getValidHeight | ||
getValidHeight, | ||
fixColumnData | ||
} from './draw-chart-data'; | ||
/** | ||
* 绘制x轴 | ||
* 绘制x轴 | ||
* | ||
@@ -399,2 +400,3 @@ * @param {*} originPoint 原点 | ||
calPoints.push(points); | ||
points = fixColumnData(points, eachSpacing, series.length, index, config); | ||
drawBarDataSinglePoints(points, canvasContext, series, eachSpacing, index, config, process); | ||
@@ -515,40 +517,2 @@ }); | ||
* | ||
* 对柱图数据浅cpoy | ||
* | ||
* @param {*} points [{value: 42, height: 280.56, x: 68, y: 91}] | ||
* @param {*} eachSpacing 坐标点间隔 | ||
* @param {*} columnLen 一个分类里数据总数 | ||
* @param {*} index 当前index | ||
* @param {*} config 用户配置 | ||
* @return {Object} | ||
*/ | ||
function fixColumnData(points, eachSpacing, columnLen, index, config) { | ||
const { | ||
xAxis: { | ||
type | ||
}, | ||
styleConfig: { | ||
columnPadding | ||
} | ||
} = config; | ||
return points.map(item => { | ||
if (item === null) { | ||
return null; | ||
} | ||
const itemCopy = { | ||
...item, | ||
width: Math.min((eachSpacing - 2 * columnPadding) / columnLen, 30) | ||
}; | ||
if (type === 'value') { | ||
itemCopy.y += (index + 0.5 - (columnLen) / 2) * itemCopy.width; | ||
} | ||
else { | ||
itemCopy.x += (index + 0.5 - (columnLen) / 2) * itemCopy.width; | ||
} | ||
return itemCopy; | ||
}); | ||
} | ||
/** | ||
* | ||
* 绘制柱状图 | ||
@@ -564,3 +528,2 @@ * | ||
*/ | ||
function drawBarDataSinglePoints(points, context, seriesBar, eachSpacing, index, config, process = 1) { | ||
@@ -580,3 +543,2 @@ if (config.xAxis.type === 'value') { | ||
} = config; | ||
points = fixColumnData(points, eachSpacing, seriesBar.length, index, config); | ||
points.forEach((item, idx) => { | ||
@@ -625,3 +587,2 @@ // 绘制柱状数据图 | ||
} = config; | ||
points = fixColumnData(points, eachSpacing, seriesBar.length, index, config); | ||
points.forEach((item, idx) => { | ||
@@ -628,0 +589,0 @@ // 绘制柱状数据图 |
@@ -377,3 +377,3 @@ /** | ||
if (type === 'line' && tooltip.offset) { | ||
drawToolTipSplitLine(tooltip.offset.x, originPoint, toolTipBackground, ctxAxis); | ||
drawToolTipSplitLine(tooltip.offset.x, originPoint, ctxAxis); | ||
} | ||
@@ -380,0 +380,0 @@ else if (type === 'bar') { |
@@ -12,3 +12,8 @@ /** | ||
type: Object, | ||
value: {} | ||
value: {}, | ||
observer(newVal, oldVal) { | ||
// 使用 setData 设置 this.data.some.subfield 时触发 | ||
// (除此以外,使用 setData 设置 this.data.some 也会触发) | ||
this.draw(); | ||
} | ||
} | ||
@@ -28,37 +33,41 @@ }, | ||
}, | ||
attached() { | ||
let { | ||
canvasWidth, | ||
canvasHeight, | ||
renderType, | ||
canvasId = 'myCanvas' | ||
} = this.data.chartOptions; | ||
this.setData({ | ||
canvasWidth, | ||
canvasHeight, | ||
renderType | ||
}); | ||
setTimeout(() => { | ||
let ctx = swan.createCanvasContext(canvasId); // 数据上下文 | ||
let ctxAxis = swan.createCanvasContext(`${canvasId}Axis`); // 坐标轴 | ||
let svgCtx = createSVGContext(this); | ||
let ctxToolTip = swan.createCanvasContext(`${canvasId}ToolTip`); // 坐标轴 | ||
this.ctxToolTip = ctxToolTip; | ||
if (renderType === 'svg') { | ||
ctx = svgCtx; | ||
ctxAxis = svgCtx; | ||
ctxToolTip = svgCtx; | ||
this.setData({ | ||
renderType: 'svg' | ||
}); | ||
} | ||
this.swanChartDemo = new SwanChart({ | ||
ctx, | ||
ctxAxis, | ||
ctxToolTip, | ||
...this.data.chartOptions | ||
}); | ||
}, 100); | ||
this.draw(); | ||
}, | ||
methods: { | ||
draw() { | ||
let { | ||
canvasWidth, | ||
canvasHeight, | ||
renderType, | ||
canvasId = 'myCanvas' | ||
} = this.data.chartOptions; | ||
this.setData({ | ||
canvasWidth, | ||
canvasHeight, | ||
renderType | ||
}); | ||
setTimeout(() => { | ||
let ctx = swan.createCanvasContext(canvasId); // 数据上下文 | ||
let ctxAxis = swan.createCanvasContext(`${canvasId}Axis`); // 坐标轴 | ||
let svgCtx = createSVGContext(this); | ||
let ctxToolTip = swan.createCanvasContext(`${canvasId}ToolTip`); // 坐标轴 | ||
this.ctxToolTip = ctxToolTip; | ||
if (renderType === 'svg') { | ||
ctx = svgCtx; | ||
ctxAxis = svgCtx; | ||
ctxToolTip = svgCtx; | ||
this.setData({ | ||
renderType: 'svg' | ||
}); | ||
} | ||
this.swanChartDemo = new SwanChart({ | ||
ctx, | ||
ctxAxis, | ||
ctxToolTip, | ||
...this.data.chartOptions | ||
}); | ||
}, 100); | ||
}, | ||
handleTouchStart(e) { | ||
@@ -65,0 +74,0 @@ if (this.data.renderType !== 'svg') { |
@@ -1,1 +0,1 @@ | ||
{"name":"component","label":"通用","type":"component","configPath":"./smart-design-config.json","version":"1.1.79"} | ||
{"name":"component","label":"通用","type":"component","configPath":"./smart-design-config.json","version":"1.1.80"} |
Sorry, the diff of this file is too big to display
1666357
14946