Skip to content

Commit

Permalink
chart showMarkLine
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Jan 22, 2025
1 parent db3ae9b commit de76331
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/css/chart-design.css
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ a.ui-draggable.ui-draggable-dragging {
.themeStyle {
border: 0 none;
outline: 0 none;
width: 77px;
width: 80px;
border-bottom: 1px solid #ccc;
padding: 2px;
margin-left: 5px;
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/web/assets/js/charts/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ const ECHART_AXIS_LABEL = {
},
}

const ECHART_MARK_LINE = {
data: [{ type: 'average', name: $L('均线') }],
symbol: 'none',
silent: true,
emphasis: { disabled: true },
label: { show: false },
}

const ECHART_VALUE_LABEL2 = function (dataFlags = []) {
return {
show: true,
Expand Down Expand Up @@ -519,6 +527,7 @@ class ChartLine extends BaseChart {
const showAreaColor = data._renderOption && data._renderOption.showAreaColor
const dataFlags = data._renderOption.dataFlags || []
const themeStyle = data._renderOption ? data._renderOption.themeStyle : null
const showMarkLine = data._renderOption ? data._renderOption.showMarkLine : null

for (let i = 0; i < data.yyyAxis.length; i++) {
const yAxis = data.yyyAxis[i]
Expand All @@ -532,6 +541,7 @@ class ChartLine extends BaseChart {
if (showAreaColor) yAxis.areaStyle = { opacity: 0.2 }
if (showNumerical) yAxis.label = ECHART_VALUE_LABEL2(dataFlags)
yAxis.cursor = 'default'
if (showMarkLine) yAxis.markLine = { ...$clone(ECHART_MARK_LINE) }
data.yyyAxis[i] = yAxis
}

Expand Down Expand Up @@ -589,6 +599,7 @@ class ChartBar extends BaseChart {
const showMutliYAxis = data._renderOption && data._renderOption.showMutliYAxis // v3.7
const dataFlags = data._renderOption.dataFlags || [] // 小数符号
const themeStyle = data._renderOption ? data._renderOption.themeStyle : null
const showMarkLine = data._renderOption ? data._renderOption.showMarkLine : null

for (let i = 0; i < data.yyyAxis.length; i++) {
const yAxis = data.yyyAxis[i]
Expand All @@ -603,6 +614,7 @@ class ChartBar extends BaseChart {
yAxis.smooth = true
yAxis.lineStyle = { width: 3 }
}
if (showMarkLine) yAxis.markLine = { ...$clone(ECHART_MARK_LINE) }
data.yyyAxis[i] = yAxis
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/web/dashboard/chart-design.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ <h5>[[${bundle.L('图表选项')}]]</h5>
<span class="custom-control-label">[[${bundle.L('显示参考线')}]]</span>
</label>
</div>
<div class="hide J_opt-LINE J_opt-BAR J_opt-BAR2 J_opt-BAR3">
<label class="custom-control custom-control-sm custom-checkbox">
<input class="custom-control-input" type="checkbox" data-name="showMarkLine" />
<span class="custom-control-label">[[${bundle.L('显示均线')}]]</span>
</label>
</div>
<div class="hide J_opt-FUNNEL">
<label class="custom-control custom-control-sm custom-checkbox">
<input class="custom-control-input" type="checkbox" data-name="showCvr" />
Expand Down

0 comments on commit de76331

Please sign in to comment.