From cbf2f7867313118c6d27353d9f3437f710b492e4 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Thu, 27 Oct 2022 15:22:08 +0800 Subject: [PATCH] opt some --- plugin/local/wiki/draw.js | 12 +++++++----- plugin/story/trend.js | 4 ++-- proto.js | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugin/local/wiki/draw.js b/plugin/local/wiki/draw.js index e100d493..09aa4872 100644 --- a/plugin/local/wiki/draw.js +++ b/plugin/local/wiki/draw.js @@ -174,10 +174,12 @@ Volcanos(chat.ONFIGURE, {help: "图形绘制", }, rect: { // data: {points: 2, ry: 4, rx: 4, size: {}, copy: [html.HEIGHT, html.WIDTH, svg.RY, svg.RX]}, - draw: function(event, can, point) { if (point.length < 2) { return } - var p0 = point[0], p1 = point[1] + draw: function(event, can, point, style) { if (point.length < 2) { return } + var p0 = point[0], p1 = point[1]; style = style||{} return { - height: Math.abs(p0.y-p1.y), width: Math.abs(p0.x-p1.x), ry: this.data.ry, rx: this.data.rx, + height: Math.abs(p0.y-p1.y), width: Math.abs(p0.x-p1.x), + ry: style.ry == undefined? this.data.ry: style.ry, + rx: style.rx == undefined? this.data.rx: style.rx, x: p0.x > p1.x? p1.x: p0.x, y: p0.y > p1.y? p1.y: p0.y, } }, @@ -206,7 +208,7 @@ Volcanos(chat.ONFIGURE, {help: "图形绘制", this._temp && can.page.Remove(can, this._temp) && delete(this._temp) this._temp = can.onfigure._push(can, svg.G, {}, can.group||can.svg) - var rect = can.onfigure._push(can, svg.RECT, can.onfigure.rect.draw(event, can, point), this._temp) + var rect = can.onfigure._push(can, svg.RECT, can.onfigure.rect.draw(event, can, point, {}), this._temp) if (event.type == html.CLICK) { can.onfigure._pid(can, rect), delete(this._temp) } @@ -300,7 +302,7 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: [ var shape = can.Action(svg.SHAPE), figure = can.onfigure[shape] figure.grid && figure.grid(event, can, point) - var data = figure.draw && figure.draw(event, can, point) + var data = figure.draw && figure.draw(event, can, point, {}) var item = data && can.onfigure._push(can, figure.data.name||shape, data, can.group||can.svg) event.type == html.CLICK && point.length === figure.data.points && (can.point = []) diff --git a/plugin/story/trend.js b/plugin/story/trend.js index 827c9e6e..ecf5ad44 100644 --- a/plugin/story/trend.js +++ b/plugin/story/trend.js @@ -36,7 +36,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar _layout: function(can) { var height = can.onexport.height(can) var width = parseInt(can.ConfWidth()), space = parseInt(can.Action("space")||"10") - var step = parseInt((width-2*space) / can.list.length) + var step = parseFloat((width-2*space) / can.list.length) can.onmotion.clear(can, can._output), can.onimport._show(can, can._msg) can.svg.Val(html.HEIGHT, height), can.svg.Val(html.WIDTH, width) @@ -84,7 +84,7 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: [ can.onimport.draw({}, can, {shape: svg.RECT, point: [ order(index, args.step/4, line.close), order(index, args.step/4*3, line.begin), - ], _init: function(view) { + ], style: {rx: 0, ry:0}, _init: function(view) { can.core.ItemCB(can.ondetail, function(key, cb) { view[key] = function(event) { cb(event, can, line) } }) }}, line.begin < line.close? white: black) diff --git a/proto.js b/proto.js index 2fd9d529..5b38ca61 100644 --- a/proto.js +++ b/proto.js @@ -314,7 +314,7 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", cache: for (var i = 0; i < arguments.length; i += 2) { if (typeof key == lang.OBJECT) { res = can.core.Value(can._conf, arguments[i]), i--; continue } res = can.core.Value(can._conf, arguments[i], arguments[i+1]) - } return can.base.isUndefined(res) && key.indexOf(ctx.FEATURE+ice.PT) == -1? can.Conf(can.core.Keys(ctx.FEATURE, key)): res + } return res == undefined && key.indexOf(ctx.FEATURE+ice.PT) == -1? can.Conf(can.core.Keys(ctx.FEATURE, key)): res }, _conf: {}, }; can = can||{}, kit.proto(can, proto), kit.proto(proto, meta), _can_path = _can_name||_can_path