From 16085bb56f84941454aea5de8e30ff31e4d10d55 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Wed, 12 Jan 2022 14:30:45 +0800 Subject: [PATCH] feat: add custom config for Bar, Line, Area --- src/types/dashboard.ts | 16 +++++-- .../dashboard/configuration/ConfigEdit.vue | 19 ++++++-- .../configuration/graph-styles/Area.vue | 28 ++++++----- .../configuration/graph-styles/Bar.vue | 21 +++++++-- .../configuration/graph-styles/Line.vue | 46 +++++++++++++------ .../configuration/graph-styles/types.ts | 20 -------- src/views/dashboard/data.ts | 8 ++-- src/views/dashboard/graphs/Area.vue | 7 ++- src/views/dashboard/graphs/Bar.vue | 11 ++--- src/views/dashboard/graphs/Line.vue | 18 ++++++-- 10 files changed, 121 insertions(+), 73 deletions(-) delete mode 100644 src/views/dashboard/configuration/graph-styles/types.ts diff --git a/src/types/dashboard.ts b/src/types/dashboard.ts index f4fee79b..c4de6c37 100644 --- a/src/types/dashboard.ts +++ b/src/types/dashboard.ts @@ -41,14 +41,20 @@ export interface StandardConfig { min?: string; } -export type GraphConfig = BarConfig | LineConfig; -interface BarConfig { +type GraphConfig = BarConfig | LineConfig; +export interface BarConfig { type?: string; showBackground?: boolean; barWidth?: number; } -interface LineConfig { +export interface LineConfig extends AreaConfig { type?: string; - showBackground?: boolean; - barWidth?: number; + smooth?: boolean; + showSymbol?: boolean; + step?: boolean; +} + +export interface AreaConfig { + type?: string; + opacity?: number; } diff --git a/src/views/dashboard/configuration/ConfigEdit.vue b/src/views/dashboard/configuration/ConfigEdit.vue index 337f6614..488cc363 100644 --- a/src/views/dashboard/configuration/ConfigEdit.vue +++ b/src/views/dashboard/configuration/ConfigEdit.vue @@ -21,6 +21,7 @@ limitations under the License. --> :is="states.chartType" :intervalTime="appStoreWithOut.intervalTime" :data="states.source" + :config="states.graph" />
{{ t("noData") }}
@@ -66,7 +67,11 @@ limitations under the License. --> - + d.value + (d: { value: number }) => d.value + 1 ); const m = states.metrics[0]; if (!m) { @@ -270,7 +283,7 @@ export default defineComponent({ metricOpts, updateWidgetOptions, configHeight, - dashboardStore, + updateGraphOptions, applyConfig, loading, }; diff --git a/src/views/dashboard/configuration/graph-styles/Area.vue b/src/views/dashboard/configuration/graph-styles/Area.vue index a5ecc100..44950f8a 100644 --- a/src/views/dashboard/configuration/graph-styles/Area.vue +++ b/src/views/dashboard/configuration/graph-styles/Area.vue @@ -14,32 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. -->