mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 17:54:52 +00:00
feat: update graphs
This commit is contained in:
parent
32232e6f47
commit
6ce7265d3e
@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div ref="dom" :style="`height:${height};width:${width};`"></div>
|
<div ref="chart" :style="`height:${height};width:${width};`"></div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {
|
import {
|
||||||
@ -27,7 +27,7 @@ import {
|
|||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import * as echarts from "echarts";
|
import * as echarts from "echarts";
|
||||||
/*global Nullable*/
|
/*global Nullable*/
|
||||||
const dom = ref<Nullable<HTMLElement>>(null);
|
const chart = ref<Nullable<HTMLElement>>(null);
|
||||||
const state = reactive<{ instanceChart: any }>({
|
const state = reactive<{ instanceChart: any }>({
|
||||||
instanceChart: null,
|
instanceChart: null,
|
||||||
});
|
});
|
||||||
@ -40,16 +40,19 @@ const props = defineProps({
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
drawEcharts();
|
setTimeout(() => {
|
||||||
window.addEventListener("resize", state.instanceChart.resize);
|
drawEcharts();
|
||||||
|
window.addEventListener("resize", state.instanceChart.resize);
|
||||||
|
}, 50);
|
||||||
});
|
});
|
||||||
function drawEcharts(): void {
|
function drawEcharts(): void {
|
||||||
if (!dom.value) {
|
if (!chart.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.instanceChart = echarts.init(dom.value, "");
|
state.instanceChart = echarts.init(chart.value, "");
|
||||||
state.instanceChart.setOption(props.option);
|
unWarp(state.instanceChart).setOption(props.option);
|
||||||
state.instanceChart.on("click", (params: any) => {
|
state.instanceChart.on("click", (params: any) => {
|
||||||
if (!props.clickEvent) {
|
if (!props.clickEvent) {
|
||||||
return;
|
return;
|
||||||
@ -57,6 +60,10 @@ function drawEcharts(): void {
|
|||||||
props.clickEvent(params);
|
props.clickEvent(params);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function unWarp(obj: any) {
|
||||||
|
return obj && (obj.__v_raw || obj.valueOf() || obj);
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.option,
|
() => props.option,
|
||||||
(opt) => {
|
(opt) => {
|
||||||
|
@ -53,6 +53,8 @@ const msg = {
|
|||||||
instance: "Instance",
|
instance: "Instance",
|
||||||
create: "Create",
|
create: "Create",
|
||||||
loading: "Loading",
|
loading: "Loading",
|
||||||
|
graphMetric: "Graph your metrics",
|
||||||
|
selectVisualization: "Select you visualization",
|
||||||
hourTip: "Select Hour",
|
hourTip: "Select Hour",
|
||||||
minuteTip: "Select Minute",
|
minuteTip: "Select Minute",
|
||||||
secondTip: "Select Second",
|
secondTip: "Select Second",
|
||||||
@ -219,7 +221,7 @@ const msg = {
|
|||||||
grade: "Grade",
|
grade: "Grade",
|
||||||
relatedTraceLogs: "Related Logs",
|
relatedTraceLogs: "Related Logs",
|
||||||
setConditions: "More Conditions",
|
setConditions: "More Conditions",
|
||||||
metricName: "Metric Name",
|
metricName: "Metric Names",
|
||||||
keywordsOfContent: "Keys Of Content",
|
keywordsOfContent: "Keys Of Content",
|
||||||
excludingKeywordsOfContent: "Exclude Keys Of Content",
|
excludingKeywordsOfContent: "Exclude Keys Of Content",
|
||||||
return: "Return",
|
return: "Return",
|
||||||
|
@ -51,6 +51,8 @@ const msg = {
|
|||||||
endpoint: "端点",
|
endpoint: "端点",
|
||||||
create: "新建",
|
create: "新建",
|
||||||
loading: "加载中",
|
loading: "加载中",
|
||||||
|
graphMetric: "用图表示你的指标",
|
||||||
|
selectVisualization: "选择你的可视化",
|
||||||
hourTip: "选择小时",
|
hourTip: "选择小时",
|
||||||
minuteTip: "选择分钟",
|
minuteTip: "选择分钟",
|
||||||
secondTip: "选择秒数",
|
secondTip: "选择秒数",
|
||||||
|
@ -20,12 +20,12 @@ limitations under the License. -->
|
|||||||
:intervalTime="appStoreWithOut.intervalTime"
|
:intervalTime="appStoreWithOut.intervalTime"
|
||||||
:data="source"
|
:data="source"
|
||||||
/>
|
/>
|
||||||
<span v-show="!source">No Data</span>
|
<span v-show="!source">{{ t("noData") }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="config">
|
<div class="config">
|
||||||
<div class="metrics item">
|
<div class="metrics item">
|
||||||
<label>Graph your metric</label>
|
<label>{{ t("graphMetric") }}</label>
|
||||||
<div class="name">Metrics Name</div>
|
<div class="name">{{ t("metricName") }}</div>
|
||||||
<Selector
|
<Selector
|
||||||
:value="states.metrics"
|
:value="states.metrics"
|
||||||
:options="metricOpts"
|
:options="metricOpts"
|
||||||
@ -46,7 +46,7 @@ limitations under the License. -->
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="visualization item">
|
<div class="visualization item">
|
||||||
<label>Select you visualization</label>
|
<label>{{ t("selectVisualization") }}</label>
|
||||||
<div class="chart-types">
|
<div class="chart-types">
|
||||||
<span
|
<span
|
||||||
v-for="(type, index) in ChartTypes"
|
v-for="(type, index) in ChartTypes"
|
||||||
@ -148,7 +148,8 @@ export default defineComponent({
|
|||||||
{ value: "service_mq_consume_count", label: "service_mq_consume_count" },
|
{ value: "service_mq_consume_count", label: "service_mq_consume_count" },
|
||||||
];
|
];
|
||||||
const source = {
|
const source = {
|
||||||
count: [1, 2, 3, 4, 5, 6, 7, 3, 4, 5, 2, 1, 6, 9],
|
count: [1, 2, 5, 4, 5, 6, 7, 3, 4, 5, 2, 1, 6, 9],
|
||||||
|
avg: [3, 2, 4, 4, 5, 6, 5, 3, 4, 1, 2, 1, 6, 10],
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
states,
|
states,
|
||||||
|
@ -26,8 +26,16 @@ const props = defineProps({
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
theme: { type: String, default: "dark" },
|
theme: { type: String, default: "light" },
|
||||||
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
||||||
|
config: {
|
||||||
|
type: Object as PropType<{
|
||||||
|
theme: string;
|
||||||
|
showBackground: boolean;
|
||||||
|
barMaxWidth: number;
|
||||||
|
}>,
|
||||||
|
default: () => ({ theme: "light", showBackground: true, barMaxWidth: 30 }),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
/*global Nullable */
|
/*global Nullable */
|
||||||
const chart = ref<Nullable<HTMLElement>>(null);
|
const chart = ref<Nullable<HTMLElement>>(null);
|
||||||
@ -72,12 +80,13 @@ function getOption() {
|
|||||||
name: i,
|
name: i,
|
||||||
type: "bar",
|
type: "bar",
|
||||||
symbol: "none",
|
symbol: "none",
|
||||||
barMaxWidth: 10,
|
barWidth: props.config.barMaxWidth,
|
||||||
stack: "总量",
|
stack: "sum",
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: 1.5,
|
width: 1.5,
|
||||||
type: "dotted",
|
type: "dotted",
|
||||||
},
|
},
|
||||||
|
showBackground: props.config.showBackground,
|
||||||
markArea:
|
markArea:
|
||||||
index === 0
|
index === 0
|
||||||
? {
|
? {
|
||||||
@ -130,13 +139,13 @@ function getOption() {
|
|||||||
color,
|
color,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: "axis",
|
trigger: "axis",
|
||||||
backgroundColor: "rgb(50,50,50)",
|
// backgroundColor: "rgb(50,50,50)",
|
||||||
textStyle: {
|
// textStyle: {
|
||||||
fontSize: 13,
|
// fontSize: 13,
|
||||||
color: "#ccc",
|
// color: "#ccc",
|
||||||
},
|
// },
|
||||||
enterable: true,
|
// enterable: true,
|
||||||
extraCssText: "max-height: 300px; overflow: auto;",
|
// extraCssText: "max-height: 300px; overflow: auto;",
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
type: "scroll",
|
type: "scroll",
|
||||||
@ -146,7 +155,7 @@ function getOption() {
|
|||||||
left: 0,
|
left: 0,
|
||||||
itemWidth: 12,
|
itemWidth: 12,
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: props.theme === "dark" ? "#fff" : "#333",
|
color: props.config.theme === "dark" ? "#fff" : "#333",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
|
@ -27,7 +27,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
type: { type: String, default: "" },
|
type: { type: String, default: "" },
|
||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
theme: { type: String, default: "dark" },
|
theme: { type: String, default: "light" },
|
||||||
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
||||||
});
|
});
|
||||||
/*global Nullable */
|
/*global Nullable */
|
||||||
|
Loading…
Reference in New Issue
Block a user