Skip to content

Commit 6926742

Browse files
author
cihan emre kisakurek
committed
fix
1 parent ca47fee commit 6926742

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

resources/views/livewire/compositechart.blade.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div wire:ignore>
2-
<div style="position: relative; height:40vh;">
2+
<div style="position: relative;">
33
<canvas id="{{ $chart_id }}"></canvas>
44
</div>
55
</div>
@@ -20,8 +20,13 @@
2020
grid: @json($x_grid),
2121
ticks: {
2222
callback: function(value, index, ticks) {
23-
let formatted = Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]);
24-
return String("{!! $left_x_unit !!}") + formatted + String("{!! $right_x_unit !!}");
23+
let formatterName = String("{!! $formatter_name !!}");
24+
if(formatterName === 'number') {
25+
let formatted = Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]);
26+
return String("{!! $left_x_unit !!}") + formatted + String("{!! $right_x_unit !!}");
27+
} else {
28+
return String("{!! $left_x_unit !!}") + this.getLabelForValue(value) + String("{!! $right_x_unit !!}");
29+
}
2530
}
2631
}
2732
},
@@ -32,8 +37,13 @@
3237
grid: @json($y_grid),
3338
ticks: {
3439
callback: function(value, index, ticks) {
35-
let formatted = Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]);
36-
return String("{!! $left_y_unit !!}") + formatted + String("{!! $right_y_unit !!}");
40+
let formatterName = String("{!! $formatter_name !!}");
41+
if(formatterName === 'number') {
42+
let formatted = Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]);
43+
return String("{!! $left_y_unit !!}") + formatted + String("{!! $right_y_unit !!}");
44+
} else {
45+
return String("{!! $left_y_unit !!}") + this.getLabelForValue(value) + String("{!! $right_y_unit !!}");
46+
}
3747
}
3848
}
3949
},
@@ -43,8 +53,13 @@
4353
grid: @json($y1_grid),
4454
ticks: {
4555
callback: function(value, index, ticks) {
46-
let formatted = Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]);
47-
return String("{!! $left_y1_unit !!}") + formatted + String("{!! $right_y1_unit !!}");
56+
let formatterName = String("{!! $formatter_name !!}");
57+
if(formatterName === 'number') {
58+
let formatted = Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]);
59+
return String("{!! $left_y1_unit !!}") + formatted + String("{!! $right_y1_unit !!}");
60+
} else {
61+
return String("{!! $left_y1_unit !!}") + this.getLabelForValue(value) + String("{!! $right_y1_unit !!}");
62+
}
4863
}
4964
}
5065
}

src/CompositeChart.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class CompositeChart extends Component
1515
public $show_left_axis = true;
1616
public $canvas_background_color = 'rgba(255, 255, 255, 1.0)';
1717

18+
public $formatter_name = 'default';
19+
1820
public $left_x_unit = '';
1921
public $right_x_unit = '';
2022

0 commit comments

Comments
 (0)