Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for y-axis zoom in renderConfigurableZoomableTrendChart() #306

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions src/main/webapp/js/echarts-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ const echartsJenkinsApi = {
* @param {String} settingsDialogId - the optional ID of the div that provides a settings dialog (might be set to null
* if there is no such dialog)
* @param {Function} chartClickedEventHandler - the optional event handler that receives click events
* @param {Boolean} allowYAxisZoom - Allow zooming on the y-axis
*/
renderConfigurableZoomableTrendChart: function (chartDivId, model, settingsDialogId, chartClickedEventHandler) {
renderConfigurableZoomableTrendChart: function (chartDivId, model, settingsDialogId, chartClickedEventHandler, allowYAxisZoom = false) {
const themedModel = echartsJenkinsApi.resolveJenkinsColors(model);
const chartModel = JSON.parse(themedModel);
const chartPlaceHolder = document.getElementById(chartDivId);
Expand All @@ -238,6 +239,35 @@ const echartsJenkinsApi = {
const textColor = getComputedStyle(document.body).getPropertyValue('--text-color') || '#333';
const showSettings = document.getElementById(settingsDialogId);

function getDataZoomOptions(allowYAxisZoom) {
var dataZoomOptions = [
{
type: 'inside'
},
{
type: 'slider',
height: 25,
bottom: 5,
moveHandleSize: 5,
xAxisIndex: [0],
filterMode: 'filter',
}
];

if (allowYAxisZoom) {
dataZoomOptions.push({
type: 'slider',
width: 25,
right: 5,
moveHandleSize: 5,
yAxisIndex: [0],
filterMode: 'empty'
});
}

return dataZoomOptions;
};

const options = {
tooltip: {
trigger: 'axis',
Expand All @@ -261,16 +291,7 @@ const echartsJenkinsApi = {
}
}
},
dataZoom: [
{
type: 'inside'
},
{
type: 'slider',
height: 25,
bottom: 5,
moveHandleSize: 5
}],
dataZoom: getDataZoomOptions(allowYAxisZoom),
legend: {
orient: 'horizontal',
type: 'scroll',
Expand All @@ -282,7 +303,7 @@ const echartsJenkinsApi = {
},
grid: {
left: '20',
right: '10',
right: allowYAxisZoom ? '40' : '10',
bottom: '35',
top: '40',
containLabel: true
Expand Down
Loading