diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index 91dde220..10ee19da 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -4,5 +4,5 @@ var version = struct { host string self int }{ - "2019-07-08 16:56:13", "ZYB-20190522USI", 122, + "2019-07-08 23:23:11", "com.mac", 57, } diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 4bde1cd2..4b580c92 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -1253,7 +1253,7 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", }}, "git": &ctx.Command{Name: "git sum", Help: "版本控制", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { if len(arg) > 0 && arg[0] == "sum" { - if out, e := exec.Command("git", "log", "--shortstat", "--pretty=commit: %ad", "--date=format:%Y-%m-%d").CombinedOutput(); m.Assert(e) { + if out, e := exec.Command("git", "log", "--reverse", "--shortstat", "--pretty=commit: %ad", "--date=format:%Y-%m-%d").CombinedOutput(); m.Assert(e) { for _, v := range strings.Split(string(out), "commit: ") { if l := strings.Split(v, "\n"); len(l) > 2 { fs := strings.Split(strings.TrimSpace(l[2]), ", ") @@ -1395,6 +1395,10 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", m.Cmdy("nfs.dir", "src", "filename", "line", "size", "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r") return } + if arg[0] == "git" { + m.Cmdy("nfs.git", "sum") + return + } m.Append("text", m.Time()) m.Append("style", map[int]string{ diff --git a/usr/librarys/example.js b/usr/librarys/example.js index 81a630a8..8eea5ef9 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -854,7 +854,7 @@ function Canvas(plugin, output, width, height, space, msg) { var list = [] msg[key].forEach(function(value, index) { var v = parseInt(value) - !isNaN(v) && (list.push(v), v > (max[key]||0) && (max[key] = v)) + !isNaN(v) && (list.push((value.indexOf("-") == -1)? v: value), v > (max[key]||0) && (max[key] = v)) }) list.length == nrow && (keys.push(key), data[key] = list, nline++) }) @@ -1072,6 +1072,64 @@ function Canvas(plugin, output, width, height, space, msg) { return p }, }, + ticket: { + draw: function() { + what.drawAxies().drawXLabel(step) + canvas.beginPath() + + var sum = 0, total = 0 + for (var i = 0; i < nrow; i++) { + sum += data[keys[1]][i] + sum > total && (total = sum) + sum -= data[keys[2]][i] + } + if (!data["sum"]) { + var sum = 0, max = 0, min = 0, end = 0 + keys = keys.concat(["sum", "max", "min", "end"]) + data["sum"] = [] + data["max"] = [] + data["min"] = [] + data["end"] = [] + for (var i = 0; i < nrow; i++) { + max = sum + data[keys[1]][i] + min = sum - data[keys[2]][i] + end = sum + data[keys[1]][i] - data[keys[2]][i] + data["sum"].push(sum) + data["max"].push(max) + data["min"].push(min) + data["end"].push(end) + sum = end + } + } + + for (var i = 0; i < nrow; i++) { + if (data["sum"][i] < data["end"][i]) { + canvas.moveTo(step*i, data["min"][i]/total*height) + canvas.lineTo(step*i, data["sum"][i]/total*height) + + canvas.moveTo(step*i, data["max"][i]/total*height) + canvas.lineTo(step*i, data["end"][i]/total*height) + } else { + canvas.moveTo(step*i, data["min"][i]/total*height) + canvas.lineTo(step*i, data["end"][i]/total*height) + + canvas.moveTo(step*i, data["max"][i]/total*height) + canvas.lineTo(step*i, data["sum"][i]/total*height) + } + } + canvas.strokeStyle = conf.data.style + canvas.lineWidth = conf.data.width + canvas.stroke() + }, + show: function(p) { + index = parseInt(p.x/step) + canvas.moveTo(p.x, -space) + canvas.lineTo(p.x, height) + canvas.moveTo(-space, p.y) + canvas.lineTo(width, p.y) + return p + }, + }, stick: { draw: function() { what.drawAxies().drawXLabel(step) @@ -1212,9 +1270,12 @@ function Canvas(plugin, output, width, height, space, msg) { p.x += conf.plabel.offset p.y -= conf.plabel.offset + if (width - p.x < 200) { + p.x -= 200 + } canvas.fillText("index: "+index, p.x, -p.y+conf.plabel.height) - msg.append.forEach(function(key, i, n) { - msg[key][index] && canvas.fillText(key+": "+msg[key][index], p.x, -p.y+(i+2)*conf.plabel.height) + keys.forEach(function(key, i) { + data[key][index] && canvas.fillText(key+": "+data[key][index], p.x, -p.y+(i+2)*conf.plabel.height) }) canvas.restore() return what @@ -1379,6 +1440,7 @@ function Canvas(plugin, output, width, height, space, msg) { }, trans: { "折线图": ["type", "trend"], + "股价图": ["type", "ticket"], "柱状图": ["type", "stick"], "饼状图": ["type", "weight"], @@ -1459,7 +1521,7 @@ function Canvas(plugin, output, width, height, space, msg) { } var action = kit.AppendAction(kit.AppendChild(output, [{view: ["action"]}]).last, [ - ["折线图", "柱状图", "饼状图"], + ["折线图", "股价图", "柱状图", "饼状图"], ["移动", "旋转", "缩放"], ["文本", "直线", "折线", "矩形", "圆形", "椭圆"], ["辅助点", "辅助线"],