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

Fix: Disable chart toolbar by default in chart directives and added a simple method for displaying or not the toolbar directly from a boolean in the configuration #29

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class BarChartDirective<X extends XaxisType> implements ChartView<X, numb

private readonly chartInstance = signal<ApexCharts | null>(null);

private _chartConfig: ChartProvider<X, number> = {};
private _chartConfig: ChartProvider<X, number> = {showToolbar: false};
private _options: any = {
chart: {
type: 'bar'
Expand Down Expand Up @@ -105,7 +105,7 @@ export class BarChartDirective<X extends XaxisType> implements ChartView<X, numb
width: this._chartConfig.width ?? '100%',
stacked: this._chartConfig.stacked,
toolbar: {
show: true,
show: this._chartConfig.showToolbar ?? false,
tools: {
download: false,
selection: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LineChartDirective<X extends XaxisType, Y extends YaxisType> implem

private readonly chartInstance = signal<ApexCharts | null>(null);

private _chartConfig: ChartProvider<X, Y> = {};
private _chartConfig: ChartProvider<X, Y> = {showToolbar: false};

private _options: any = {
chart: {
Expand Down Expand Up @@ -104,7 +104,7 @@ export class LineChartDirective<X extends XaxisType, Y extends YaxisType> implem
width: this._chartConfig.width ?? '100%',
stacked: this._chartConfig.stacked,
toolbar: {
show: true,
show: this._chartConfig.showToolbar ?? false,
tools: {
download: false,
selection: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class PieChartDirective implements ChartView<string, number>, OnChanges,
'radar': 'radar'
}

private _chartConfig: ChartProvider<string, number> = {};
private _chartConfig: ChartProvider<string, number> = {showToolbar: false};
private _options: any = {
chart: {
type: 'pie'
Expand Down Expand Up @@ -110,7 +110,7 @@ export class PieChartDirective implements ChartView<string, number>, OnChanges,
height: this._chartConfig.height ?? '100%',
width: this._chartConfig.width ?? '100%',
toolbar: {
show: true,
show: this._chartConfig.showToolbar ?? false,
tools: {
download: false,
selection: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class RangeChartDirective<X extends XaxisType> implements ChartView<X, nu

private readonly chartInstance = signal<ApexCharts | null>(null);

private _chartConfig: ChartProvider<X, number[]> = {};
private _chartConfig: ChartProvider<X, number[]> = {showToolbar: false};

private _options: any = {
chart: {
Expand Down Expand Up @@ -106,7 +106,7 @@ export class RangeChartDirective<X extends XaxisType> implements ChartView<X, nu
height: this._chartConfig.height ?? '100%',
width: this._chartConfig.width ?? '100%',
toolbar: {
show: true,
show: this._chartConfig.showToolbar ?? false,
tools: {
download: false,
selection: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TreemapChartDirective implements ChartView<string, number>, OnChang

private readonly chartInstance = signal<ApexCharts | null>(null);

private _chartConfig: ChartProvider<string, number> = {};
private _chartConfig: ChartProvider<string, number> = {showToolbar: false};
private _options: any = {
chart: {
type: 'treemap'
Expand Down Expand Up @@ -104,7 +104,7 @@ export class TreemapChartDirective implements ChartView<string, number>, OnChang
height: this._chartConfig.height ?? '100%',
width: this._chartConfig.width ?? '100%',
toolbar: {
show: true,
show: this._chartConfig.showToolbar ?? false,
tools: {
download: false,
selection: false,
Expand Down
4 changes: 3 additions & 1 deletion projects/oneteme/jquery-core/src/lib/jquery-core.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function buildChart<X extends XaxisType, Y extends YaxisType>(objects: an
function newChart<X extends XaxisType, Y extends YaxisType>(provider: ChartProvider<X,Y>) : CommonChart<X,Y>{
return Object.entries(provider)
.filter(e=> ['series'].indexOf(e[0])<0)
.reduce((acc,e)=>{acc[e[0]] = e[1]; return acc;}, {series:[]})
.reduce((acc,e)=>{acc[e[0]] = e[1]; return acc;}, {series:[]});
}

function resolveDataProvider<T>(provider?: T | DataProvider<T>, defaultValue?: T): DataProvider<T> {
Expand Down Expand Up @@ -164,6 +164,7 @@ export interface ChartProvider<X extends XaxisType, Y extends YaxisType> { //rm
xorder?: Sort;
series?: SerieProvider<X,Y>[];
options?: any;
showToolbar?: boolean;
}

export interface SerieProvider<X extends XaxisType, Y extends YaxisType> { //rm SerieProvider
Expand Down Expand Up @@ -201,6 +202,7 @@ export interface CommonChart<X extends XaxisType, Y extends YaxisType | Coordina
stacked?: boolean;
xorder?: Sort;
options?: any;
// showToolbar?: boolean;
antonin77 marked this conversation as resolved.
Show resolved Hide resolved
}

export interface CommonSerie<Y extends YaxisType | Coordinate2D> {
Expand Down
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AppComponent {
{ count_2xx: 110, count_4xx: 160, count_5xx: 80 }
],
config: {
showToolbar: true, // for testing
series: [
{ data: { x: values('2xx'), y: field('count_2xx') }, name: 'Mapper 1', color: '#2E93fA' },
{ data: { x: values('4xx'), y: field('count_4xx') }, name: 'Mapper 2', color: '#66DA26' },
Expand Down
Loading