wrong context of AxisTickFormatting methods
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here
Current behavior
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { DatePipe } from '@angular/common';
@Component({
selector: 'app-value-history',
template: `
<ngx-charts-line-chart
[xAxisTickFormatting]="xAxisTickFormatting"
</ngx-charts-line-chart>
`
})
export class ValueHistoryComponent {
// ...
constructor(private datePipe: DatePipe) { }
xAxisTickFormatting(value) {
return this.datePipe.transform(value, 'short');
}
}
throws an error:
TypeError: Cannot read property 'transform' of undefined
at XAxisTicksComponent.webpackJsonp.479.ValueHistoryComponent.xAxisTickFormatting (value-history.component.ts:60)
because the this
in the formatting function seems to be the internal xAxisTickComponent
Expected behavior i expect to be able to use the injected datePipe in the AxisTickFormatting function
Reproduction of the problem see example above
What is the motivation / use case for changing the behavior? i want to use angular2 LOCALE_ID to format the date for various countries
Please tell us about your environment: OSX / Webstorm
- ngx-charts version: 4.2.0
- Angular version: 4.0.0-rc0 (ng-cli 1.0.0-rc.0)
- Browser: all
- Language: Typescript -> es5
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:17 (4 by maintainers)
Top Results From Across the Web
swimlane/ngx-charts - Gitter
Hi, I am looking for extend the lib. i am looking to add a funnel chart to begin with but maybe others in...
Read more >Ngxcharts Only Updating On Hover - ADocLib
Solvedngx charts wrong context of AxisTickFormatting methods i expect to be able to use the injected datePipe in the AxisTickFormatting function.
Read more >Changelog - ngx-charts - GitBook
Bug: Fixed error being thrown when results is undefined (#217) ... Enhancement: Added x-axis value to the context of a bubble chart tooltip...
Read more >Source code for dms_tools2.plot
Useful for nice axis-tick formatting. ... Number): isnum = True xlist = [xlist] else: isnum = False formatlist = [] for x in...
Read more >ng2-charts | Yarn - Package Manager
Access to the .toBase64Image() method #325 ... #656; self.parent.context. ... Adding CHART_DIRECTIVES causes app to error #258; Y Axis Tick Formatting #254 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
[xAxisTickFormatting]="xFormat"
// in your template guys just simple declare function like this:@rutemja you need to do it in your component:
public xAxisTickFormattingFn = this.xAxisTickFormatting.bind(this);
Then just use
xAxisTickFormattingFn
in your template