Skip to content

Commit

Permalink
feat: release
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Nov 23, 2024
1 parent cf0d3f3 commit 051d44c
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 114 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is a small chart library for Angular based on D3js. It currently supports single line and multi line charts with a legend. Bar and Donut charts are now supported too. The token service and token interceptor are now included in a configurable manner. The Bar charts, line charts, donut, and Date/Timeline charts and the services are in separate entry points to enable the Angular Compiler to put only the required code in the modules that use the features. Its purpose is to enable fast updates to new Angular versions. To enable the fast updates and due to limited time the library will continue have a small feature set.

## Minimum Supported Angular Version
Angular 18
Angular 19

[![CodeQL](https://github.com/Angular2Guy/ngx-simple-charts/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Angular2Guy/ngx-simple-charts/actions/workflows/codeql-analysis.yml)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-simple-charts",
"version": "19.0.0-beta.1",
"version": "19.0.0",
"license": "Apache License Version 2.0",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-simple-charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is a small chart library for Angular based on D3js. It currently supports single line and multi line charts with a legend. Bar and Donut charts are now supported too. The token service and token interceptor are now included in a configurable manner. The Bar charts, line charts, donut, and Date/Timeline charts and the services are in separate entry points to enable the Angular Compiler to put only the required code in the modules that use the features. Its purpose is to enable fast updates to new Angular versions. To enable the fast updates and due to limited time the library will continue have a small feature set.

## Minimum Supported Angular Version
Angular 18
Angular 19

[![CodeQL](https://github.com/Angular2Guy/ngx-simple-charts/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Angular2Guy/ngx-simple-charts/actions/workflows/codeql-analysis.yml)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class Tuple<A, B> {
}

@Component({
selector: 'sc-bar-chart',
templateUrl: './sc-bar-chart.component.html',
styleUrls: ['./sc-bar-chart.component.scss'],
standalone: false
selector: 'sc-bar-chart',
templateUrl: './sc-bar-chart.component.html',
styleUrls: ['./sc-bar-chart.component.scss'],
standalone: false,
})
export class ScBarChartComponent
implements AfterViewInit, OnChanges, OnDestroy
Expand All @@ -88,7 +88,7 @@ export class ScBarChartComponent

ngAfterViewInit(): void {
this.d3Svg = select<ContainerElement, ChartBar>(
this.chartContainer.nativeElement
this.chartContainer.nativeElement,
);

this.chartUpdateSubscription = this.chartUpdateSubject
Expand All @@ -105,26 +105,26 @@ export class ScBarChartComponent
private calcBarChartsXScalePosition(
contentHeight: number,
minYValue: number,
maxYValue: number
maxYValue: number,
): Tuple<YScalePosition, number> {
const positivePart =
maxYValue / (Math.abs(minYValue) + Math.abs(maxYValue));
let xPosition =
minYValue >= 0 && maxYValue >= 0
? new Tuple<YScalePosition, number>(
YScalePosition.Bottom,
contentHeight - this.chartBars.xScaleHeight
contentHeight - this.chartBars.xScaleHeight,
)
: new Tuple<YScalePosition, number>(
YScalePosition.Middle,
(contentHeight - this.chartBars.xScaleHeight) * positivePart
(contentHeight - this.chartBars.xScaleHeight) * positivePart,
);
//console.log(xPosition);
xPosition =
minYValue <= 0 && maxYValue <= 0
? new Tuple<YScalePosition, number>(
YScalePosition.Top,
this.chartBars.xScaleHeight
this.chartBars.xScaleHeight,
)
: xPosition;
//console.log(xPosition);
Expand All @@ -133,12 +133,12 @@ export class ScBarChartComponent

private updateChart(): void {
const contentWidth = isNaN(
parseInt(this.d3Svg.style('width').replace(/[^0-9\.]+/g, ''), 10)
parseInt(this.d3Svg.style('width').replace(/[^0-9\.]+/g, ''), 10),
)
? 0
: parseInt(this.d3Svg.style('width').replace(/[^0-9\.]+/g, ''), 10);
const contentHeight = isNaN(
parseInt(this.d3Svg.style('height').replace(/[^0-9\.]+/g, ''), 10)
parseInt(this.d3Svg.style('height').replace(/[^0-9\.]+/g, ''), 10),
)
? 0
: parseInt(this.d3Svg.style('height').replace(/[^0-9\.]+/g, ''), 10);
Expand Down Expand Up @@ -167,7 +167,7 @@ export class ScBarChartComponent
const yScalePositionY = this.calcBarChartsXScalePosition(
contentHeight,
minYValue,
maxYValue
maxYValue,
);

// Add Y axis
Expand All @@ -184,46 +184,50 @@ export class ScBarChartComponent
(yScalePositionY.a === YScalePosition.Top
? '' + this.chartBars.xScaleHeight
: '' + 0) +
')'
')',
)
.call(
axisLeft(yScale as unknown as AxisScale<number>) as (
selection: Selection<SVGGElement, ChartBar, HTMLElement, any>,
...args: any[]
) => void
) => void,
);

const yScalePosition = this.calcBarChartsXScalePosition(
contentHeight,
min(yScale.domain()) || 0,
max(yScale.domain()) || 0
max(yScale.domain()) || 0,
);

gxAttribute
.attr(
'transform',
'translate(' + this.chartBars.yScaleWidth + ',' + yScalePosition.b + ')'
'translate(' +
this.chartBars.yScaleWidth +
',' +
yScalePosition.b +
')',
)
.call(
axisBottom(xScale as unknown as AxisScale<number>) as (
selection: Selection<SVGGElement, ChartBar, HTMLElement, any>,
...args: any[]
) => void
) => void,
)
.selectAll('text')
.attr(
'transform',
yScalePosition.a === YScalePosition.Top
? 'translate(-10,-15)rotate(-45)'
: yScalePosition.a === YScalePosition.Bottom
? 'translate(-10,0)rotate(-45)'
: `translate(-10,${
contentHeight - yScalePosition.b - this.chartBars.xScaleHeight
})rotate(-45)`
? 'translate(-10,0)rotate(-45)'
: `translate(-10,${
contentHeight - yScalePosition.b - this.chartBars.xScaleHeight
})rotate(-45)`,
)
.style(
'text-anchor',
yScalePosition.a === YScalePosition.Top ? 'start' : 'end'
yScalePosition.a === YScalePosition.Top ? 'start' : 'end',
);

//console.log(yScale.domain());
Expand All @@ -243,7 +247,7 @@ export class ScBarChartComponent
.join('rect')
.attr(
'x',
(d) => (xScale(d.x) as unknown as number) + this.chartBars.yScaleWidth
(d) => (xScale(d.x) as unknown as number) + this.chartBars.yScaleWidth,
)
.attr('width', xScale.bandwidth())
.attr('height', 0)
Expand All @@ -253,8 +257,8 @@ export class ScBarChartComponent
yScalePosition.a === YScalePosition.Top
? this.chartBars.xScaleHeight
: yScalePosition.a === YScalePosition.Bottom || d.y > 0
? yScale(d.y)
: yScalePosition.b
? yScale(d.y)
: yScalePosition.b,
)
.attr('height', (d) => {
let result = 0;
Expand All @@ -275,7 +279,7 @@ export class ScBarChartComponent
(d) =>
'bar bar-' +
d.x.split(/[^a-zA-Z0-9\-]/)[0].toLowerCase() +
`${d.x === this.chartBars.title ? ' bar-portfolio' : ''}`
`${d.x === this.chartBars.title ? ' bar-portfolio' : ''}`,
)
.delay((d, i) => i * 100);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { RouterModule } from '@angular/router';
})
export class NgxServiceModule {
static forRoot(
config: SimpleChartsConfig
config: SimpleChartsConfig,
): ModuleWithProviders<NgxServiceModule> {
return {
ngModule: NgxServiceModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
limitations under the License.
*/
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse } from '@angular/common/http';
import {
HttpInterceptor,
HttpRequest,
HttpHandler,
HttpEvent,
HttpErrorResponse,
} from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { tap } from 'rxjs/operators';
import { TokenService } from './token.service';
Expand All @@ -22,16 +28,16 @@ export class TokenInterceptor implements HttpInterceptor {

intercept(
req: HttpRequest<any>,
next: HttpHandler
next: HttpHandler,
): Observable<HttpEvent<any>> {
req = req.clone({
headers: this.tokenService.createTokenHeader(),
});
return next.handle(req).pipe(
tap(
(event) => event,
(event) => this.handleError(event)
)
(event) => this.handleError(event),
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class TokenService {
constructor(
private http: HttpClient,
private router: Router,
@Inject(MODULE_CONFIG) private moduleConfig: SimpleChartsConfig
@Inject(MODULE_CONFIG) private moduleConfig: SimpleChartsConfig,
) {}

private refreshToken(): Observable<RefreshTokenResponse> {
Expand Down Expand Up @@ -116,11 +116,11 @@ export class TokenService {
takeUntil(myStopTimer),
switchMap(() => this.refreshToken()),
retry({ count: 3, delay: 2000, resetOnSuccess: true }),
shareReplay(this.CACHE_SIZE)
shareReplay(this.CACHE_SIZE),
);
this.myTokenSubscription = this.myTokenCache.subscribe(
(newToken) => (this.myToken = newToken.refreshToken),
() => this.clear()
() => this.clear(),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ScDateTimeChartBase {
.reduce(
(acc, myItem) =>
(myItem as Date).valueOf() < (acc as Date).valueOf() ? myItem : acc,
new Date()
new Date(),
) as Date;
//console.log(this.localStart);
/*
Expand Down Expand Up @@ -68,8 +68,8 @@ export class ScDateTimeChartBase {
openEndItems.length > 0 || !this.localShowDays
? endOfYear
: lastEndYear < 1
? endOfYear
: lastEndItem.end;
? endOfYear
: lastEndItem.end;
this.periodDays = [];
for (
let myDay = DateTime.fromObject({
Expand All @@ -95,7 +95,7 @@ export class ScDateTimeChartBase {
) {
this.periodMonths.push(myMonth);
this.monthHeaderAnchorIds.push(
'M_' + this.generateHeaderAnchorId(myMonth)
'M_' + this.generateHeaderAnchorId(myMonth),
);
}
this.periodYears = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[id]="monthHeaderAnchorIds[indexOfElement]"
[style.width.px]="periodMonth.daysInMonth * (DAY_WIDTH + 2) - 2"
>
{{ periodMonth.toJSDate() | date : "MMMM YYYY" }}
{{ periodMonth.toJSDate() | date: "MMMM YYYY" }}
</div>
</div>
<div class="header-line">
Expand All @@ -34,7 +34,7 @@
[class.header-sunday]="periodDay.weekday === 7"
[style.width.px]="DAY_WIDTH"
>
{{ periodDay.toJSDate() | date : "dd" }}
{{ periodDay.toJSDate() | date: "dd" }}
</div>
</div>
</ng-container>
Expand All @@ -55,7 +55,7 @@
class="header-box"
[style.width.px]="MONTH_WIDTH"
>
{{ periodMonth.toJSDate() | date : "MMMM" }}
{{ periodMonth.toJSDate() | date: "MMMM" }}
</div>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ interface LineKeyToItems {
}

@Component({
selector: 'sc-date-time-chart',
templateUrl: './sc-date-time-chart.component.html',
styleUrls: ['./sc-date-time-chart.component.scss'],
standalone: false
selector: 'sc-date-time-chart',
templateUrl: './sc-date-time-chart.component.html',
styleUrls: ['./sc-date-time-chart.component.scss'],
standalone: false,
})
export class ScDateTimeChartComponent
extends ScDateTimeChartBase
Expand Down Expand Up @@ -61,14 +61,14 @@ export class ScDateTimeChartComponent
setTimeout(() => {
let myPeriods = !this.showDays ? this.periodYears : this.periodMonths;
myPeriods = myPeriods.filter(
(myPeriod) => myPeriod.diffNow().seconds <= 0
(myPeriod) => myPeriod.diffNow().seconds <= 0,
);
const myPeriodIndex = myPeriods.length === 0 ? -1 : myPeriods.length - 1;
if (myPeriodIndex >= 0) {
this.scrollToAnchorId(
!this.showDays
? this.yearHeaderAnchorIds[myPeriodIndex]
: this.monthHeaderAnchorIds[myPeriodIndex]
: this.monthHeaderAnchorIds[myPeriodIndex],
);
}
this.calcTimeChartValues();
Expand Down Expand Up @@ -125,7 +125,7 @@ export class ScDateTimeChartComponent
});
const itemInterval = Interval.fromDateTimes(
chartStart,
!!start ? DateTime.fromJSDate(start) : chartStart
!!start ? DateTime.fromJSDate(start) : chartStart,
);
const itemPeriods = !this.showDays
? itemInterval.length('months')
Expand All @@ -139,7 +139,7 @@ export class ScDateTimeChartComponent
const chartEnd = DateTime.fromJSDate(this.end);
const itemInterval = Interval.fromDateTimes(
DateTime.fromJSDate(end),
chartEnd
chartEnd,
);
const itemPeriods = !this.showDays
? itemInterval.length('months')
Expand Down Expand Up @@ -188,8 +188,8 @@ export class ScDateTimeChartComponent
this.anchoreIdIndex + timeDiff < 0
? 0
: this.anchoreIdIndex + timeDiff >= anchorIds.length
? anchorIds.length - 1
: this.anchoreIdIndex + timeDiff;
? anchorIds.length - 1
: this.anchoreIdIndex + timeDiff;
this.scrollToAnchorId(anchorIds[this.anchoreIdIndex]);
}

Expand Down
Loading

0 comments on commit 051d44c

Please sign in to comment.