Skip to content

Commit

Permalink
fix: 删除课评缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
konodioda727 committed Nov 19, 2024
1 parent cc62782 commit ddf4c18
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions src/common/components/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,23 @@ const LineChart: React.FC<LineChartProps> = (props) => {
}, []);
const drawLineChart = () => {
const query = Taro.createSelectorQuery();
query
.select(`#${id ?? DEFAULT_CHART_ID}`)
.fields({ node: true, size: true })
.exec((res) => {
const dpr = Taro.getSystemInfoSync().pixelRatio;
const canvas = res[0].node as CanvasInterface;
const { width, height } = canvas;
canvas.width = width * dpr;
canvas.height = height * dpr;
// 设置 canvas 组件的样式宽高
setSize({ x: width ?? 200, y: height ?? 200 });
const ctx = canvas.getContext('2d') as CanvasContext;
ctx.scale(dpr, dpr);
drawChart(ctx);
});
setTimeout(() => {
query
.select(`#${id ?? DEFAULT_CHART_ID}`)
.fields({ node: true, size: true })
.exec((res) => {
const dpr = Taro.getSystemInfoSync().pixelRatio;
const canvas = res[0].node as CanvasInterface;
const { width, height } = canvas;
canvas.width = width * dpr;
canvas.height = height * dpr;
// 设置 canvas 组件的样式宽高
setSize({ x: width ?? 200, y: height ?? 200 });
const ctx = canvas.getContext('2d') as CanvasContext;
ctx.scale(dpr, dpr);
drawChart(ctx);
});
}, 200);
};

const drawChart = (ctx: CanvasContext) => {
Expand Down Expand Up @@ -178,14 +180,15 @@ const LineChart: React.FC<LineChartProps> = (props) => {
return (
<Canvas
id={id ?? DEFAULT_CHART_ID}
width={(size?.x ?? DEFAULT_WIDTH + 'px') as string}
height={(size?.y ?? DEFAULT_HEIGHT + 'px') as string}
// width={(size?.x ?? DEFAULT_WIDTH + 'px') as string}
// height={(size?.y ?? DEFAULT_HEIGHT + 'px') as string}
className={className}
style={{
...style,
...{
width: `${propWidth ?? DEFAULT_WIDTH}px`,
height: `${propHeight ?? DEFAULT_HEIGHT}px`,
flex: 1,
},
}}
type="2d"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/classInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function Index() {
<Label3 key={keyindex} content={feature} />
))}
</View>
<View className="h-1/3 pt-1.5">
<View className="mx-auto flex w-[90%] pt-1.5">
<LineChart
className="mx-auto text-center"
data={yData}
Expand Down

0 comments on commit ddf4c18

Please sign in to comment.