forked from x/ContextOS
add ticket.canvas.js
This commit is contained in:
parent
07061b3622
commit
10cf54168f
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-07-08 16:56:13", "ZYB-20190522USI", 122,
|
"2019-07-08 23:23:11", "com.mac", 57,
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
"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 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: ") {
|
for _, v := range strings.Split(string(out), "commit: ") {
|
||||||
if l := strings.Split(v, "\n"); len(l) > 2 {
|
if l := strings.Split(v, "\n"); len(l) > 2 {
|
||||||
fs := strings.Split(strings.TrimSpace(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")
|
m.Cmdy("nfs.dir", "src", "filename", "line", "size", "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if arg[0] == "git" {
|
||||||
|
m.Cmdy("nfs.git", "sum")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
m.Append("text", m.Time())
|
m.Append("text", m.Time())
|
||||||
m.Append("style", map[int]string{
|
m.Append("style", map[int]string{
|
||||||
|
@ -854,7 +854,7 @@ function Canvas(plugin, output, width, height, space, msg) {
|
|||||||
var list = []
|
var list = []
|
||||||
msg[key].forEach(function(value, index) {
|
msg[key].forEach(function(value, index) {
|
||||||
var v = parseInt(value)
|
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++)
|
list.length == nrow && (keys.push(key), data[key] = list, nline++)
|
||||||
})
|
})
|
||||||
@ -1072,6 +1072,64 @@ function Canvas(plugin, output, width, height, space, msg) {
|
|||||||
return p
|
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: {
|
stick: {
|
||||||
draw: function() {
|
draw: function() {
|
||||||
what.drawAxies().drawXLabel(step)
|
what.drawAxies().drawXLabel(step)
|
||||||
@ -1212,9 +1270,12 @@ function Canvas(plugin, output, width, height, space, msg) {
|
|||||||
p.x += conf.plabel.offset
|
p.x += conf.plabel.offset
|
||||||
p.y -= 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)
|
canvas.fillText("index: "+index, p.x, -p.y+conf.plabel.height)
|
||||||
msg.append.forEach(function(key, i, n) {
|
keys.forEach(function(key, i) {
|
||||||
msg[key][index] && canvas.fillText(key+": "+msg[key][index], p.x, -p.y+(i+2)*conf.plabel.height)
|
data[key][index] && canvas.fillText(key+": "+data[key][index], p.x, -p.y+(i+2)*conf.plabel.height)
|
||||||
})
|
})
|
||||||
canvas.restore()
|
canvas.restore()
|
||||||
return what
|
return what
|
||||||
@ -1379,6 +1440,7 @@ function Canvas(plugin, output, width, height, space, msg) {
|
|||||||
},
|
},
|
||||||
trans: {
|
trans: {
|
||||||
"折线图": ["type", "trend"],
|
"折线图": ["type", "trend"],
|
||||||
|
"股价图": ["type", "ticket"],
|
||||||
"柱状图": ["type", "stick"],
|
"柱状图": ["type", "stick"],
|
||||||
"饼状图": ["type", "weight"],
|
"饼状图": ["type", "weight"],
|
||||||
|
|
||||||
@ -1459,7 +1521,7 @@ function Canvas(plugin, output, width, height, space, msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var action = kit.AppendAction(kit.AppendChild(output, [{view: ["action"]}]).last, [
|
var action = kit.AppendAction(kit.AppendChild(output, [{view: ["action"]}]).last, [
|
||||||
["折线图", "柱状图", "饼状图"],
|
["折线图", "股价图", "柱状图", "饼状图"],
|
||||||
["移动", "旋转", "缩放"],
|
["移动", "旋转", "缩放"],
|
||||||
["文本", "直线", "折线", "矩形", "圆形", "椭圆"],
|
["文本", "直线", "折线", "矩形", "圆形", "椭圆"],
|
||||||
["辅助点", "辅助线"],
|
["辅助点", "辅助线"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user