From 52b00f9a97de5fd01ec05a763b5efc822f71755a Mon Sep 17 00:00:00 2001 From: BingBlog Date: Sat, 6 Jan 2018 18:18:44 +0800 Subject: [PATCH] frontend add graph (#63) * fix the tooltip index error * frontend add graph --- frontend/mock/data/plugin/graphs/graphs.js | 115 +++++++++++++++++++++ frontend/src/common/component/AppMenu.san | 5 + frontend/src/graph/Graph.san | 92 +++++++++++++++++ frontend/src/graph/index.js | 9 ++ frontend/src/graph/ui/chart.san | 73 +++++++++++++ frontend/src/graph/ui/config.san | 68 ++++++++++++ frontend/src/histogram/ui/config.san | 6 +- frontend/src/images/ui/config.san | 6 +- frontend/src/index.js | 1 + frontend/src/scalars/ui/config.san | 2 +- frontend/src/service.js | 2 + 11 files changed, 372 insertions(+), 7 deletions(-) create mode 100644 frontend/mock/data/plugin/graphs/graphs.js create mode 100644 frontend/src/graph/Graph.san create mode 100644 frontend/src/graph/index.js create mode 100644 frontend/src/graph/ui/chart.san create mode 100644 frontend/src/graph/ui/config.san diff --git a/frontend/mock/data/plugin/graphs/graphs.js b/frontend/mock/data/plugin/graphs/graphs.js new file mode 100644 index 00000000..6097e8be --- /dev/null +++ b/frontend/mock/data/plugin/graphs/graphs.js @@ -0,0 +1,115 @@ +/** + * get mock data + * + * @param {string} path request path + * @param {Object} queryParam query params + * @param {Object} postParam post params + * @return {Object} + */ +module.exports = function (path, queryParam, postParam) { + return { + // moock delay + _timeout: 0, + // mock http status + _status: 200, + // mock response data + _data: { + status: 0, + msg: 'SUCCESS', + data: { + title: { + text: 'Graph 简单示例' + }, + tooltip: {}, + animationDurationUpdate: 1500, + animationEasingUpdate: 'quinticInOut', + series : [ + { + type: 'graph', + layout: 'none', + symbolSize: 50, + roam: true, + label: { + normal: { + show: true + } + }, + edgeSymbol: ['circle', 'arrow'], + edgeSymbolSize: [4, 10], + edgeLabel: { + normal: { + textStyle: { + fontSize: 20 + } + } + }, + data: [{ + name: '节点1', + x: 300, + y: 300 + }, { + name: '节点2', + x: 800, + y: 300 + }, { + name: '节点3', + x: 550, + y: 100 + }, { + name: '节点4', + x: 550, + y: 500 + }], + // links: [], + links: [{ + source: 0, + target: 1, + symbolSize: [5, 20], + label: { + normal: { + show: true + } + }, + lineStyle: { + normal: { + width: 5, + curveness: 0.2 + } + } + }, { + source: '节点2', + target: '节点1', + label: { + normal: { + show: true + } + }, + lineStyle: { + normal: { curveness: 0.2 } + } + }, { + source: '节点1', + target: '节点3' + }, { + source: '节点2', + target: '节点3' + }, { + source: '节点2', + target: '节点4' + }, { + source: '节点1', + target: '节点4' + }], + lineStyle: { + normal: { + opacity: 0.9, + width: 2, + curveness: 0 + } + } + } + ] + } + } + }; +}; diff --git a/frontend/src/common/component/AppMenu.san b/frontend/src/common/component/AppMenu.san index 8a31cce8..2538a327 100644 --- a/frontend/src/common/component/AppMenu.san +++ b/frontend/src/common/component/AppMenu.san @@ -39,6 +39,11 @@ export default { url: '/histograms', title: 'HISTOGRAMS', name: 'histograms' + }, + { + url: '/graphs', + title: 'GRAPHS', + name: 'graphs' } ] }; diff --git a/frontend/src/graph/Graph.san b/frontend/src/graph/Graph.san new file mode 100644 index 00000000..5b7cb235 --- /dev/null +++ b/frontend/src/graph/Graph.san @@ -0,0 +1,92 @@ + + + + + diff --git a/frontend/src/graph/index.js b/frontend/src/graph/index.js new file mode 100644 index 00000000..4f76411c --- /dev/null +++ b/frontend/src/graph/index.js @@ -0,0 +1,9 @@ +import {router} from 'san-router'; + +import Graph from './Graph'; + +router.add({ + target: '#content', + rule: '/graphs', + Component: Graph +}); diff --git a/frontend/src/graph/ui/chart.san b/frontend/src/graph/ui/chart.san new file mode 100644 index 00000000..593186f0 --- /dev/null +++ b/frontend/src/graph/ui/chart.san @@ -0,0 +1,73 @@ + + + diff --git a/frontend/src/graph/ui/config.san b/frontend/src/graph/ui/config.san new file mode 100644 index 00000000..89f218d4 --- /dev/null +++ b/frontend/src/graph/ui/config.san @@ -0,0 +1,68 @@ + + + diff --git a/frontend/src/histogram/ui/config.san b/frontend/src/histogram/ui/config.san index 6b4986e0..b48f245f 100644 --- a/frontend/src/histogram/ui/config.san +++ b/frontend/src/histogram/ui/config.san @@ -1,5 +1,5 @@