|
|
|
@ -15,6 +15,7 @@ export class AxLegend extends AxShape {
|
|
|
|
|
*/ |
|
|
|
|
constructor(assetData: any, workingArea: WorkingAreaComponent,shapeMap:Map<string,Legend>) { |
|
|
|
|
super(assetData, workingArea); |
|
|
|
|
this.angle = -this.workingArea.backgroundImage.angle; |
|
|
|
|
this.name = this.assetData.Id; |
|
|
|
|
this.shapeMap = shapeMap; |
|
|
|
|
this.refresh(); |
|
|
|
@ -42,15 +43,15 @@ export class AxLegend extends AxShape {
|
|
|
|
|
refresh() { |
|
|
|
|
this.removeChildren(); |
|
|
|
|
let index = 1; |
|
|
|
|
let offset = 50; |
|
|
|
|
let offset = 25; |
|
|
|
|
let number = 2; |
|
|
|
|
let width = 450; |
|
|
|
|
let height = 100; |
|
|
|
|
let width = 300; |
|
|
|
|
let height = 50; |
|
|
|
|
for (let i = 0; i < number; i++){ |
|
|
|
|
if (i >= this.shapeMap.size) break; |
|
|
|
|
let x = width * i; |
|
|
|
|
var textImage = new Text('图例',{ |
|
|
|
|
fontSize: 36, |
|
|
|
|
fontSize: 20, |
|
|
|
|
fill: ['#0000ff'],
|
|
|
|
|
}); |
|
|
|
|
textImage.anchor.set(0.5) |
|
|
|
@ -59,7 +60,7 @@ export class AxLegend extends AxShape {
|
|
|
|
|
this.addChild(textImage); |
|
|
|
|
|
|
|
|
|
var textName = new Text("名称"+' 【数量】',{ |
|
|
|
|
fontSize: 36, |
|
|
|
|
fontSize: 20, |
|
|
|
|
fill: ['#0000ff'],
|
|
|
|
|
}); |
|
|
|
|
textName.anchor.set(0,0.5); |
|
|
|
@ -71,14 +72,16 @@ export class AxLegend extends AxShape {
|
|
|
|
|
let x = index % number === 0 ? (number -1) * width : (index % number - 1) * width; |
|
|
|
|
let y = Math.ceil(index / number) * height; |
|
|
|
|
let image: Sprite = Sprite.from(item.ImageUrl); |
|
|
|
|
image.width = 64; |
|
|
|
|
image.height = 64; |
|
|
|
|
image.width = 32; |
|
|
|
|
image.height = 32; |
|
|
|
|
image.anchor.set(0.5); |
|
|
|
|
image.x = x; |
|
|
|
|
image.y = y; |
|
|
|
|
this.addChild(image); |
|
|
|
|
|
|
|
|
|
var textName = new Text(item.Name+' 【'+item.Count.toString()+'】'); |
|
|
|
|
var textName = new Text(item.Name+' 【'+item.Count.toString()+'】',{ |
|
|
|
|
fontSize: 20, |
|
|
|
|
}); |
|
|
|
|
textName.anchor.set(0,0.5); |
|
|
|
|
textName.x = x + image.width/2 + offset; |
|
|
|
|
textName.y = y; |
|
|
|
@ -89,7 +92,7 @@ export class AxLegend extends AxShape {
|
|
|
|
|
let rect = this.getLocalBounds(); |
|
|
|
|
this.pen.clear(); |
|
|
|
|
this.pen.beginFill(0xffffff,0.01); |
|
|
|
|
this.pen.lineStyle(5, 0x000000); |
|
|
|
|
this.pen.lineStyle(3, 0x000000); |
|
|
|
|
this.pen.moveTo(rect.left-offset, rect.top-offset); |
|
|
|
|
this.pen.lineTo(rect.right+offset, rect.top-offset); |
|
|
|
|
this.pen.lineTo(rect.right+offset, rect.bottom+offset); |
|
|
|
@ -98,6 +101,7 @@ export class AxLegend extends AxShape {
|
|
|
|
|
this.pen.endFill(); |
|
|
|
|
}
|
|
|
|
|
this.addChild(this.pen); |
|
|
|
|
this.angle = -this.workingArea.backgroundImage.angle; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|