Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeLine HTML Template working? #32

Open
plaetzchen79 opened this issue Apr 13, 2017 · 9 comments
Open

TimeLine HTML Template working? #32

plaetzchen79 opened this issue Apr 13, 2017 · 9 comments
Assignees

Comments

@plaetzchen79
Copy link

I am trying to use the template option to make a timeline-item render with html Tags.
(like shown in the soccer cup overview)

I am getting no errors, but the timeline ignores the "template" attribute and the function
(the other attributes are working).

What am i doing wrong?

Thank you

    this.visOptions = {showCurrentTime: true,  showMajorLabels: true, showMinorLabels: true,
      template:() => (function (item, element, data) {
                 return  "<p>"+ item.data.Name + "</p><p style='font-size:x-small;'>" + item.data.Betreff + "</p> <hr><p style='font-size:x-small;'><img src='/img/user.png'/>" + item.data.Bearbeiter.length + " </p>"  ;
                })
    };

         this.visTimelineService.setOptions(this.visTimeline,this.visOptions);
@seveves
Copy link
Owner

seveves commented Apr 18, 2017

I don't think that this is an issue with ng2-vis.
Please try the following:
template: (item, element, data) => { return ... } or without the fat arrow: template: function (item, element, data) { return ... } (where ... is your string content of course).

@plaetzchen79
Copy link
Author

Thank you for your answer!
unfortunately i am getting the error

Types of property 'template' are incompatible.
Type '(item: any, element: any, data: any) => string' is not assignable to type '() => void'.

and can't compile

@seveves
Copy link
Owner

seveves commented Apr 18, 2017

That's an error in here. I will make a PR to fix this. You could try to overwrite the typescript definition or set your visOptions object to any as a workaround.

@plaetzchen79
Copy link
Author

Ok Thank you!
And of course thank you for creating and maintaining the whole project!

seveves added a commit to seveves/DefinitelyTyped that referenced this issue Apr 18, 2017
As mentioned [here](seveves/angular-vis#32) there is a problem with the definition of the template functions. We really should allow any as a return value because you can return a string, Handlebars, mustache or even react templates. As you can see [here](http://visjs.org/docs/timeline/#Templates) the template function always has three parameters. I made them optional because you don't have to use them at all.
@plaetzchen79
Copy link
Author

plaetzchen79 commented Apr 18, 2017

I have changed the type of the "visOptions" object to any. Does compile then.

But vis.js still does not care about the template-option.
My breakpoint inside {return .. } does not fire too.

this.visOptions = {showCurrentTime: true, showMajorLabels: true, showMinorLabels: true, rollingMode: true,
template: function (item, element, data){
return "..."
}
};
this.visTimelineService.setOptions(this.visTimeline,this.visOptions);

@seveves
Copy link
Owner

seveves commented Apr 18, 2017

May you provide some code as an example to reproduce this issue?

@plaetzchen79
Copy link
Author

I have a timeline-Component ts:


import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { VisTimelineService } from "ng2-vis/components";
import { VisTimelineItems, VisTimelineOptions } from "ng2-vis/ng2-vis";

@Component({
  selector: 'timeline-component',
  templateUrl: './timeline-component.component.html',
  styleUrls: ['css/timeline-component.component.css']
})
export class TimelineComponentComponent implements OnInit, OnDestroy {

 @Input() timelineitems: VisTimelineItems;

 public visTimeline: string = 'timelineId1';
 public visOptions: any;

constructor(private visTimelineService: VisTimelineService) { }

  ngOnInit():void {
  }

   public timelineInitialized(): void {
        console.log('timeline initialized');

        this.visOptions = {showCurrentTime: true,  showMajorLabels: true, showMinorLabels: true, rollingMode: true,
          template: function (item, element, data){
                        return  "<p>"+ item.data.Betreff + "</p><p style='font-size:x-small;'> ff" + item.data.Betreff + "</p>";
                    }
        }; //just playing here

        this.visTimelineService.setOptions(this.visTimeline,this.visOptions);
       
 
        // open your console/dev tools to see the click params
        this.visTimelineService.click
            .subscribe((eventData: any[]) => {
                if (eventData[0] === this.visTimeline) {
                    console.log(eventData[1]);
                }
            });
    }

      public ngOnDestroy(): void {
        this.visTimelineService.off(this.visTimeline, 'click');
    }

}

html template:

 <div [visTimeline]="visTimeline"
           [visTimelineItems]="timelineitems"
           (initialized)="timelineInitialized()"></div>

using component like this:
<timeline-component [timelineitems]="timelineitems" >``

Thank you

@seveves
Copy link
Owner

seveves commented Apr 19, 2017

I'll give it a try this week and come back to you. Thanks so far.

@seveves seveves self-assigned this Apr 19, 2017
mhegazy pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this issue May 1, 2017
* Updating template function defintion

As mentioned [here](seveves/angular-vis#32) there is a problem with the definition of the template functions. We really should allow any as a return value because you can return a string, Handlebars, mustache or even react templates. As you can see [here](http://visjs.org/docs/timeline/#Templates) the template function always has three parameters. I made them optional because you don't have to use them at all.

* Using fat arrow syntax

I think this is the right way to do it.

* Fix lint error
@plaetzchen79
Copy link
Author

Hi,
any news concerning this issue?
Thank you

mojoaxel pushed a commit to visjs/vis-types that referenced this issue Jul 27, 2019
* Updating template function defintion

As mentioned [here](seveves/angular-vis#32) there is a problem with the definition of the template functions. We really should allow any as a return value because you can return a string, Handlebars, mustache or even react templates. As you can see [here](http://visjs.org/docs/timeline/#Templates) the template function always has three parameters. I made them optional because you don't have to use them at all.

* Using fat arrow syntax

I think this is the right way to do it.

* Fix lint error
mojoaxel pushed a commit to visjs/vis-types that referenced this issue Jul 27, 2019
* Updating template function defintion

As mentioned [here](seveves/angular-vis#32) there is a problem with the definition of the template functions. We really should allow any as a return value because you can return a string, Handlebars, mustache or even react templates. As you can see [here](http://visjs.org/docs/timeline/#Templates) the template function always has three parameters. I made them optional because you don't have to use them at all.

* Using fat arrow syntax

I think this is the right way to do it.

* Fix lint error
Thomaash added a commit to visjs/vis-network that referenced this issue Aug 31, 2019
* Move all packages to a `types` directory

* Fix various lint errors (#15529)

* All VisJS config options are optional.
http://visjs.org/docs/timeline/#Configuration_Options

* increment version

* Use new strict-export-declare-modifiers lint rule (#15844)

* Updating template function defintion (#15936)

* Updating template function defintion

As mentioned [here](seveves/angular-vis#32) there is a problem with the definition of the template functions. We really should allow any as a return value because you can return a string, Handlebars, mustache or even react templates. As you can see [here](http://visjs.org/docs/timeline/#Templates) the template function always has three parameters. I made them optional because you don't have to use them at all.

* Using fat arrow syntax

I think this is the right way to do it.

* Fix lint error

* Update index.d.ts

added missing DataGroup.nestedGroups according this example: http://visjs.org/examples/timeline/groups/nestedGroups.html

* Update rollingMode option to object.

Timeline implements rolling mode with an object configuration instead boolean type.

* vis: Add types for Options.locales

* Make All LocaleMessages properties required

Also fix lint.

* Merge upstream changes (#3)

* [vis] timeline: add types for custom ordering functions (#20031)

* add types for custom ordering functions

* fix trailing whitespace

* include dependency on moment  (2.13 being the first version to include types)
add type for moment constructor for use in timeline and graph2d options

* timeline: updated TimelineOptions & Timeline (#20174)

* @types/vis separated Node color into it's own interface and added it to the Node (#20603)

* separated node color into it's own interface and added it to the node
definition too.

* tslint fixes

* vis: Fix lint (#20974)

* [vis] Timeline: Type definition changes required for Timeline module on vis.js v4.21

Highlights:
@Timeline
- Documentation added for all methods as per documented in http://visjs.org/docs/timeline/
- Add 3 new definition methods for Timeline in v4.21.0: toggleRollingMode, zoomIn, zoomOut
- Add new type EasingFunction to support the intellisense to be able to choose the type of easing function used in animation

@TimelineEventPropertiesResult
- Add documentations for methods as defined in http://visjs.org/docs/timeline/#getEventProperties

Miscellaneous:
- Rename TimelineFitOptions to TimelineAnimationOptions since the class is intended to tamper with the animation styles.
- Rename TimelineFitAnimationType to TimelineAnimationType as per reason mention on last point and added documentation.

* Add chinese locale.

* Changed type of item for the TimelineEventPropertiesResult to the approperiate type

* Additional font options for NodeOptions and EdgeOptions according to http://visjs.org/docs/network/nodes.html and http://visjs.org/docs/network/edges.html

* Allow Edge arrows from to be left out of edge options

network.setOptions({edges: {arrows: {to: true}}}); should be accepted since it works properly in vis, but previous @types/vis will fail type-checking.

* Add support of subgroupStack on DataGroup (#25480)

* Add support of subgroupStack on DataGroup

* Update index.d.ts

* Update index.d.ts

Added new SubGroupStackOptions dynamic structure and updated type of DataGroup.subgroupStack to SubGroupStackOptions | boolean

* Update index.d.ts

codestyling

* Update index.d.ts

codestyling colon

* vis: update network nodes image option (v4.21)

* Make node and edge interfaces inherit from their options (#27254)

Node and Edge interfaces should inherit from NodeOptions and EdgeOptions. These Options are meant to be global, so properties such as "id", "from" and "to" should exist only on Node and Edge interfaces. Plus, in this way it's possible to use all properties defined on parent interface.

* added order property for TimelineGroup

currently missing from official docs.
awaiting merge almende/vis#4091

* The color of vis nodes can be given as a string as well

* add on-initial-draw-complete-support

* change void function type

* [vis] DataSet.get may return null + type parameter for DataSet.map (#32570)

* Update project urls to match NPM url

Note that this *trivially* updates project urls by adding the NPM url to
the end, even when the urls are almost identical or the DT one is
outdated. I'll clean up the urls in a later commit.

This PR is unfinished! Please do not merge it yet.

* Improve @types/vis (#34293)

* Improveme @types/vis

Two improvements:

* Correct optional types on options.node.shapeProperties
* Add types for options.node.margin

* Fix lint

* Make TimelineTooltipOption properties optional

Those properties have default values in vis library so they don't need to be required.

* [@types/vis] add optional parameter to getConnectedNodes (#34820)

* [@types/vis] add optional string types to EdgeOptions (#34972)

* @types/vis Adding Types to Edges.Arrows

Adding Edges.Arrows.To/Middle/From Type

* Correcting contributor link

* Added widthConstraint options to NodeOptions and fixed linting issues (#35683)

* Added widthConstraint for nodeOptions

* Updated definitions

* Added tests

* Fixed lint issues

* Applied warnings from lint

* Vis.  Fix DataGroup mappings for nestedGroups, added visible and showNested to DataGroup as described in vis.js documentation (#35965)

* Add support of subgroupStack on DataGroup

* Update index.d.ts

* Update index.d.ts

Added new SubGroupStackOptions dynamic structure and updated type of DataGroup.subgroupStack to SubGroupStackOptions | boolean

* Update index.d.ts

codestyling

* Update index.d.ts

codestyling colon

* Fix DataGroup mappings for nestedGroups, added visible and showNested to DataGroup as described in vis.js documentation

* DataGroup test

* fix redundant line break

* [@types/vis] add getBaseEdges definition (#36462)

* [@types/vis] add getBaseEdges definition

* [@types/vis] fix trailing spaces

* Create README.md

* chore: move DefinitelyTyped types to Network.d.ts

* chore(types): clean the new types up
yotamberk pushed a commit to visjs/vis-timeline that referenced this issue Sep 7, 2019
* Move all packages to a `types` directory

* Fix various lint errors (#15529)

* All VisJS config options are optional.
http://visjs.org/docs/timeline/#Configuration_Options

* increment version

* Use new strict-export-declare-modifiers lint rule (#15844)

* Updating template function defintion (#15936)

* Updating template function defintion

As mentioned [here](seveves/angular-vis#32) there is a problem with the definition of the template functions. We really should allow any as a return value because you can return a string, Handlebars, mustache or even react templates. As you can see [here](http://visjs.org/docs/timeline/#Templates) the template function always has three parameters. I made them optional because you don't have to use them at all.

* Using fat arrow syntax

I think this is the right way to do it.

* Fix lint error

* Update index.d.ts

added missing DataGroup.nestedGroups according this example: http://visjs.org/examples/timeline/groups/nestedGroups.html

* Update rollingMode option to object.

Timeline implements rolling mode with an object configuration instead boolean type.

* vis: Add types for Options.locales

* Make All LocaleMessages properties required

Also fix lint.

* Merge upstream changes (#3)

* [vis] timeline: add types for custom ordering functions (#20031)

* add types for custom ordering functions

* fix trailing whitespace

* include dependency on moment  (2.13 being the first version to include types)
add type for moment constructor for use in timeline and graph2d options

* timeline: updated TimelineOptions & Timeline (#20174)

* @types/vis separated Node color into it's own interface and added it to the Node (#20603)

* separated node color into it's own interface and added it to the node
definition too.

* tslint fixes

* vis: Fix lint (#20974)

* [vis] Timeline: Type definition changes required for Timeline module on vis.js v4.21

Highlights:
@Timeline
- Documentation added for all methods as per documented in http://visjs.org/docs/timeline/
- Add 3 new definition methods for Timeline in v4.21.0: toggleRollingMode, zoomIn, zoomOut
- Add new type EasingFunction to support the intellisense to be able to choose the type of easing function used in animation

@TimelineEventPropertiesResult
- Add documentations for methods as defined in http://visjs.org/docs/timeline/#getEventProperties

Miscellaneous:
- Rename TimelineFitOptions to TimelineAnimationOptions since the class is intended to tamper with the animation styles.
- Rename TimelineFitAnimationType to TimelineAnimationType as per reason mention on last point and added documentation.

* Add chinese locale.

* Changed type of item for the TimelineEventPropertiesResult to the approperiate type

* Additional font options for NodeOptions and EdgeOptions according to http://visjs.org/docs/network/nodes.html and http://visjs.org/docs/network/edges.html

* Allow Edge arrows from to be left out of edge options

network.setOptions({edges: {arrows: {to: true}}}); should be accepted since it works properly in vis, but previous @types/vis will fail type-checking.

* Add support of subgroupStack on DataGroup (#25480)

* Add support of subgroupStack on DataGroup

* Update index.d.ts

* Update index.d.ts

Added new SubGroupStackOptions dynamic structure and updated type of DataGroup.subgroupStack to SubGroupStackOptions | boolean

* Update index.d.ts

codestyling

* Update index.d.ts

codestyling colon

* vis: update network nodes image option (v4.21)

* Make node and edge interfaces inherit from their options (#27254)

Node and Edge interfaces should inherit from NodeOptions and EdgeOptions. These Options are meant to be global, so properties such as "id", "from" and "to" should exist only on Node and Edge interfaces. Plus, in this way it's possible to use all properties defined on parent interface.

* added order property for TimelineGroup

currently missing from official docs.
awaiting merge almende/vis#4091

* The color of vis nodes can be given as a string as well

* add on-initial-draw-complete-support

* change void function type

* [vis] DataSet.get may return null + type parameter for DataSet.map (#32570)

* Update project urls to match NPM url

Note that this *trivially* updates project urls by adding the NPM url to
the end, even when the urls are almost identical or the DT one is
outdated. I'll clean up the urls in a later commit.

This PR is unfinished! Please do not merge it yet.

* Improve @types/vis (#34293)

* Improveme @types/vis

Two improvements:

* Correct optional types on options.node.shapeProperties
* Add types for options.node.margin

* Fix lint

* Make TimelineTooltipOption properties optional

Those properties have default values in vis library so they don't need to be required.

* [@types/vis] add optional parameter to getConnectedNodes (#34820)

* [@types/vis] add optional string types to EdgeOptions (#34972)

* @types/vis Adding Types to Edges.Arrows

Adding Edges.Arrows.To/Middle/From Type

* Correcting contributor link

* Added widthConstraint options to NodeOptions and fixed linting issues (#35683)

* Added widthConstraint for nodeOptions

* Updated definitions

* Added tests

* Fixed lint issues

* Applied warnings from lint

* Vis.  Fix DataGroup mappings for nestedGroups, added visible and showNested to DataGroup as described in vis.js documentation (#35965)

* Add support of subgroupStack on DataGroup

* Update index.d.ts

* Update index.d.ts

Added new SubGroupStackOptions dynamic structure and updated type of DataGroup.subgroupStack to SubGroupStackOptions | boolean

* Update index.d.ts

codestyling

* Update index.d.ts

codestyling colon

* Fix DataGroup mappings for nestedGroups, added visible and showNested to DataGroup as described in vis.js documentation

* DataGroup test

* fix redundant line break

* [@types/vis] add getBaseEdges definition (#36462)

* [@types/vis] add getBaseEdges definition

* [@types/vis] fix trailing spaces

* Create README.md

* feat(types): set up types in build process

* feat(types): adapt the types for this project

- Remove unrelated types.
- Replace DataSet and DataView by vis-data package.
- Reexport vis-util types.

* chore(dist): update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants