Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
chart-project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
czj
chart-project
Commits
02b21257
提交
02b21257
authored
12月 07, 2023
作者:
祖铭松
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Feature Plot
上级
ce04e1f5
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
552 行增加
和
179 行删除
+552
-179
chart.vue
src/components/FeaturePlot/components/chart.vue
+143
-0
config.vue
src/components/FeaturePlot/components/config.vue
+158
-0
index.vue
src/components/FeaturePlot/index.vue
+17
-0
index.js
src/components/FeaturePlot/utils/index.js
+143
-0
mock.js
src/components/FeaturePlot/utils/mock.js
+0
-0
chart.vue
src/components/MsDimplot/components/chart.vue
+84
-82
config.vue
src/components/MsDimplot/components/config.vue
+7
-97
mock.js
src/components/MsDimplot/mock.js
+0
-0
index.js
src/components/MsDimplot/utils/index.js
+0
-0
mock.js
src/components/MsDimplot/utils/mock.js
+0
-0
index.vue
src/components/Test/index.vue
+0
-0
mock.js
src/components/Test/mock.js
+0
-0
utils.js
src/components/Test/utils.js
+0
-0
index.vue
src/views/home/index.vue
+0
-0
没有找到文件。
src/components/FeaturePlot/components/chart.vue
0 → 100644
浏览文件 @
02b21257
<
template
>
<div
ref=
"chartRef"
class=
"chart-box"
>
<div
class=
"tip"
></div>
</div>
</
template
>
<
script
setup
>
import
{
ref
,
onMounted
,
onUnmounted
}
from
'vue'
;
import
*
as
d3
from
'https://cdn.jsdelivr.net/npm/d3@7/+esm'
;
import
{
chartMockData
}
from
'../utils/mock'
;
import
{
setTips
,
setMaxMinNumber
,
coordinateScale
,
setColor
,
setCluster
,
setLegend
,
setLabel
}
from
'../utils/index'
;
import
PubSub
from
'pubsub-js'
;
// 根节点实例
const
chartRef
=
ref
(
null
);
// 配置项数据
const
options
=
ref
({});
// pubsub实例
const
pubSubInstance
=
ref
(
null
);
// 图表实例
const
svgInstance
=
ref
(
null
);
// 生成图表
const
generateChart
=
()
=>
{
const
ret
=
options
.
value
;
let
width
=
Number
(
ret
.
chart_width
)
||
500
;
let
height
=
Number
(
ret
.
chart_height
)
||
1200
;
let
marginTop
=
Number
(
ret
.
margin_top
)
||
30
;
let
marginRight
=
Number
(
ret
.
margin_right
)
||
30
;
let
marginBottom
=
Number
(
ret
.
margin_bottom
)
||
30
;
let
marginLeft
=
Number
(
ret
.
margin_left
)
||
30
;
let
radius
=
Number
(
ret
.
point_radius
)
||
4
;
let
rectHeight
=
300
;
let
colorList
=
[
[
'#E53935'
,
'#1E88E5'
],
[
'#AA40FC'
,
'#FFBB78'
],
[
'#17BECF'
,
'#E377C2'
]
];
let
titles
=
[
'UMAP1'
,
'UMAP2'
];
let
labels
=
[
'main_cluster_id_0.4'
,
'celltype'
,
'sample_id'
];
const
titleConfig
=
{
label
:
!!
ret
.
title
?
ret
.
title
:
null
,
color
:
ret
.
title_font_color
||
'#333333'
,
fontSize
:
ret
.
title_font_size
||
20
,
fontStyle
:
ret
.
title_font_style
?
'oblique'
:
'normal'
,
fontFamily
:
ret
.
title_font_family
||
'Arial'
,
fontWeight
:
ret
.
title_font_weight
?
'bold'
:
'normal'
};
const
svg
=
d3
.
create
(
'svg'
).
attr
(
'width'
,
width
).
attr
(
'height'
,
height
);
let
configObj
=
{
svg
,
width
,
height
,
marginTop
,
marginRight
,
marginBottom
,
marginLeft
,
radius
,
rectHeight
,
titleConfig
,
titles
,
labels
,
colorList
};
let
chartArr
=
[
chartMockData
,
chartMockData
,
chartMockData
];
for
(
let
i
=
0
;
i
<
chartArr
.
length
;
i
++
)
{
setChart
(
configObj
,
chartArr
[
i
],
i
);
}
svgInstance
.
value
=
svg
.
node
();
// Append the SVG element.
chartRef
.
value
.
appendChild
(
svgInstance
.
value
);
};
const
setChart
=
(
config
,
data
,
index
)
=>
{
let
position
=
{
rect
:
[
config
.
marginLeft
,
(
config
.
rectHeight
+
80
)
*
index
+
config
.
marginTop
],
cluster
:
[
0
,
(
config
.
rectHeight
+
80
)
*
index
],
titleTop
:
[
config
.
width
/
2
,
(
config
.
rectHeight
+
80
)
*
index
+
20
],
titleBottom
:
[
config
.
width
/
2
,
(
config
.
rectHeight
+
80
)
*
index
+
config
.
rectHeight
+
50
],
titleLeft
:
[
-
config
.
rectHeight
/
2
-
(
config
.
rectHeight
+
80
)
*
index
,
20
]
};
config
.
svg
.
append
(
'rect'
)
.
attr
(
'x'
,
position
.
rect
[
0
])
.
attr
(
'y'
,
position
.
rect
[
1
])
.
attr
(
'width'
,
config
.
width
-
config
.
marginTop
-
config
.
marginRight
)
.
attr
(
'height'
,
config
.
rectHeight
)
.
attr
(
'stroke'
,
'#111111'
)
.
attr
(
'fill'
,
'white'
);
const
{
paddedMin
,
paddedMax
}
=
setMaxMinNumber
(
data
);
let
label
=
config
.
labels
[
index
];
let
colors
=
config
.
colorList
[
index
];
let
configObj
=
{
...
config
,
paddedMin
,
paddedMax
,
position
,
label
,
colors
};
const
{
x
,
y
}
=
coordinateScale
(
configObj
,
data
);
const
color
=
setColor
(
configObj
);
configObj
=
{
...
configObj
,
x
,
y
,
color
};
const
cluster
=
setCluster
(
configObj
,
data
);
setTips
(
cluster
);
// label
setLabel
(
configObj
);
};
onMounted
(()
=>
{
pubSubInstance
.
value
=
PubSub
.
subscribe
(
'options'
,
(
m
,
data
)
=>
{
options
.
value
=
data
;
chartRef
.
value
.
removeChild
(
svgInstance
.
value
);
generateChart
();
});
generateChart
();
});
onUnmounted
(()
=>
{
PubSub
.
unsubscribe
(
pubSubInstance
.
value
);
});
</
script
>
<
style
scoped
>
.chart-box
{
position
:
relative
;
}
</
style
>
src/components/FeaturePlot/components/config.vue
0 → 100644
浏览文件 @
02b21257
<
template
>
<div
class=
"form-container"
>
<h3
class=
"type content"
>
画布
</h3>
<div
class=
"form-item"
>
<span>
宽:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.chart_width"
/>
</div>
<div
class=
"form-item"
>
<span>
高:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.chart_height"
/>
</div>
<div
class=
"form-item"
>
<span>
上边距:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.margin_top"
/>
</div>
<div
class=
"form-item"
>
<span>
右边距:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.margin_right"
/>
</div>
<div
class=
"form-item"
>
<span>
下边距:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.margin_bottom"
/>
</div>
<div
class=
"form-item"
>
<span>
左边距:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.margin_left"
/>
</div>
<h3
class=
"type content"
>
文本
</h3>
<div
class=
"form-item"
>
<span>
字体:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.title_font_family"
/>
</div>
<div
class=
"form-item"
>
<span>
字号:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.title_font_size"
/>
</div>
<div
class=
"form-item"
>
<span>
字体颜色:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.title_font_color"
/>
</div>
<div
class=
"form-item"
>
<span>
字体加粗:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.title_font_weight"
/>
</div>
<div
class=
"form-item"
>
<span>
斜体:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.title_font_style"
/>
</div>
<h3
class=
"type content"
>
图表配置
</h3>
<div
class=
"form-item"
>
<span>
散点半径:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.point_radius"
/>
</div>
<!--
<h3
class=
"type content"
>
图例
</h3>
<div
class=
"form-item"
>
<span>
显示图例:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_legend"
/>
</div>
-->
<div
class=
"btn"
>
<button
@
click=
"submit"
>
提交
</button>
</div>
</div>
</
template
>
<
script
setup
>
import
{
reactive
,
onMounted
}
from
'vue'
;
import
PubSub
from
'pubsub-js'
;
//动态图参数,固定参数
const
dynamic_parameter
=
reactive
({
//长宽间距
chart_width
:
500
,
chart_height
:
1200
,
margin_top
:
30
,
margin_right
:
30
,
margin_bottom
:
30
,
margin_left
:
30
,
//标题配置
title
:
''
,
title_font_family
:
'Arial'
,
title_font_weight
:
false
,
title_font_size
:
20
,
title_font_color
:
'#333333'
,
title_font_style
:
false
,
//横轴标题
xtitle_font_family
:
'Arial'
,
xtitle_font_weight
:
false
,
xtitle_font_style
:
false
,
xtitle_font_size
:
16
,
xtitle_font_color
:
'#333333'
,
//纵轴标题
ytitle_font_family
:
'Arial'
,
ytitle_font_weight
:
false
,
ytitle_font_style
:
false
,
ytitle_font_size
:
16
,
ytitle_font_color
:
'#333333'
,
//颜色设置
data_color_list
:
[
'#E53935'
,
'#1E88E5'
],
point_radius
:
4
,
// 散点图半径
//图例
show_legend
:
true
,
legend_position
:
'1,1'
,
//坐标轴
show_x_axis
:
true
,
show_x_line
:
true
,
show_x_tickMarks
:
true
,
show_x_gridLine
:
false
,
show_x_title
:
true
,
x_title
:
''
,
x_tickMarks_color
:
'#333333'
,
x_tickMarks_length
:
'5'
,
show_y_axis
:
true
,
show_y_line
:
true
,
show_y_tickMarks
:
true
,
show_y_gridLine
:
false
,
show_y_title
:
true
,
y_title
:
''
,
y_tickMarks_color
:
'#333333'
,
y_tickMarks_length
:
'5'
,
//节点相关的参数,可能还会有更多
node_id
:
null
,
//节点id
node_color
:
null
,
//节点颜色
is_delect_node
:
false
,
//是否删除节点
node_search_name
:
null
,
//节点名称搜索
node_search_color
:
'#FF0404'
,
//节点搜索后的颜色
node_edit_name
:
null
,
//修改节点名称
node_height
:
100
,
//节点大小
path_id
:
null
});
const
submit
=
()
=>
{
PubSub
.
publish
(
'options'
,
dynamic_parameter
);
};
onMounted
(()
=>
{
submit
();
});
</
script
>
<
style
scoped
>
.form-item
span
{
display
:
inline-block
;
width
:
100px
;
text-align
:
left
;
}
.btn
{
width
:
100%
;
height
:
100px
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
}
</
style
>
src/components/FeaturePlot/index.vue
0 → 100644
浏览文件 @
02b21257
<
template
>
<div
class=
"chart-container"
>
<Chart
/>
<Config
/>
</div>
</
template
>
<
script
setup
>
import
Chart
from
'./components/chart.vue'
;
import
Config
from
'./components/config.vue'
;
</
script
>
<
style
scoped
>
.chart-container
{
display
:
flex
;
}
</
style
>
src/components/FeaturePlot/utils/index.js
0 → 100644
浏览文件 @
02b21257
import
*
as
d3
from
'https://cdn.jsdelivr.net/npm/d3@7/+esm'
;
// color config
export
const
setColor
=
(
config
)
=>
{
let
colors
=
[
'#E53935'
,
'#1E88E5'
];
if
(
Array
.
isArray
(
config
.
colors
))
{
colors
=
!!
config
.
colors
.
length
?
config
.
colors
:
colors
;
}
else
if
(
!!
config
.
colors
)
{
colors
=
config
.
colors
.
split
(
','
);
}
return
d3
.
scaleOrdinal
(
colors
).
domain
(
config
.
legendData
||
[]);
};
// paddedMin paddedMax
export
const
setMaxMinNumber
=
(
data
)
=>
{
const
paddedMin
=
d3
.
min
(
data
,
(
d
)
=>
d
.
x
)
-
d3
.
min
(
data
,
(
d
)
=>
d
.
y
)
*
-
0.1
;
const
paddedMax
=
d3
.
max
(
data
,
(
d
)
=>
d
.
x
)
+
d3
.
max
(
data
,
(
d
)
=>
d
.
y
)
*
0.1
;
return
{
paddedMin
,
paddedMax
}
}
// cluster
export
const
setCluster
=
(
config
,
data
)
=>
{
return
config
.
svg
.
append
(
'g'
)
.
attr
(
'transform'
,
`translate(
${
config
.
position
.
cluster
[
0
]}
,
${
config
.
position
.
cluster
[
1
]}
)`
)
.
style
(
'isolation'
,
'isolate'
)
.
selectAll
(
'circle'
)
.
data
(
data
)
.
enter
()
.
append
(
'circle'
)
.
attr
(
'class'
,
'points'
)
.
attr
(
'cx'
,
(
d
)
=>
config
.
x
(
d
.
x
))
.
attr
(
'cy'
,
(
d
)
=>
config
.
y
(
d
.
y
))
.
attr
(
'fill'
,
(
d
)
=>
config
.
color
(
d
.
group
))
.
attr
(
'opacity'
,
0.7
)
.
attr
(
'r'
,
config
.
radius
);
}
// scale
export
const
coordinateScale
=
(
config
,
data
)
=>
{
const
x
=
d3
.
scaleLinear
()
.
domain
([
config
.
paddedMin
,
config
.
paddedMax
])
.
range
([
config
.
marginLeft
,
config
.
width
-
config
.
marginRight
]);
const
y
=
d3
.
scaleLinear
()
.
domain
(
d3
.
extent
(
data
,
(
d
)
=>
d
.
y
))
.
range
([
config
.
rectHeight
,
config
.
marginTop
+
30
]);
return
{
x
,
y
}
}
// tips
export
const
setTips
=
(
rect
)
=>
{
const
tips
=
d3
.
select
(
'.tip'
)
.
style
(
'visibility'
,
'hidden'
)
.
style
(
'position'
,
'relative'
)
.
style
(
'background-color'
,
'rgba(0, 0, 0, .8)'
)
.
style
(
'color'
,
'#fff'
)
.
style
(
'border-radius'
,
'5px'
)
.
style
(
'width'
,
'200px'
)
.
style
(
'height'
,
'45px'
)
.
style
(
'text-align'
,
'left'
)
.
style
(
'padding'
,
'5px'
)
rect
.
on
(
'mouseover'
,
(
event
,
d
)
=>
{
tips
.
style
(
'visibility'
,
'visible'
);
})
.
on
(
'mousemove'
,
function
(
event
,
d
)
{
tips
.
style
(
'visibility'
,
'visible'
)
.
style
(
'left'
,
event
.
offsetX
+
15
+
'px'
)
.
style
(
'top'
,
event
.
offsetY
+
90
+
'px'
)
.
html
(
`
<div>x:
${
d
.
x
}
</div>
<div>y:
${
d
.
y
}
</div>`
);
})
.
on
(
'mouseleave'
,
function
()
{
tips
.
style
(
'visibility'
,
'hidden'
);
});
};
// legend
export
const
setLegend
=
(
config
)
=>
{
config
.
svg
.
append
(
'g'
)
.
attr
(
'transform'
,
`translate(
${
config
.
width
-
config
.
marginLeft
-
70
}
,
${
100
}
)`
)
.
selectAll
()
.
data
(
config
.
legendData
)
.
join
(
'g'
)
.
attr
(
'transform'
,
(
d
,
i
)
=>
`translate(0,
${
i
*
20
}
)`
)
.
call
((
g
)
=>
g
.
append
(
'rect'
).
attr
(
'width'
,
15
).
attr
(
'height'
,
15
).
attr
(
'fill'
,
d
=>
config
.
color
(
d
)))
.
call
((
g
)
=>
g
.
append
(
'text'
)
.
attr
(
'x'
,
20
)
.
attr
(
'y'
,
8
)
.
attr
(
'dy'
,
'0.3em'
)
.
style
(
'font'
,
'13px sans-serif'
)
.
text
((
d
)
=>
d
)
);
};
// title
export
const
setLabel
=
(
config
)
=>
{
config
.
svg
.
append
(
'text'
)
.
attr
(
'x'
,
config
.
position
.
titleTop
[
0
])
.
attr
(
'y'
,
config
.
position
.
titleTop
[
1
])
.
attr
(
'fill'
,
config
.
titleConfig
.
color
)
.
attr
(
'font-size'
,
`
${
config
.
titleConfig
.
fontSize
}
px`
)
.
attr
(
'font-family'
,
`
${
config
.
titleConfig
.
fontFamily
}
`
)
.
attr
(
'font-style'
,
`
${
config
.
titleConfig
.
fontStyle
}
`
)
.
attr
(
'font-weight'
,
`
${
config
.
titleConfig
.
fontWeight
}
`
)
.
style
(
'text-anchor'
,
'middle'
)
.
text
(
config
.
label
);
config
.
svg
.
append
(
'text'
)
.
attr
(
'x'
,
config
.
position
.
titleBottom
[
0
])
.
attr
(
'y'
,
config
.
position
.
titleBottom
[
1
])
.
attr
(
'fill'
,
config
.
titleConfig
.
color
)
.
attr
(
'font-size'
,
`
${
config
.
titleConfig
.
fontSize
}
px`
)
.
attr
(
'font-family'
,
`
${
config
.
titleConfig
.
fontFamily
}
`
)
.
attr
(
'font-style'
,
`
${
config
.
titleConfig
.
fontStyle
}
`
)
.
attr
(
'font-weight'
,
`
${
config
.
titleConfig
.
fontWeight
}
`
)
.
style
(
'text-anchor'
,
'middle'
)
.
text
(
config
.
titles
[
0
]);
config
.
svg
.
append
(
'text'
)
.
attr
(
'x'
,
config
.
position
.
titleLeft
[
0
])
.
attr
(
'y'
,
config
.
position
.
titleLeft
[
1
])
.
attr
(
'fill'
,
config
.
titleConfig
.
color
)
.
attr
(
'font-size'
,
`
${
config
.
titleConfig
.
fontSize
}
px`
)
.
attr
(
'font-family'
,
`
${
config
.
titleConfig
.
fontFamily
}
`
)
.
attr
(
'font-style'
,
`
${
config
.
titleConfig
.
fontStyle
}
`
)
.
attr
(
'font-weight'
,
`
${
config
.
titleConfig
.
fontWeight
}
`
)
.
style
(
'text-anchor'
,
'middle'
)
.
style
(
'transform'
,
'rotate(-90deg)'
)
.
text
(
config
.
titles
[
1
]);
};
src/components/FeaturePlot/utils/mock.js
0 → 100644
浏览文件 @
02b21257
差异被折叠。
点击展开。
src/components/MsDimplot/components/chart.vue
浏览文件 @
02b21257
<
template
>
<
template
>
<div
ref=
"chartRef"
></div>
<div
ref=
"chartRef"
class=
"chart-box"
>
<div
class=
"tip"
></div>
</div>
</
template
>
</
template
>
<
script
setup
>
<
script
setup
>
import
{
ref
,
onMounted
,
onUnmounted
}
from
'vue'
;
import
{
ref
,
onMounted
,
onUnmounted
}
from
'vue'
;
import
*
as
Plot
from
'@observablehq/plot
'
;
import
*
as
d3
from
'https://cdn.jsdelivr.net/npm/d3@7/+esm
'
;
// import * as d3 from 'd3
';
import
{
chartMockData
}
from
'../utils/mock
'
;
import
{
chartData
}
from
'../mock
'
;
import
{
setTips
,
setMaxMinNumber
,
coordinateScale
,
setColor
,
setCluster
,
setLegend
,
setLabel
}
from
'../utils/index
'
;
import
PubSub
from
'pubsub-js'
;
import
PubSub
from
'pubsub-js'
;
// 根节点实例
// 根节点实例
...
@@ -18,92 +20,88 @@ const options = ref({});
...
@@ -18,92 +20,88 @@ const options = ref({});
// pubsub实例
// pubsub实例
const
pubSubInstance
=
ref
(
null
);
const
pubSubInstance
=
ref
(
null
);
//
plot
实例
//
图表
实例
const
plot
Instance
=
ref
(
null
);
const
svg
Instance
=
ref
(
null
);
// 生成图表
// 生成图表
const
generateChart
=
(
data
)
=>
{
const
generateChart
=
(
data
)
=>
{
const
ret
=
options
.
value
;
const
ret
=
options
.
value
;
// console.log(ret);
let
width
=
Number
(
ret
.
chart_width
)
||
800
;
// 点,线,阴影颜色设置
let
height
=
Number
(
ret
.
chart_height
)
||
800
;
let
point_color
=
'#FF5733'
;
let
marginTop
=
Number
(
ret
.
margin_top
)
||
60
;
let
line_color
=
'#39FDBE'
;
let
marginRight
=
Number
(
ret
.
margin_right
)
||
200
;
let
shadow_color
=
'#D6D6D6'
;
let
marginBottom
=
Number
(
ret
.
margin_bottom
)
||
60
;
if
(
ret
.
data_color_list
?.
length
)
{
let
marginLeft
=
Number
(
ret
.
margin_left
)
||
60
;
point_color
=
ret
.
data_color_list
[
0
];
let
radius
=
Number
(
ret
.
point_radius
)
||
4
;
line_color
=
ret
.
data_color_list
[
1
];
let
colors
=
ret
.
data_color_list
||
[
'#E53935'
,
'#1E88E5'
];
shadow_color
=
ret
.
data_color_list
[
2
];
let
legendData
=
[
'Cancer'
,
'Non-cance'
];
}
plotInstance
.
value
=
Plot
.
plot
({
const
titleConfig
=
{
width
:
ret
.
chart_width
||
800
,
label
:
!!
ret
.
title
?
ret
.
title
:
null
,
height
:
ret
.
chart_height
||
700
,
color
:
ret
.
title_font_color
||
'#333333'
,
marginTop
:
ret
.
margin_top
||
60
,
fontSize
:
ret
.
title_font_size
||
30
,
marginRight
:
ret
.
margin_right
||
60
,
fontStyle
:
ret
.
title_font_style
?
'oblique'
:
'normal'
,
marginBottom
:
ret
.
margin_bottom
||
60
,
fontFamily
:
ret
.
title_font_family
||
'Arial'
,
marginLeft
:
ret
.
margin_left
||
60
,
fontWeight
:
ret
.
title_font_weight
?
'bold'
:
'normal'
color
:
{
};
legend
:
ret
.
show_legend
,
range
:
ret
.
data_color_list
||
[]
const
svg
=
d3
.
create
(
'svg'
).
attr
(
'width'
,
width
).
attr
(
'height'
,
height
);
},
// x: {
svg
.
append
(
'rect'
)
// grid: ret.show_x_gridLine,
.
attr
(
'x'
,
marginLeft
)
// domain: [-100, 100]
.
attr
(
'y'
,
marginTop
)
// },
.
attr
(
'width'
,
width
-
marginTop
-
marginRight
)
// y: {
.
attr
(
'height'
,
height
-
marginTop
-
marginBottom
)
// grid: ret.show_y_gridLine,
.
attr
(
'fill'
,
'white'
);
// domain: [-100, 100]
// },
const
{
paddedMin
,
paddedMax
}
=
setMaxMinNumber
(
data
);
marks
:
[
Plot
.
ruleX
([
0
]),
let
configObj
=
{
Plot
.
ruleY
([
0
]),
svg
,
Plot
.
axisX
({
width
,
label
:
!!
ret
.
x_title
?
ret
.
x_title
:
null
,
height
,
stroke
:
ret
.
x_tickMarks_color
||
'currentColor'
,
marginTop
,
tickSize
:
ret
.
show_x_tickMarks
?
ret
.
x_tickMarks_length
:
0
,
marginRight
,
fill
:
ret
.
xtitle_font_color
||
'currentColor'
,
marginBottom
,
fontSize
:
ret
.
xtitle_font_size
||
16
,
marginLeft
,
fontStyle
:
ret
.
xtitle_font_style
?
'oblique'
:
'normal'
,
paddedMin
,
fontFamily
:
ret
.
xtitle_font_family
||
'Arial'
,
paddedMax
,
fontWeight
:
ret
.
xtitle_font_weight
?
'bold'
:
'normal'
titleConfig
,
}),
colors
,
Plot
.
axisY
({
radius
,
label
:
!!
ret
.
y_title
?
ret
.
y_title
:
null
,
legendData
,
stroke
:
ret
.
y_tickMarks_color
||
'currentColor'
,
...
ret
tickSize
:
ret
.
show_x_tickMarks
?
ret
.
y_tickMarks_length
:
0
,
};
fill
:
ret
.
ytitle_font_color
||
'currentColor'
,
fontSize
:
ret
.
ytitle_font_size
||
16
,
const
{
x
,
y
}
=
coordinateScale
(
configObj
,
data
);
fontStyle
:
ret
.
ytitle_font_style
?
'oblique'
:
'normal'
,
fontFamily
:
ret
.
ytitle_font_family
||
'Arial'
,
const
color
=
setColor
(
configObj
);
fontWeight
:
ret
.
ytitle_font_weight
?
'bold'
:
'normal'
}),
configObj
=
{
...
configObj
,
x
,
y
,
color
};
Plot
.
dot
(
data
,
{
x
:
'x'
,
const
cluster
=
setCluster
(
configObj
,
data
);
y
:
'y'
,
stroke
:
'group'
,
setTips
(
cluster
);
fill
:
'group'
,
r
:
Number
(
ret
.
point_radius
)
||
5
,
// legend
tip
:
true
configObj
.
show_legend
&&
setLegend
(
configObj
);
}),
Plot
.
text
([
ret
.
title
||
''
],
{
// label
x
:
1
,
setLabel
(
configObj
);
fill
:
ret
.
title_font_color
||
'currentColor'
,
fontSize
:
ret
.
title_font_size
||
20
,
svgInstance
.
value
=
svg
.
node
();
fontStyle
:
ret
.
title_font_style
?
'oblique'
:
'normal'
,
fontFamily
:
ret
.
title_font_family
||
'Arial'
,
// Append the SVG element.
fontWeight
:
ret
.
title_font_weight
?
'bold'
:
'normal'
,
chartRef
.
value
.
appendChild
(
svgInstance
.
value
);
frameAnchor
:
'top'
,
textAnchor
:
'start'
})
]
});
chartRef
.
value
.
appendChild
(
plotInstance
.
value
);
};
};
onMounted
(()
=>
{
onMounted
(()
=>
{
const
chartData
=
chartMockData
;
pubSubInstance
.
value
=
PubSub
.
subscribe
(
'options'
,
(
m
,
data
)
=>
{
pubSubInstance
.
value
=
PubSub
.
subscribe
(
'options'
,
(
m
,
data
)
=>
{
options
.
value
=
data
;
options
.
value
=
data
;
chartRef
.
value
.
removeChild
(
plot
Instance
.
value
);
chartRef
.
value
.
removeChild
(
svg
Instance
.
value
);
generateChart
(
chartData
);
generateChart
(
chartData
);
});
});
generateChart
(
chartData
);
generateChart
(
chartData
);
...
@@ -114,4 +112,8 @@ onUnmounted(() => {
...
@@ -114,4 +112,8 @@ onUnmounted(() => {
});
});
</
script
>
</
script
>
<
style
scoped
></
style
>
<
style
scoped
>
.chart-box
{
position
:
relative
;
}
</
style
>
src/components/MsDimplot/components/config.vue
浏览文件 @
02b21257
...
@@ -46,99 +46,9 @@
...
@@ -46,99 +46,9 @@
<span>
斜体:
</span>
<span>
斜体:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.title_font_style"
/>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.title_font_style"
/>
</div>
</div>
<h3
class=
"type content"
>
X轴配置
</h3>
<div
class=
"form-item"
>
<span>
显示坐标轴:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_x_axis"
/>
</div>
<div
class=
"form-item"
>
<span>
显示刻度线:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_x_tickMarks"
/>
</div>
<div
class=
"form-item"
>
<span>
显示网格:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_x_gridLine"
/>
</div>
<div
class=
"form-item"
>
<span>
刻度线颜色:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.x_tickMarks_color"
/>
</div>
<div
class=
"form-item"
>
<span>
刻度线长度:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.x_tickMarks_length"
/>
</div>
<div
class=
"form-item"
>
<span>
字体:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.xtitle_font_family"
/>
</div>
<div
class=
"form-item"
>
<span>
字号:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.xtitle_font_size"
/>
</div>
<div
class=
"form-item"
>
<span>
字体颜色:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.xtitle_font_color"
/>
</div>
<div
class=
"form-item"
>
<span>
字体加粗:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.xtitle_font_weight"
/>
</div>
<div
class=
"form-item"
>
<span>
斜体:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.xtitle_font_style"
/>
</div>
<div
class=
"form-item"
>
<span>
x轴标题:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.x_title"
/>
</div>
<h3
class=
"type content"
>
Y轴配置
</h3>
<div
class=
"form-item"
>
<span>
显示坐标轴:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_y_axis"
/>
</div>
<div
class=
"form-item"
>
<span>
显示刻度线:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_y_tickMarks"
/>
</div>
<div
class=
"form-item"
>
<span>
显示网格:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.show_y_gridLine"
/>
</div>
<div
class=
"form-item"
>
<span>
刻度线颜色:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.y_tickMarks_color"
/>
</div>
<div
class=
"form-item"
>
<span>
刻度线长度:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.y_tickMarks_length"
/>
</div>
<div
class=
"form-item"
>
<span>
字体:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.ytitle_font_family"
/>
</div>
<div
class=
"form-item"
>
<span>
字号:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.ytitle_font_size"
/>
</div>
<div
class=
"form-item"
>
<span>
字体颜色:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.ytitle_font_color"
/>
</div>
<div
class=
"form-item"
>
<span>
字体加粗:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.ytitle_font_weight"
/>
</div>
<div
class=
"form-item"
>
<span>
斜体:
</span>
<input
type=
"checkbox"
v-model=
"dynamic_parameter.ytitle_font_style"
/>
</div>
<div
class=
"form-item"
>
<span>
x轴标题:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.y_title"
/>
</div>
<h3
class=
"type content"
>
图表配置
</h3>
<h3
class=
"type content"
>
图表配置
</h3>
<div
class=
"form-item"
>
<div
class=
"form-item"
>
<span>
散点
图
半径:
</span>
<span>
散点半径:
</span>
<input
type=
"text"
v-model=
"dynamic_parameter.point_radius"
/>
<input
type=
"text"
v-model=
"dynamic_parameter.point_radius"
/>
</div>
</div>
<h3
class=
"type content"
>
图例
</h3>
<h3
class=
"type content"
>
图例
</h3>
...
@@ -160,18 +70,18 @@ import PubSub from 'pubsub-js';
...
@@ -160,18 +70,18 @@ import PubSub from 'pubsub-js';
const
dynamic_parameter
=
reactive
({
const
dynamic_parameter
=
reactive
({
//长宽间距
//长宽间距
chart_width
:
800
,
chart_width
:
800
,
chart_height
:
7
00
,
chart_height
:
8
00
,
margin_top
:
60
,
margin_top
:
60
,
margin_right
:
6
0
,
margin_right
:
20
0
,
margin_bottom
:
60
,
margin_bottom
:
60
,
margin_left
:
60
,
margin_left
:
60
,
//标题配置
//标题配置
title
:
''
,
title
:
''
,
title_font_family
:
'Arial'
,
title_font_family
:
'Arial'
,
title_font_weight
:
true
,
title_font_weight
:
true
,
title_font_size
:
2
0
,
title_font_size
:
3
0
,
title_font_color
:
'#333333'
,
title_font_color
:
'#333333'
,
title_font_style
:
tru
e
,
title_font_style
:
fals
e
,
//横轴标题
//横轴标题
xtitle_font_family
:
'Arial'
,
xtitle_font_family
:
'Arial'
,
xtitle_font_weight
:
false
,
xtitle_font_weight
:
false
,
...
@@ -186,9 +96,9 @@ const dynamic_parameter = reactive({
...
@@ -186,9 +96,9 @@ const dynamic_parameter = reactive({
ytitle_font_color
:
'#333333'
,
ytitle_font_color
:
'#333333'
,
//颜色设置
//颜色设置
data_color_list
:
[
'#
FF5733'
,
'#39FDBE'
,
'#D6D6D6
'
],
data_color_list
:
[
'#
E53935'
,
'#1E88E5
'
],
point_radius
:
5
,
// 散点图半径
point_radius
:
4
,
// 散点图半径
//图例
//图例
show_legend
:
true
,
show_legend
:
true
,
...
...
src/components/MsDimplot/mock.js
deleted
100644 → 0
浏览文件 @
ce04e1f5
差异被折叠。
点击展开。
src/components/MsDimplot/utils/index.js
0 → 100644
浏览文件 @
02b21257
差异被折叠。
点击展开。
src/components/MsDimplot/utils/mock.js
0 → 100644
浏览文件 @
02b21257
差异被折叠。
点击展开。
src/components/Test/index.vue
浏览文件 @
02b21257
差异被折叠。
点击展开。
src/components/Test/mock.js
浏览文件 @
02b21257
差异被折叠。
点击展开。
src/components/Test/utils.js
浏览文件 @
02b21257
差异被折叠。
点击展开。
src/views/home/index.vue
浏览文件 @
02b21257
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论