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:
niusoff 2021-10-13 11:15:59 -07:00 коммит произвёл GitHub
Родитель ecfa35a55e
Коммит 2e2bc4a64b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -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);
}