Giter Club home page Giter Club logo

Comments (3)

ishwara-bhat avatar ishwara-bhat commented on May 14, 2024

My mistake. I had some additional ',' in my data. The component does not give error. So, I totally ignored it. Sorry about that.

It works well with Angular 8.

from timelines-chart.

soniya31 avatar soniya31 commented on May 14, 2024

@ishwara-bhat Could you please share the working example with angular 8

from timelines-chart.

ishwara-bhat avatar ishwara-bhat commented on May 14, 2024

I have something like this .

//timelinewrapper.ts

import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
import { ElementRef, Renderer2, AfterViewInit, ViewChild } from '@angular/core';
import * as d3 from 'd3';

import TimelinesChart from 'timelines-chart';

@Component({
  selector: 'app-time-line-wrap',
  templateUrl: './time-line-wrap.component.html',
  styleUrls: ['./time-line-wrap.component.scss']
})
export class TimeLineWrapComponent implements OnInit {
    private elRef: any;
    
    mychart = TimelinesChart();
     inputDataDomain = ['labelval1', 'labelval2', 'labelval3', 'labelval4', 'labelval5'];
    inputDataRange = ['red', 'green', 'grey', 'blue', 'brown'];
    controlwidth: integer = 1000;
   public inputData: any =  //Reference data
        [
            {
                group: "group1",
                data: [
                    {
                        label: "label1",
                        data:
                            [
                                {
                                    timeRange: [1, 2],
                                    val: 'labelval1'
                                },
                                {
                                    timeRange: [2, 3],
                                    val: 'labelval2'
                                },
                                {
                                    timeRange: [6, 7],
                                    val: 'labelval3'
                                },
                                {
                                    timeRange: [7, 8],
                                    val: 'labelval4'
                                },
                                {
                                    timeRange: [11, 12],
                                    val: 'labelval5'
                                },
                                {
                                    timeRange: [12, 13],
                                    val: 'labelval6'
                                }
                            ]
                    },

                ]
            },
			{...}]

			
			 ngOnInit() {
        this.mychart
            .data(this.inputData)
            .zScaleLabel('My Labels')
            .zQualitative(true)
            .xTickFormat(n => +n)
            .timeFormat('%Q')
            .maxLineHeight(20)
            .width(this.controlwidth)
            .topMargin(30)

            //(this.chartspanContainer.nativeElement);

            (this.elRef.nativeElement);

        this.mychart.zColorScale(d3.scaleOrdinal().domain(this.inputDataDomainfromOutside).range(this.inputDataRangefromOutside));
  }
    ngOnChanges(changes: SimpleChanges) {
        console.log("Data simple change event at child chart" + changes)
        this.mychart
            .data(this.inputData);

        console.log(this.inputData);

        this.mychart.zColorScale(d3.scaleOrdinal().domain(this.inputDataDomain).range(this.inputDataRange));
    }

from timelines-chart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.