Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 3b99c6a

Browse files
committed
ENH: refs #917. Display unofficial scalar points in different color
1 parent 53f6f83 commit 3b99c6a

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

modules/tracker/public/js/trend/trend.view.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var midas = midas || {};
22
midas.tracker = midas.tracker || {};
33

4-
midas.tracker.OFFICIAL_COLOR_KEY = -1;
4+
midas.tracker.OFFICIAL_COLOR_KEY = 'black';
55
midas.tracker.UNOFFICIAL_COLOR_KEY = 'red';
66

77
/**
@@ -80,12 +80,15 @@ midas.tracker.populateInfo = function (curveData) {
8080
};
8181

8282
midas.tracker.bindPlotEvents = function () {
83-
$('#chartDiv').unbind('jqplotDataClick').bind('jqplotDataClick', function (ev, seriesIndex, pointIndex, data) {
83+
$('#chartDiv').unbind('jqplotDataClick').bind('jqplotClick', function (ev, gridpos, datapos, dataPoint, plot) {
84+
if(dataPoint == null || typeof dataPoint.seriesIndex == 'undefined') {
85+
return;
86+
}
8487
var scalarId;
85-
if(!json.tracker.rightTrend || seriesIndex == 0) {
86-
scalarId = json.tracker.scalars[seriesIndex][pointIndex].scalar_id;
88+
if(!json.tracker.rightTrend || dataPoint.seriesIndex == 0) {
89+
scalarId = json.tracker.scalars[dataPoint.seriesIndex][dataPoint.pointIndex].scalar_id;
8790
} else {
88-
scalarId = json.tracker.rightScalars[pointIndex].scalar_id;
91+
scalarId = json.tracker.rightScalars[dataPoint.pointIndex].scalar_id;
8992
}
9093
midas.loadDialog('scalarPoint'+scalarId, '/tracker/scalar/details?scalarId='+scalarId);
9194
midas.showDialog('Scalar details', false, {width: 500});
@@ -130,8 +133,20 @@ midas.tracker.renderChartArea = function (curveData, first) {
130133
show: true,
131134
zoom: true,
132135
showTooltip: false
133-
}
136+
},
137+
series: []
134138
};
139+
// Now assign official/unofficial color to each marker
140+
$.each(curveData.colors, function(idx, trendColors) {
141+
opts.series[idx] = {
142+
renderer: $.jqplot.DifferentColorMarkerLineRenderer,
143+
rendererOptions: {
144+
markerColors: curveData.colors[idx],
145+
shapeRenderer: $.jqplot.ShapeRenderer,
146+
shadowRenderer: $.jqplot.ShadowRenderer
147+
}
148+
};
149+
});
135150
if(json.tracker.rightTrend) {
136151
opts.legend = {
137152
show: true,
@@ -149,7 +164,8 @@ midas.tracker.renderChartArea = function (curveData, first) {
149164
},
150165
showLabel: true
151166
};
152-
opts.series = [{yaxis: 'yaxis'}, {yaxis: 'y2axis'}];
167+
opts.series[0].yaxis = 'yaxis';
168+
opts.series[1].yaxis = 'y2axis';
153169

154170
if(typeof json.tracker.y2Min != 'undefined' && typeof json.tracker.y2Max != 'undefined') {
155171
opts.axes.y2axis.min = parseFloat(json.tracker.y2Min);

0 commit comments

Comments
 (0)