зеркало из https://github.com/microsoft/tsiclient.git
adding Jorge's changes (#339)
Adding the ability to set per swim lane yExtents. If they are specified those will be used to set the yExtents for the swim lane and will override per-time series yExtents.
This commit is contained in:
Родитель
ecfa35a55e
Коммит
2e2bc4a64b
|
@ -40,10 +40,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
var swimLaneOptions = {
|
||||
1: {yExtent: [0.2, 0.8], yAxisType: 'shared', label: 'Lane 1', onClick: () => alert("'Lane 1' label/axis clicked")},
|
||||
2: {yAxisType: 'shared', label: 'Lane 2', onClick: () => alert("'Lane 2' label/axis clicked")},
|
||||
3: {yAxisType: 'shared', label: 'Lane 3', onClick: () => alert("'Lane 3' label/axis clicked")}
|
||||
};
|
||||
|
||||
// render the data in a chart
|
||||
var tsiClient = new TsiClient();
|
||||
var lineChart = new tsiClient.ux.LineChart(document.getElementById('chart1'));
|
||||
lineChart.render(data, {theme: 'light'});
|
||||
lineChart.render(data, {theme: 'light', swimLaneOptions});
|
||||
|
||||
var barChart = new tsiClient.ux.BarChart(document.getElementById('chart2'));
|
||||
barChart.render(data, {theme: 'dark', grid: true, tooltip: true, legend: 'compact'});
|
||||
|
|
|
@ -1140,10 +1140,18 @@ class LineChart extends TemporalXAxisComponent {
|
|||
return visibleGroupEndValues;
|
||||
}
|
||||
|
||||
private setSwimLaneYExtents (visibleGroups, visibleCDOs, swimLanes) {
|
||||
private setSwimLaneYExtents (visibleGroups, visibleCDOs, swimLanes, swimLaneOptions) {
|
||||
let extents = {};
|
||||
swimLanes.forEach((lane) => {
|
||||
let extent = [];
|
||||
|
||||
// Check if swim lane options sets y-axis extents for this lane. If so use that
|
||||
// value for yExtents.
|
||||
if(swimLaneOptions && swimLaneOptions[lane] && swimLaneOptions[lane].yExtent) {
|
||||
extents[lane] = swimLaneOptions[lane].yExtent;
|
||||
return;
|
||||
}
|
||||
|
||||
visibleGroups.forEach((aggGroup, i) => {
|
||||
let cDO = visibleCDOs[i];
|
||||
if (cDO.dataType !== DataTypes.Numeric) {
|
||||
|
@ -1226,7 +1234,14 @@ class LineChart extends TemporalXAxisComponent {
|
|||
|
||||
let heightPerNumeric = (useableHeight - heightNonNumeric) / countNumericLanes;
|
||||
|
||||
this.setSwimLaneYExtents(visibleGroups, visibleCDOs, Object.keys(swimLaneSet).filter((lane) => swimLaneSet[lane]).map((stringLane) => Number(stringLane)));
|
||||
this.setSwimLaneYExtents(
|
||||
visibleGroups,
|
||||
visibleCDOs,
|
||||
Object.keys(swimLaneSet)
|
||||
.filter((lane) => swimLaneSet[lane])
|
||||
.map((stringLane) => Number(stringLane)),
|
||||
this.chartOptions.swimLaneOptions
|
||||
);
|
||||
return this.getSwimlaneOffsets(linechartTopPadding, visibleGroups, visibleCDOs, heightPerNumeric, swimLaneSet);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче