Skip to content

Commit

Permalink
Edit methods and styles of both charts
Browse files Browse the repository at this point in the history
  • Loading branch information
Novruu committed Nov 20, 2024
1 parent b8709cd commit 1ce8b4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ class MS.Views.DashboardLoansActiveStackChart extends Backbone.View
@element = params.el
@loansData = params.loans_data
@defaultChartOptions = {
height: 400,
width: '100%'
backgroundColor: 'none',
isStacked: true,
chartArea: {
left: 60
width: '100%',
height: '90%'
left: '60px'
width: '80%',
height: '100%'
},
hAxis: {
minValue: 0,
Expand Down Expand Up @@ -94,14 +92,20 @@ class MS.Views.DashboardLoansActiveStackChart extends Backbone.View
# position of the text elements in the center of each row
# Unfortunately, this is the only way to do this
@observer = new MutationObserver( ->
for annotation in $('text')
if !annotation.nextSibling
for annotation in $('text', element)
svg_els = [annotation.previousSibling, annotation, annotation.nextSibling]

if !svg_els[1] || !svg_els[2]
continue
chart_box = chart_box || layout.getChartAreaBoundingBox()
text_box = annotation.getBoundingClientRect()

annotation.setAttribute('x', chart_box.left + (chart_box.width / 2) - (text_box.width / 2))
annotation.setAttribute('text-anchor', 'start')
chart_box = chart_box || layout.getChartAreaBoundingBox()
for svg_el, index in svg_els
if !svg_el
continue
box = svg_el.getBoundingClientRect()
svg_el.setAttribute('x', chart_box.left + (chart_box.width / 2) - (box.width / 2))
if index == 1
svg_el.setAttribute('text-anchor', 'start')
)

@observer.observe(element, { childList: true, subtree: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class MS.Views.DashboardLoansChart extends Backbone.View
#@loansDataData = [{'name': 'status1', 'amount':10},{'name': 'status2', 'amount':20},{'name': 'status3', 'amount':30},{'name': 'status4', 'amount':40},{'name': 'status5', 'amount':50},{'name': 'status6', 'amount':60}]
@locale = params.locale
@defaultChartOptions = {
height: 400,
width: '100%',
chartArea: {
left: 20,
top: 20,
Expand Down

0 comments on commit 1ce8b4e

Please sign in to comment.