|
@@ -2,7 +2,7 @@
|
|
<div class="chart-container">
|
|
<div class="chart-container">
|
|
<div id="ring-chart" ref="chart" class="ring-chart"></div>
|
|
<div id="ring-chart" ref="chart" class="ring-chart"></div>
|
|
<!-- //圆心-->
|
|
<!-- //圆心-->
|
|
- <!-- <div id="cc" style="position: absolute;width: 5px;height: 5px;background: #ff0000"></div>-->
|
|
|
|
|
|
+ <!--<div id="cc" style="position: absolute;width: 5px;height: 5px;background: #ff0000"></div>-->
|
|
|
|
|
|
|
|
|
|
<!--<div id="ring-chart" ref="chart" class="ring-chart"-->
|
|
<!--<div id="ring-chart" ref="chart" class="ring-chart"-->
|
|
@@ -15,6 +15,12 @@
|
|
import * as echarts from 'echarts'
|
|
import * as echarts from 'echarts'
|
|
|
|
|
|
// document.body.style.overflow = 'hidden';
|
|
// document.body.style.overflow = 'hidden';
|
|
|
|
+ document.oncontextmenu = function (event) {
|
|
|
|
+ event.preventDefault(); // 阻止默认右键菜单
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // document.body.style.overflow = 'hidden';
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
chartProps: {}
|
|
chartProps: {}
|
|
})
|
|
})
|
|
@@ -163,6 +169,8 @@
|
|
const center_x = left + width / 2
|
|
const center_x = left + width / 2
|
|
const center_y = top + height / 2
|
|
const center_y = top + height / 2
|
|
|
|
|
|
|
|
+ console.log("共用圆心",center_x,center_y)
|
|
|
|
+
|
|
function init() {
|
|
function init() {
|
|
//
|
|
//
|
|
// var cc = document.getElementById("cc");
|
|
// var cc = document.getElementById("cc");
|
|
@@ -170,10 +178,11 @@
|
|
// cc.style.top = center_y + "px"
|
|
// cc.style.top = center_y + "px"
|
|
// cc.style.left = center_x + "px"
|
|
// cc.style.left = center_x + "px"
|
|
|
|
|
|
- let chartDiv = document.getElementById("ring-chart");
|
|
|
|
- chartDiv.addEventListener('touchstart', begin)
|
|
|
|
- chartDiv.addEventListener('touchmove', moving)
|
|
|
|
- chartDiv.addEventListener('touchend', stopMoving)
|
|
|
|
|
|
+ //单独注册事件
|
|
|
|
+ // let chartDiv = document.getElementById("ring-chart");
|
|
|
|
+ // chartDiv.addEventListener('touchstart', begin)
|
|
|
|
+ // chartDiv.addEventListener('touchmove', moving)
|
|
|
|
+ // chartDiv.addEventListener('touchend', stopMoving)
|
|
}
|
|
}
|
|
|
|
|
|
function testMove(e) {
|
|
function testMove(e) {
|
|
@@ -231,52 +240,51 @@
|
|
// }
|
|
// }
|
|
|
|
|
|
function begin(event) {
|
|
function begin(event) {
|
|
- console.log("=====", props.chartProps.status)
|
|
|
|
|
|
+ console.log("2222")
|
|
|
|
+ if (!props.chartProps.power) return;
|
|
if (!event.targetTouches || event.targetTouches.length === 0) return;
|
|
if (!event.targetTouches || event.targetTouches.length === 0) return;
|
|
//鼠标按下,取点
|
|
//鼠标按下,取点
|
|
let mouse_x = event.targetTouches[0].pageX;
|
|
let mouse_x = event.targetTouches[0].pageX;
|
|
let mouse_y = event.targetTouches[0].pageY;
|
|
let mouse_y = event.targetTouches[0].pageY;
|
|
if (props.chartProps.status == 'edit' && isFinish.value == true) {
|
|
if (props.chartProps.status == 'edit' && isFinish.value == true) {
|
|
//
|
|
//
|
|
- console.log(mouse_x,"11111",mouse_x)
|
|
|
|
- //
|
|
|
|
//计算一下离谁比较近
|
|
//计算一下离谁比较近
|
|
- let d_begin = Math.pow((beginPoint.value.x - mouse_x),2)+ Math.pow((beginPoint.value.y - mouse_y),2)
|
|
|
|
- let d_end = Math.pow((endPoint.value.x - mouse_x),2)+ Math.pow((endPoint.value.y - mouse_y),2)
|
|
|
|
- if(d_begin <= d_end){
|
|
|
|
|
|
+ let d_begin = Math.pow((beginPoint.value.x - mouse_x), 2) + Math.pow((beginPoint.value.y - mouse_y), 2)
|
|
|
|
+ let d_end = Math.pow((endPoint.value.x - mouse_x), 2) + Math.pow((endPoint.value.y - mouse_y), 2)
|
|
|
|
+ if (d_begin <= d_end) {
|
|
let ang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
let ang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
option.value.series[0].startAngle = 180 - ang
|
|
option.value.series[0].startAngle = 180 - ang
|
|
beginCorner.value = ang
|
|
beginCorner.value = ang
|
|
- beginPoint.value ={
|
|
|
|
- x : mouse_x,
|
|
|
|
- y : mouse_y
|
|
|
|
|
|
+ beginPoint.value = {
|
|
|
|
+ x: mouse_x,
|
|
|
|
+ y: mouse_y
|
|
}
|
|
}
|
|
//
|
|
//
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
let eang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
let eang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
option.value.series[0].data[0].value = (eang - beginCorner.value) * 5 / 9 + beginCorner.value / 30
|
|
option.value.series[0].data[0].value = (eang - beginCorner.value) * 5 / 9 + beginCorner.value / 30
|
|
option.value.series[0].data[1].value = 100 - (eang - beginCorner.value) * 5 / 9 - beginCorner.value / 30
|
|
option.value.series[0].data[1].value = 100 - (eang - beginCorner.value) * 5 / 9 - beginCorner.value / 30
|
|
endCorner.value = eang
|
|
endCorner.value = eang
|
|
- endPoint.value ={
|
|
|
|
- x : mouse_x,
|
|
|
|
- y : mouse_y
|
|
|
|
|
|
+ endPoint.value = {
|
|
|
|
+ x: mouse_x,
|
|
|
|
+ y: mouse_y
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if (props.chartProps.status == 'new') {
|
|
|
|
|
|
+ } else if (props.chartProps.status == 'new' && !isFinish.value) {
|
|
let ang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
let ang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
beginCorner.value = ang
|
|
beginCorner.value = ang
|
|
beginPoint.value = {
|
|
beginPoint.value = {
|
|
x: mouse_x,
|
|
x: mouse_x,
|
|
y: mouse_y
|
|
y: mouse_y
|
|
}
|
|
}
|
|
- console.log("ssss",beginPoint.value.x,beginPoint.value.y)
|
|
|
|
option.value.series[0].startAngle = 180 - ang
|
|
option.value.series[0].startAngle = 180 - ang
|
|
isBegin.value = true
|
|
isBegin.value = true
|
|
}
|
|
}
|
|
myChart.setOption(option.value)
|
|
myChart.setOption(option.value)
|
|
}
|
|
}
|
|
|
|
|
|
- function stopMoving() {
|
|
|
|
|
|
+ function stopMoving(event) {
|
|
|
|
+ if (!props.chartProps.power) return;
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
isFinish.value = true
|
|
isFinish.value = true
|
|
isBegin.value = false
|
|
isBegin.value = false
|
|
@@ -287,9 +295,11 @@
|
|
|
|
|
|
function finish() {
|
|
function finish() {
|
|
//alert("绘制完成!")
|
|
//alert("绘制完成!")
|
|
|
|
+ console.log("ffffffffffffffffffffff")
|
|
}
|
|
}
|
|
|
|
|
|
function moving(event) {
|
|
function moving(event) {
|
|
|
|
+ if (!props.chartProps.power) return;
|
|
let mouse_x = event.targetTouches[0].pageX;
|
|
let mouse_x = event.targetTouches[0].pageX;
|
|
let mouse_y = event.targetTouches[0].pageY;
|
|
let mouse_y = event.targetTouches[0].pageY;
|
|
let eang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
let eang = calculateAngleDegrees(mouse_x, mouse_y, center_x, center_y)
|
|
@@ -329,6 +339,13 @@
|
|
//
|
|
//
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
+ defineExpose({
|
|
|
|
+ finish,
|
|
|
|
+ begin,
|
|
|
|
+ moving,
|
|
|
|
+ stopMoving
|
|
|
|
+ })
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
@@ -340,6 +357,7 @@
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
align-items: center;
|
|
justify-content: center;
|
|
justify-content: center;
|
|
|
|
+ /*border: 1px solid white;*/
|
|
}
|
|
}
|
|
|
|
|
|
.ring-chart {
|
|
.ring-chart {
|
|
@@ -347,6 +365,13 @@
|
|
height: 910px;
|
|
height: 910px;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
margin-top: 219px;
|
|
margin-top: 219px;
|
|
|
|
+ border: 1px solid white;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ body {
|
|
|
|
+ overscroll-behavior: none; /* 禁用滑动返回 */
|
|
|
|
+ touch-action: pan-y; /* 仅允许垂直滚动 */
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|