Skip to content
Snippets Groups Projects
Commit bd439de6 authored by AndiMajore's avatar AndiMajore
Browse files

Merge branch 'master' of gitlab.lrz.de:netex/frontend

parents c13a1569 8807715e
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ import {NetworkSettings} from '../../network-settings';
import {NetexControllerService} from 'src/app/services/netex-controller/netex-controller.service';
import {defaultConfig, IConfig} from 'src/app/config';
import { mapCustomEdge, mapCustomNode } from 'src/app/main-network';
import { downLoadFile, removeDuplicateObjectsFromList } from 'src/app/utils';
import { downLoadFile, pieChartContextRenderer, removeDuplicateObjectsFromList } from 'src/app/utils';
declare var vis: any;
......@@ -801,7 +801,8 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
isSeed,
this.analysis.inSelection(wrapper),
this.gradientMap[netexId]));
node.gradient = this.gradientMap[netexId];
node.shape = 'custom';
node.ctxRenderer = pieChartContextRenderer;
updatedNodes.push(node);
}
this.nodeData.nodes.update(updatedNodes);
......
......@@ -803,7 +803,6 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
gradient));
// try out custom ctx renderer
// node.gradient = gradient;
node.shape = 'custom';
node.ctxRenderer = pieChartContextRenderer;
updatedNodes.push(node);
......
......@@ -101,7 +101,7 @@ export function rgbToHex(rgb) {
}
// https://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes/47355187#47355187
export function standardize_color(str){
export function standardizeColor(str){
var ctx = document.createElement("canvas").getContext("2d");
ctx.fillStyle = str;
return ctx.fillStyle.toString();
......@@ -133,7 +133,21 @@ export function downLoadFile(data: any, type: string, fmt: string) {
a.click();
}
export function RGBAtoRGB(rgbaString) {
const rgbaStringSplit = rgbaString.slice(5, -1).split(",");
const RGBA = {red: rgbaStringSplit[0], green: rgbaStringSplit[1], blue: rgbaStringSplit[2], alpha: rgbaStringSplit[3]};
// assume white background
const bg = {red: 255, green: 255, blue: 255};
const RGB = {red: undefined, green: undefined, blue: undefined};
const alpha = 1 - RGBA.alpha;
RGB.red = Math.round((RGBA.alpha * (RGBA.red / 255) + (alpha * (bg.red / 255))) * 255);
RGB.green = Math.round((RGBA.alpha * (RGBA.green / 255) + (alpha * (bg.green / 255))) * 255);
RGB.blue = Math.round((RGBA.alpha * (RGBA.blue / 255) + (alpha * (bg.blue / 255))) * 255);
return `rgb(${RGB.red},${RGB.green},${RGB.blue})`;
}
export function pieChartContextRenderer({ ctx, x, y, state: { selected, hover }, style, label }) {
console.log(style)
ctx.drawPieLabel = function(style, x, y, label) {
ctx.font = "normal 12px sans-serif";
ctx.textAlign = "center";
......@@ -144,7 +158,6 @@ export function pieChartContextRenderer({ ctx, x, y, state: { selected, hover },
ctx.drawPie = function(style, x, y) {
const total = 1;
let lastend = 0;
// draw shadow
if (style.shadow) {
......@@ -154,13 +167,16 @@ export function pieChartContextRenderer({ ctx, x, y, state: { selected, hover },
ctx.shadowBlur = 10;
}
ctx.fillStyle = style.color ? style.color : "red";
ctx.fillStyle = style.color ? style.color : 'rgba(255, 0, 0, 1)';
// set alpha value to 1
// ctx.fillStyle = ctx.fillStyle.replace(/[^,]+(?=\))/, '1')
ctx.fillStyle = RGBAtoRGB(ctx.fillStyle)
ctx.strokeStyle = "black";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(x, y);
var len = style.opacity/total * 2 * Math.PI;
ctx.arc(x , y, style.size, lastend, lastend + len, false);
const len = style.opacity/total * 2 * Math.PI;
ctx.arc(x , y, style.size, 0, 0 + len, false);
ctx.lineTo(x, y);
ctx.fill();
if (style.opacity !== total) {
......
......@@ -108,7 +108,7 @@
height: $height;
overflow-y: auto;
overflow-x: hidden;
max-width: $sidebar-max-width;
max-width: $sidebar-width;
min-width: $sidebar-min-width;
height: 100%;
/* Hide scrollbar for Chrome, Safari and Opera */
......@@ -118,6 +118,9 @@
/* Hide scrollbar for IE, Edge and Firefox */
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
@media only screen and (min-width: #{$screen-lg}) {
max-width: 350px;
}
}
div.card.bar-small {
......
// media queries
$screen-lg: 1400px;
$row-data-selector-height: auto;
$network-header-height: 3rem;
$network-footer-height: 4rem;
......@@ -34,7 +37,7 @@ $legend-diamond-size: 25px;
$height: 100%;
$sidebar-max-width: 25%;
$sidebar-width: 25%;
$sidebar-min-width: 240px;
// settings for different screen sizes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment