Skip to content

Commit

Permalink
修改 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhhuse committed Dec 21, 2021
1 parent a442233 commit 333ca11
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 73 deletions.
1 change: 0 additions & 1 deletion src/views/density/DisplayDensity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
v-model="loading"
:finished="loadFinished"
finished-text="没有更多了"
@load="onLoad"
>
<van-swipe-cell v-for="item in densityList" :key="item.measureTime">
<van-cell :title="item.measureTime" :title-style="'text-align: left;'" :value="item.measureValue" />
Expand Down
63 changes: 33 additions & 30 deletions src/views/density/components/ScaleChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import F2 from "@antv/f2/lib/index-all";
import { HttpMessage } from "@/types";
import { PieType, PieTypeRender } from "@/types/density";
import { getScaleDensityAction } from "@/action/density";
import { nextTick } from "vue";
export default defineComponent({
setup() {
Expand Down Expand Up @@ -50,39 +51,41 @@ export default defineComponent({
() => {
nullValueCheck(data.value);
if (!isNullData.value) {
const chart = new F2.Chart({
id: container.value,
height: 200,
pixelRatio: window.devicePixelRatio,
});
nextTick(() => {
const chart = new F2.Chart({
id: container.value,
height: 200,
pixelRatio: window.devicePixelRatio,
});
chart.source(data.value);
chart.coord("polar", {
transposed: true,
radius: 0.75,
});
chart.legend(false);
chart.axis(false);
chart.tooltip(false);
chart.source(data.value);
chart.coord("polar", {
transposed: true,
radius: 0.75,
});
chart.legend(false);
chart.axis(false);
chart.tooltip(false);
// 添加饼图文本
chart.pieLabel({
sidePadding: 10,
lineHeight: 16,
label1: function label1(data, color) {
return {
text: data.name,
fill: color,
};
},
});
// 添加饼图文本
chart.pieLabel({
sidePadding: 10,
lineHeight: 16,
label1: function label1(data, color) {
return {
text: data.name,
fill: color,
};
},
});
chart
.interval()
.position("const*value")
.color("name", ["#3B82F6", "#10B981", "#6366F1", "#F59E0B", "#DC2626"])
.adjust("stack");
chart.render();
chart
.interval()
.position("const*value")
.color("name", ["#3B82F6", "#10B981", "#6366F1", "#F59E0B", "#DC2626"])
.adjust("stack");
chart.render();
});
}
},
);
Expand Down
84 changes: 43 additions & 41 deletions src/views/density/components/StatsChart.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div v-if="!loading">
<div v-show="!loading">
<canvas v-if="data.length" ref="cLine" />
<van-empty v-else class="custom-image" description="请添加血值记录" />
</div>
<van-loading v-else type="spinner" class="text-center" />
<van-loading v-show="loading" type="spinner" class="text-center" />
</template>

<script lang="ts">
import { defineComponent, ref, onMounted, watch } from "@vue/runtime-core";
import { defineComponent, ref, onMounted, watch, nextTick } from "@vue/runtime-core";
import F2 from "@antv/f2/lib/index-all";
import { getLatestDensityAction } from "@/action/density";
import { HttpMessage } from "@/types/index";
Expand Down Expand Up @@ -39,46 +39,48 @@ export default defineComponent({
watch(
() => data.value,
() => {
if (data.value.length) {
const chart = new F2.Chart({
id: cLine.value,
pixelRatio: window.devicePixelRatio,
});
if (data.value.length > 0) {
nextTick(() => {
const chart = new F2.Chart({
id: cLine.value,
pixelRatio: window.devicePixelRatio,
});
chart.source(data.value, {
value: {
tickCount: 5,
min: 0,
},
date: {
type: "timeCat",
range: [0, 1],
tickCount: 3,
},
});
chart.tooltip({
custom: true,
showXTip: true,
showYTip: true,
snap: true,
crosshairsType: "xy",
crosshairsStyle: {
lineDash: [2],
},
});
chart.axis("date", {
label: function label(text, index, total) {
const textCfg = {} as any;
if (index === 0) {
textCfg.textAlign = "left";
} else if (index === total - 1) {
textCfg.textAlign = "right";
}
return textCfg;
},
chart.source(data.value, {
value: {
tickCount: 5,
min: 0,
},
date: {
type: "timeCat",
range: [0, 1],
tickCount: 3,
},
});
chart.tooltip({
custom: true,
showXTip: true,
showYTip: true,
snap: true,
crosshairsType: "xy",
crosshairsStyle: {
lineDash: [2],
},
});
chart.axis("date", {
label: function label(text, index, total) {
const textCfg = {} as any;
if (index === 0) {
textCfg.textAlign = "left";
} else if (index === total - 1) {
textCfg.textAlign = "right";
}
return textCfg;
},
});
chart.line().position("date*value");
chart.render();
});
chart.line().position("date*value");
chart.render();
}
},
);
Expand Down
3 changes: 3 additions & 0 deletions src/views/density/hooks/useDensity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default function useDensity(): any {
() => {
fetchDensityList(limit.value, size.value);
},
{
immediate: true,
},
);

return {
Expand Down
4 changes: 3 additions & 1 deletion src/views/food/Food.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<van-icon name="bell" size="18" @click="onClickRight" />
</template>
</van-nav-bar>
<div>Food</div>
<div>
<van-search v-model="value" shape="round" background="#4fc08d" placeholder="请输入搜索关键词" />
</div>
</template>
<script lang="ts">
import { defineComponent, SetupContext } from "@vue/runtime-core";
Expand Down

0 comments on commit 333ca11

Please sign in to comment.