我想使用 CSS 创建一个半饼图,我有一个代码,我使用数据库中的数据调整图形,槽{{temp_f}}
。问题是我必须刷新页面才能看到更改。我一直在寻找 jquery ajax 来自动更新数据,但找不到解决方案。有人知道怎么做吗?
.pie {
margin: auto;
position: relative;
width: 200px;
height: 100px;
border-radius: 200px 200px 0 0;
overflow: hidden;
}
.pie::after {
transform: rotate( {{temp_x}}deg); /* set rotation degree */
background: linear-gradient(to right, rgba(51, 102, 255, 1) 50%, rgba(255, 0, 0, 1) 100%);
transform-origin: center bottom;
}
.pie::before {
border: 2px solid black;
}
.pie .overlay {
top: 8px; /* match border width */
left: 8px; /* match border width */
width: calc(100% - 16px); /* match border width times 2 */
height: calc(200% - 10px); /* match border width times 2 */
border-radius: 100%;
background: #062F43;
z-index: 1; /* move it on top of the pseudo elements */
}
.pie *,
.pie::before,
.pie::after {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
border-radius: inherit;
box-sizing: border-box;
}
<div class="pie">
<span class="overlay"></span>
</div>