<commit_before>/// <reference path="../typings/browser.d.ts" />
import 'snapsvg';
import {NodeSvg} from "./node.svg";
import {OrgChartConfig} from "./org.chart.config";
import {ChartNode} from "./chart.node";
import {NodeOptions} from "./node.options";
import {ChartLevelNode} from "./chart.level.node";
import {ChartLevelInfo} from "./chart.level.info";

export class OrgChartSvg {
    private nodesSpacing: number;
    private nodes: { [id: string] : ChartNode; } = {};
	private levels: ChartLevelInfo[] = [];
	private snap: Snap.Paper;
	private placeholdersParents: ChartLevelNode[] = [];

    constructor(private config?: OrgChartConfig) {
		if (!config) {
			this.initDefaultConfig();
		}

		this.snap = Snap('#orgChartSvg');

        this.calcPositions();
        this.render();
    }

	private initDefaultConfig() {
		this.config = <OrgChartConfig>{};
		this.config.selector = '#orgChartSvg';
		this.config.nodeOptions = <NodeOptions>{};
		this.config.nodeOptions.width = 150;
		this.config.nodeOptions.height = 50;
		this.config.nodeOptions.gapV = 20;
		this.config.nodeOptions.gapH = 20;

		this.config.nodes = {
			id: '1',
			parentId: null,
			data: { text: "root" },
			children: [
				{
					id: '2',
					parentId: '1',
					data: { text: "child 1" },
					children: [
						{
							id: '5',
							parentId: '3',
							data: { text: "child X1" },
							children: []
						},
						{
							id: '5',
							parentId: '3',
							data: { text: "child X1" },
							children: []
						}
					]
				},
				{
					id: '3',
					parentId: '1',
					data: { text: "child 2" },
					children: [
						{
							id: '5',
							parentId: '3',
							data: { text: "child 4" },
							children: []
						},
						{
							id: '6',
							parentId: '3',
							data: { text: "child 5" },
							children: [
								{
									id: '5',
									parentId: '3',
									data: { text: "child X1" },
									children: []
								},
								{
									id: '5',
									parentId: '3',
									data: { text: "child X1" },
									children: []
								},
								{
									id: '5',
									parentId: '3',
									data: { text: "child X1" },
									children: [
										{
											id: '5',
											parentId: '3',
											data: { text: "child X1" },
											children: []
										},
										{
											id: '5',
											parentId: '3',
											data: { text: "child X1" },
											children: []
										},
									]
								},
								{
									id: '5',
									parentId: '3',
									data: { text: "child X1" },
									children: []
								},
								{
									id: '5',
									parentId: '3',
									data: { text: "child X1" },
									children: []
								},
								{
									id: '5',
									parentId: '3',
									data: { text: "child X1" },
									children: []
								},
							]
						}
					]
				},
				{
					id: '4',
					parentId: '1',<commit_msg>[fix] Correct example nodes tree structure with parents and ids<commit_after>/// <reference path="../typings/browser.d.ts" />
import 'snapsvg';
import {NodeSvg} from "./node.svg";
import {OrgChartConfig} from "./org.chart.config";
import {ChartNode} from "./chart.node";
import {NodeOptions} from "./node.options";
import {ChartLevelNode} from "./chart.level.node";
import {ChartLevelInfo} from "./chart.level.info";

export class OrgChartSvg {
    private nodesSpacing: number;
    private nodes: { [id: string] : ChartNode; } = {};
	private levels: ChartLevelInfo[] = [];
	private snap: Snap.Paper;
	private placeholdersParents: ChartLevelNode[] = [];

    constructor(private config?: OrgChartConfig) {
		if (!config) {
			this.initDefaultConfig();
		}

		this.snap = Snap('#orgChartSvg');

        this.calcPositions();
        this.render();
    }

	private initDefaultConfig() {
		this.config = <OrgChartConfig>{};
		this.config.selector = '#orgChartSvg';
		this.config.nodeOptions = <NodeOptions>{};
		this.config.nodeOptions.width = 150;
		this.config.nodeOptions.height = 50;
		this.config.nodeOptions.gapV = 20;
		this.config.nodeOptions.gapH = 20;

		this.config.nodes = {
			id: '1',
			parentId: null,
			data: { text: "root" },
			children: [
				{
					id: '2',
					parentId: '1',
					data: { text: "child 1" },
					children: [
						{
							id: '50',
							parentId: '2',
							data: { text: "child Y1" },
							children: []
						},
						{
							id: '51',
							parentId: '2',
							data: { text: "child Y2" },
							children: []
						}
					]
				},
				{
					id: '3',
					parentId: '1',
					data: { text: "child 2" },
					children: [
						{
							id: '5',
							parentId: '3',
							data: { text: "child 4" },
							children: []
						},
						{
							id: '6',
							parentId: '3',
							data: { text: "child 5" },
							children: [
								{
									id: '7',
									parentId: '6',
									data: { text: "child X1" },
									children: []
								},
								{
									id: '8',
									parentId: '6',
									data: { text: "child X2" },
									children: []
								},
								{
									id: '9',
									parentId: '6',
									data: { text: "child X3" },
									children: [
										{
											id: '5',
											parentId: '9',
											data: { text: "child G1" },
											children: []
										},
										{
											id: '5',
											parentId: '9',
											data: { text: "child G2" },
											children: []
										},
									]
								},
								{
									id: '10',
									parentId: '6',
									data: { text: "child X4" },
									children: []
								},
								{
									id: '11',
									parentId: '6',
									data: { text: "child X5" },
									children: []
								},
								{
									id: '12',
									parentId: '6',
									data: { text: "child X6" },
									children: []
								},
							]
						}
					]
				},
				{
					id: '4',
					parentId: '1',
{'fraction_non_alphanumeric': 0.17078575080961308, 'fraction_numerical': 0.01926026930288052, 'mean_word_length': 1.546875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4583775', 'n_tokens_mistral': 3236, 'n_tokens_neox': 1940, 'n_words': 436}