Skip to content

Instantly share code, notes, and snippets.

@darrenjaworski
Last active December 16, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjaworski/5389708 to your computer and use it in GitHub Desktop.
Save darrenjaworski/5389708 to your computer and use it in GitHub Desktop.
Sunburst Partition - OK State Budget

The Oklahoma State Budget presented using a sunburst partition rendered in D3. Zoom and labeling are present, but create problems. Because of the cluster of text I created a restricting radio button that limits the text on command for less clutter. Data for 2010-2011 needs to be updated to allow for more visualizations.

{
"name": "Oklahoma Budget 2013",
"appropriation14": 7113700501,
"appropriation13": 6948363588,
"appropriation12": 6433088405,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 7192763489,
"children": [
{
"name": "Health",
"appropriation14": 1353506414,
"appropriation13": 1295187762,
"appropriation12": 1154810182,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 1126729503,
"annotation": "Health care expenditures account for 19% of legislative appropriations. The biggest portion finances the state’s share of Medicaid spending for poor and disabled Oklahomans. The federal government also contributes to these programs.",
"children": [
{
"name": "Department Health",
"appropriation14": 62983682,
"appropriation13": 61783682,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 75028113,
"appropriation12": 59477971,
"annotation": "There is a proposed a 1% funding increase for the Department of Health, which oversees community clinics and programs throughout the state. The new funds would be used to expand programs targeting Oklahoma’s high infant mortality death rate."
},
{
"name": "Health Care Authority",
"appropriation14": 961701274,
"appropriation13": 921983007,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 842122261,
"appropriation12": 912219389,
"annotation": "OCHA oversees the SoonerCare program, which dispenses federal and state Medicaid funds to serve qualified poor and disabled Oklahomans. It receives 14% of total state appropriations. There is a proposed 4.3% funding increase for 2014, much of which would be used to cover the cost of new enrollments resulting from implementation of the federal government’s Medicaid expansion."
},
{
"name": "Mental Health",
"appropriation14": 328821458,
"appropriation13": 311421073,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 209579129,
"appropriation12": 183112822,
"annotation": "The Department of Mental Health would receive one of the largest percentage increases—5.9%—of all major state agencies under the proposed 2014 budget. The additional money would be used to open new mental health crisis centers and provide more services for troubled children, prescription drug abusers and people at risk of suicide. The department currently receives 5% of all state appropriations."
}
]
},
{
"name": "Education",
"appropriation14": 3555885208,
"appropriation13": 3453676479,
"appropriation13": 3453676479,
"appropriation12": 3383750778,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 3760744494,
"annotation": "Oklahoma’s K-12 schools and higher education institutions absorb 50% of all legislative appropriations. Elementary and secondary schools also receive local property tax revenue, while college and universities receive student tuition and fees.",
"children": [
{
"name": "Department Education",
"appropriation14": 2407604082,
"appropriation13": 2333604082,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2531702553,
"appropriation12": 2278158382,
"annotation": "The Oklahoma Department of Education accounts for the biggest single share—34%—of all legislative appropriations to help finance more than 1,700 elementary and secondary schools spread across more than 500 school districts. A 3% funding increase is proposed for 2014, but legislative leaders have indicated they might increase that amount. Public schools also receive significant amounts of funding from local property taxes and federal funds."
},
{
"name": "Regents Higher Education",
"appropriation14": 988549006,
"appropriation13": 955260278,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 1039886280,
"appropriation12": 945260277,
"annotation": "The Oklahoma State Regents For Higher Education receive 14% of legislative appropriations to help finance a system consisting of 25 universities and community colleges. Higher education institutions also receive funding from student tuition and fees and donor endowments, and the state share has been declining over time. Universities have complained about the long term declines in state funding."
},
{
"name": "Career Technology Education",
"appropriation14": 138142618,
"appropriation13": 135142618,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 158269736,
"appropriation12": 133742618,
"annotation": "The Department of Career and Technology Education receives only 2% of legislative appropriations, but oversees vocational programs in 400 public school districts, 29 technology centers and 16 correctional facilities."
},
{
"name": "Misc. Education",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes Arts Council, Educational Television Authority, Department of Libraries, School of Science and Math, and Teacher Preparation Commission.",
"children": [
{
"name": "Arts Council",
"appropriation14": 4010087,
"appropriation13": 4010087,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 5150967,
"appropriation12": 4010087
},
{
"name": "Educational Television Authority",
"appropriation14": 3822328,
"appropriation13": 3822328,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 8394383,
"appropriation12": 3822328
},
{
"name": "Department Libraries",
"appropriation14": 5898633,
"appropriation13": 5898633,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 7294856,
"appropriation12": 5898633
},
{
"name": "School Science and Math",
"appropriation14": 6332274,
"appropriation13": 6332274,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 7985737,
"appropriation12": 6332274
},
{
"name": "Teacher Preparation Commission",
"appropriation14": 1526180,
"appropriation13": 1526179,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2059982,
"appropriation12": 1526179
},
{
"name" : "Educational Quality Accountability",
"appropriation14" : 661271
}
]
}
]
},
{
"name": "Human Services",
"appropriation14": 815389858,
"appropriation13": 765683858,
"appropriation13": 765683858,
"appropriation12": 689305061,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 757921731,
"annotation": "Human Services spending is 11.02% of overall appropriations, divided among Juvenile Affairs, the Department of Human Services, The Department of Rehabilitation Services, and the University Hospital Authority, amongst others.",
"children": [
{
"name": "Juvenile Affairs",
"appropriation14": 98187205,
"appropriation13": 96187205,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 112254258,
"appropriation12": 96187205
},
{
"name": "Department Human Services",
"appropriation14": 630958664,
"appropriation13": 586958664,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 559107190,
"appropriation12": 514518301,
"annotation" : "With increasing demands for services for the state's needy and disadvantage populations. A relatively large increase is being proposed in human services."
},
{
"name": "Misc. Human Services",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes J.D. McCarty Center, Physician Manpower Training, Department of Rehabilitation Services, University Hospitals Authority, Children and Youth Commission, and Disability Concerns.",
"children": [
{
"name": "J.D. McCarty Center",
"appropriation14": 4140338,
"appropriation13": 3740338,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 4452961,
"appropriation12": 3359210
},
{
"name": "Physician Manpower Training",
"appropriation14": 4279254,
"appropriation13": 4379254,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 5523502,
"appropriation12": 4379254
},
{
"name": "Department Rehabilitative Services",
"appropriation14": 30949232,
"appropriation13": 30449232,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 30053770,
"appropriation12": 30149232
},
{
"name": "University Hospitals Authority",
"appropriation14": 44530391,
"appropriation13": 41624391,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 43250342,
"appropriation12": 38446391
},
{
"name": "Sub-Misc. Human Services",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes Children and Youth Commission and the Disability Concerns.",
"children": [
{
"name": "Children and Youth Commission",
"appropriation14": 2027167,
"appropriation13": 2027167,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2608473,
"appropriation12": 2027167
},
{
"name": "Disability Concerns",
"appropriation14": 317607,
"appropriation13": 317607,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 412769,
"appropriation12": 317607
}
]
}
]
}
]
},
{
"name": "Safety",
"appropriation14": 662998659,
"appropriation13": 653891659,
"appropriation12": 639191659,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 717966959,
"annotation": "Safety and Security spending is 9.41% of overall appropriations, divided among the Department of Corrections, the Department of Public Safety, and others including the State Bureau of Investigation.",
"children": [
{
"name": "Department Corrections",
"appropriation14": 463731068,
"appropriation13": 463731068,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 503000000,
"appropriation12": 459831068,
"annotation" : "DOC would get no increase over last year and remain below 2009 levels. Gov. Mary Fallin's office is upset that the department did not disclose the true amount of money, $22 million, in three revolving accounts. Corrections officers are mad at not getting a raise."
},
{
"name": "Department Public Safety",
"appropriation14": 90416790,
"appropriation13": 89894790,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 97170391,
"appropriation12": 84894790,
"annotation" : "DPS would get a small increase, but, like other state employees, its troopers would get no raise. The Tulsa World reported more than a quarter are near retirement."
},
{
"name": "Misc. safety",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes the A.B.L.E. Commission, Attorney General, District Attorneys Council, Emergency Management, Fire Marshal, Indigent Defense System, State Bureau of Investigation, LEET, Medicolegal Investigations, NDDC and the Pardon and Parole Board.",
"children": [
{
"name": "A.B.L.E. Commission",
"appropriation14": 3140334,
"appropriation13": 3140334,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 3925266,
"appropriation12": 3140334,
"annotation": "A.B.L.E is Alcoholic Beverage Law Enforcement."
},
{
"name" : "Supreme Court",
"appropriation14" : 17300000,
"appropriation13" : 17337000,
"appropriation12": 17300000,
"appropriation11": 15381358,
"appropriation10": 16550345,
"appropriation09": 19247063
},
{
"name" : "District Courts",
"appropriation14" : 59600000,
"appropriation13" : 59600000,
"appropriation12": 59600000,
"appropriation11": 57641865,
"appropriation10": 52502812,
"appropriation09": 58067785
},
{
"name" : "Criminal Appeals Court",
"appropriation14" : 3634631,
"appropriation13" : 3484631,
"appropriation12": 3455575,
"appropriation11": 3455575,
"appropriation10": 3056707,
"appropriation09": 3474527
},
{
"name" : "Workers Compensation Commission",
"appropriation14" : 5747166,
"appropriation13" : 4747166,
"appropriation12": 4197166,
"appropriation11": 4349395,
"appropriation10": 16550345,
"appropriation09": 19247063
},
{
"name": "Attorney General",
"appropriation14": 15228141,
"appropriation13": 15228141,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 14781704,
"appropriation12": 13228141
},
{
"name": "District Attorneys Council",
"appropriation14": 39687258,
"appropriation13": 34187258,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 42820210,
"appropriation12": 32887258
},
{
"name": "Emergency Management",
"appropriation14": 651179,
"appropriation13": 651179,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 1156604,
"appropriation12": 651179
},
{
"name": "Fire Marshal",
"appropriation14": 1796764,
"appropriation13": 1796764,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2270855,
"appropriation12": 1796764
},
{
"name": "Indigent Defense System",
"appropriation14": 15699353,
"appropriation13": 14699353,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 16734008,
"appropriation12": 14699353
},
{
"name": "State Bureau of Investigation",
"appropriation14": 14283059,
"appropriation13": 13848059,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 17316450,
"appropriation12": 13848059
},
{
"name": "LEET",
"appropriation14": 3757560,
"appropriation13": 3682560,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 4614625,
"appropriation12": 3682560,
"annotation": "LEET is Law Enforcement Education and Training."
},
{
"name": "Medicolegal Investigations",
"appropriation14": 8698281,
"appropriation13": 7198281,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 4825625,
"appropriation12": 4698281
},
{
"name": "NDDC",
"appropriation14": 3616418,
"appropriation13": 3616418,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 6773895,
"appropriation12": 3616418,
"annotation": "NDDC is Narcotics and Dangerous Drugs Control."
},
{
"name": "Pardon and Parole Board",
"appropriation14": 2292454,
"appropriation13": 2217454,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2577581,
"appropriation12": 2217454
}
]
}
]
},
{
"name": "Transportation",
"appropriation14": 209101708,
"appropriation13": 206800291,
"appropriation12": 107131628,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 208221788,
"annotation": "Oklahoma’s transportation network receives only 3% of legislative appropriations, but the money is supplemented by non-appropriated state revenue and federal funding. The proposed 2014 budget includes a 1% increase. Gov. Mary Fallin said her top priority was to reduce the number of structurally deficient bridges.",
"children": [
{
"name": "Space Industry",
"appropriation14": 394589,
"appropriation13": 394589,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 530340,
"appropriation12": 394589
},
{
"name": "Department Transportation",
"appropriation14": 208707119,
"appropriation13": 206405702,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 207691448,
"appropriation12": 106737039
}
]
},
{
"name": "Misc.",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes the Office of Finance and Revenue, Tax Commission, and misc. Finance.",
"children": [
{
"name": "Finance and Revenue",
"appropriation14": 117418179,
"appropriation13": 113545929,
"appropriation12": 83888022,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 92503091,
"annotation": "Finance and Revenue spending accounts for 1.63% of overall appropriations, divid among the Tax Commission, the Treasurer, the land Office Commissioners, and Management and Enterprise Services amongst others.",
"children": [
{
"name": "Tax Commission",
"appropriation14": 46915944,
"appropriation13": 46915944,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 50201340,
"appropriation12": 46915944
},
{
"name": "Misc. Finance",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes Auditor and Inspector, Management and enterprise services, the Department of Insurance, Land office Commissioner and the Treasurer as well as a sub category of miscellaneous",
"children": [
{
"name": "Auditor and Inspector",
"appropriation14": 4706986,
"appropriation13": 4706986,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 6315269,
"appropriation12": 4706986
},
{
"name": "Management and enterprise services",
"appropriation14": 45132347,
"appropriation13": 40132347,
"percentChange13": 109.25,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation12": 19179440
},
{
"name": "Insurance Commissioner",
"appropriation14": 1871937,
"appropriation13": 1871937,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2515943,
"appropriation12": 1871937
},
{
"name": "Land Office Commissioners",
"appropriation14": 15062250,
"appropriation13": 16000000,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 4864881,
"appropriation12": 7109000
},
{
"name": "Treasurer",
"appropriation14": 3553873,
"appropriation13": 3743873,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 4668763,
"appropriation12": 3629873
},
{
"name": "Sub-Misc. Finance",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes the Bond Advisor and the Consumer Credit Commission.",
"children": [
{
"name": "Bond Advisor",
"appropriation14": 143112,
"appropriation13": 143112,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 186419,
"appropriation12": 143112
},
{
"name": "Department Consumer Credit",
"appropriation14": 31730,
"appropriation13": 31730,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 669042,
"appropriation12": 331730
}
]
}
]
}
]
},
{
"name": "Science Technology Development",
"appropriation14": 17811449,
"appropriation13": 17811449,
"appropriation12": 17811449,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 22456507,
"annotation": "Science and Technology Development accounts for 0.26% of overall appropriations, with all funding going to the Center for Advancement of Science and Technology.",
"children": [
{
"name": "Center for Science",
"appropriation14": 17811449,
"appropriation13": 17811449,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 22456507,
"appropriation12": 17811449
}
]
},
{
"name": "Misc.",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes Military, Secretary of State, Governor, Lt. Governor, Energy, and Human Resources.",
"children": [
{
"name": "Drought Relief Fund",
"appropriation14": 3000000
},
{
"name": "Maintenance Revolving Fund",
"appropriation14": 30000000
},
{
"name": "OSU Hospital",
"appropriation14": 13000000,
"appropriation13": 8080000,
"appropriation12": 5000000,
"appropriation11": 5000000
},
{
"name": "Military",
"appropriation14": 11747997,
"appropriation13": 10747997,
"appropriation12": 10247997,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 13132301,
"annotation": "Military affairs account for 0.15% of overall spending containing only the Military Department.",
"children": [
{
"name": "Department of Military Affairs",
"appropriation14": 11747997,
"appropriation13": 10747997,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 13132301,
"appropriation12": 10247997
}
]
},
{
"name": "Secretary of State",
"appropriation14": 8543937,
"appropriation13": 8393937,
"appropriation12": 8403937,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 8138194,
"annotation": "Secretary of State spending accounts for 0.12% of overall spending, divided among the Election Board, Ethics Commission, Judicial Complaints.",
"children": [
{
"name": "Election Board",
"appropriation14": 7805808,
"appropriation13": 7805808,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 6805988,
"appropriation12": 7805808
},
{
"name": "Ethics Commission",
"appropriation14": 738129,
"appropriation13": 588129,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 667960,
"appropriation12": 523129
},
{
"name": "Secretary of State",
"appropriation14": 0,
"appropriation13": 0,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 380517,
"appropriation12": 0
}
]
},
{
"name": "Governor",
"appropriation14": 2172900,
"appropriation13": 2172900,
"appropriation12": 1980594,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2661981,
"children": [
{
"name": "Governor",
"appropriation14": 2172900,
"appropriation13": 2172900,
"appropriation12": 1980594,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2661981
}
]
},
{
"name": "Lt. Governor",
"appropriation14": 506291,
"appropriation13": 506591,
"appropriation12": 506591,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 659597,
"children": [
{
"name": "Lt. Governor",
"appropriation14": 506291,
"appropriation13": 506591,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 659597,
"appropriation12": 506591
}
]
},
{
"name": "Energy",
"appropriation14": 12203566,
"appropriation13": 12103566,
"appropriation12": 12103566,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 13429003,
"annotation": "Energy spending accounts for 0.17% of overall appropriations, divided between the Corporation Commission and the Department of Mines.",
"children": [
{
"name": "Corporation Commission",
"appropriation14": 11324427,
"appropriation13": 11324427,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 12415417,
"appropriation12": 11324427
},
{
"name": "Department Mines",
"appropriation14": 879139,
"appropriation13": 779139,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 1013586,
"appropriation12": 779139
}
]
},
{
"name": "Human Resources",
"appropriation14": 2563134,
"appropriation13": 2563134,
"appropriation12": 24047311,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 27598398,
"annotation": "Human Resources Administration spending accounts for 0.04% of overall appropriations, divided between the Merit Protection Commission and the Horse Racing Commission.",
"children": [
{
"name": "Horse Racing Commission",
"appropriation14": 2072167,
"appropriation13": 2072167,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 2669568,
"appropriation12": 2072167
},
{
"name": "Merit Protection Commission",
"appropriation14": 490967,
"appropriation13": 490967,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 613684,
"appropriation12": 490967
}
]
}
]
},
{
"name": "Veterans",
"appropriation14": 35698752,
"appropriation13": 35698752,
"appropriation12": 34698752,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 40282600,
"annotation": "Veterans spending accounts for 0.51% of overall appropriations, with the Department of Veterans accounting for all veterans related spending.",
"children": [
{
"name": "Department Veterans",
"appropriation14": 35698752,
"appropriation13": 35698752,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 40282600,
"appropriation12": 34698752
}
]
},
{
"name": "Legislature",
"appropriation14": 39639306,
"appropriation13": 32639306,
"appropriation12": 30639306,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 39412908,
"annotation": "The Legislature accounts for 0.47% of overall appropriations, divided among the House, Senate, and Legislative Services.",
"children": [
{
"name": "House",
"appropriation14": 16574682,
"appropriation13": 15574682,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 19176434,
"appropriation12": 14574682
},
{
"name": "Senate",
"appropriation14": 13171789,
"appropriation13": 12171789,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 14699125,
"appropriation12": 11171789
},
{
"name": "Legislative Services",
"appropriation14": 9892835,
"appropriation13": 4892835,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 5537349,
"appropriation12": 4892835
}
]
},
{
"name": "Environment",
"appropriation14": 16057644,
"appropriation13": 14557644,
"appropriation12": 13057644,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 16529620,
"annotation": "Environment related spending accounts for 0.21% of overall appropriations, divided between the Water Resources Board, Department of Environmental Quality.",
"children": [
{
"name": "Department Environmental Quality",
"appropriation14": 9057973,
"appropriation13": 7557973,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 9728096,
"appropriation12": 7557973
},
{
"name": "Water Resources Board",
"appropriation14": 6999671,
"appropriation13": 6999671,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 4601524,
"appropriation12": 5499671
}
]
},
{
"name": "Agriculture",
"appropriation14": 36371931,
"appropriation13": 37671931,
"appropriation12": 35171931,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 44833147,
"annotation": "Agricultre spending accounts for 0.54% of overall appropriations, divided between the Department of Agriculture and the Conservation Commission.",
"children": [
{
"name": "Department Agriculture",
"appropriation14": 25910247,
"appropriation13": 27610247,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 34540185,
"appropriation12": 25610247
},
{
"name": "Conservation Commission",
"appropriation14": 10461684,
"appropriation13": 10061684,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 10292962,
"appropriation12": 9561684
}
]
},
{
"name": "Commerce",
"appropriation14": 83040200,
"appropriation13": 80040200,
"appropriation12": 79310200,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 94868925,
"annotation": "Commerce and Tourism spending accounts for 1.15% of overall appropriations, divided among the Department of Commerce, REAP, the Historical Society, Tourism and Recreation, the Department of Labor and numerous commissions.",
"children": [
{
"name": "Department Commerce",
"appropriation14": 32573212,
"appropriation13": 29573212,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 30934772,
"appropriation12": 29073212
},
{
"name": "REAP",
"appropriation14": 11532469,
"appropriation13": 11532469,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 15500000,
"appropriation12": 11532469,
"annotation": "REAP is Real Economic Action Plan."
},
{
"name": "Historical Society",
"appropriation14": 12502546,
"appropriation13": 12502546,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 14967451,
"appropriation12": 12502546
},
{
"name": "Tourism and Recreation",
"appropriation14": 21803003,
"appropriation13": 21803003,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 28041991,
"appropriation12": 21803003
},
{
"name": "Misc. Commerce",
"annotation": "'NaN' means there is no total because the grouping is miscellaneous. This group includes the Will Rogers Commission, J.M. Davis Commission, the Department of Labor, and the Oklahoma Scenic River Commission.",
"children": [
{
"name": "Will Rogers Commission",
"appropriation14": 740486,
"appropriation13": 740486,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 933702,
"appropriation12": 740486
},
{
"name": "J.M. Davis Commission",
"appropriation14": 306009,
"appropriation13": 306009,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 385403,
"appropriation12": 306009
},
{
"name": "Department Labor",
"appropriation14": 3311160,
"appropriation13": 3311160,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 3760284,
"appropriation12": 3081160
},
{
"name": "Oklahoma Scenic Rivers Commission",
"appropriation14": 271315,
"appropriation13": 271315,
"appropriation11": 6948363588,
"appropriation10": 6433088405,
"appropriation09": 345322,
"appropriation12": 271315
}
]
}
]
}
]
}
]
}
<!DOCTYPE html>
<head>
<title> Oklahoma State Budget 2013 </title>
<style>
html {
font-family: Georgia, "Times New Roman", Times, serif;
}
path {
stroke: #fff;
/*stroke-width: 1.5;
*/
cursor: pointer;
}
text {
font: 11px sans-serif;
cursor: pointer;
}
h1 {
text-align: center;
margin: .5em 0;
}
#annotation {
border: 3px solid rgb(53, 135, 212);
margin-top: 0px;
padding-top: 0px;
border-radius: 4px;
position: absolute;
min-height: 4.8em;
width: 280px;
top: 50px;
left: 10px;
background-color: rgb(53, 135, 212);
color: white;
}
#col2 {
border: 3px solid rgb(53, 135, 212);
margin-top: 0px;
padding-top: 0px;
border-radius: 4px;
position: absolute;
min-height: 4.8em;
width: 280px;
top: 50px;
left: 600px;
color: white;
background-color: rgb(53, 135, 212);
}
p {
-webkit-margin-after: 0em;
-webkit-margin-before: 0em;
margin-bottom: 0em;
margin-top: 0em;
}
#current {
font-weight: bold;
}
#left {
position: absolute;
top: 30px;
left: 120px;
}
#right {
position: absolute;
top: 30px;
left: 660px;
}
</style>
</head>
<div id="col2">
<p>
This text will disappear and show the name, appropriation and percent change when you hover over an arc.
</p>
</div>
<div id="annotation">
<p>
This text will disappear when you hover over the education arc. I'm going to make the entire box disappear until you click on the related arc.
</p>
</div>
<div id="left">
<b>Notes</b>
</div>
<div id="right">
<b>Amounts and change</b>
</div>
<form>
<label>
<input type="radio" name="mode" value="hide" checked>
Hide labels</label>
<label>
<input type="radio" name="mode" value="show">
Show Labels</label>
</form>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
var
width = 900,
height = 900,
radius = 50 * Math.max(width, height) / 100,
x = d3.scale.linear().range([0, 2 * Math.PI]),
y = d3.scale.pow().exponent(1.3).domain([0, 1]).range([0, radius]),
padding = 5,
duration = 1500;
var color = d3.scale.category20();
//var color = d3.scale.linear().domain([-100, 126]).range(["#EFEDF5", "#756BB1"]);
//var color = d3.scale.threshold().domain([-100, 0, 126]).range(["red", "white", "blue"]);
//var color = d3.scale.log().domain([0, 900000000]).range(["red", "green"]);
var div = d3.select("#vis");
//format currency
var format = d3.format(",f");
var format1 = d3.format("%");
var content = d3.select("#col2");
var content1 = d3.select("#annotation");
div.select("img").remove();
var svg = d3.select("body")
.append("svg")
.attr("width", width + padding * 2)
.attr("height", height + padding * 2)
.append("g")
.attr("transform", "translate(" + [radius + padding, radius + padding] + ")");
//div.append("p")
// .attr("id", "intro")
//.text("Click to zoom!");
var partition = d3.layout.partition()
.value(function(d)
{
return d.appropriation14;
});
var arc = d3.svg.arc()
.startAngle(function(d)
{
return Math.max(0, Math.min(2 * Math.PI, x(d.x)));
})
.endAngle(function(d)
{
return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));
})
.innerRadius(function(d)
{
return Math.max(0, y(d.y));
})
.outerRadius(function(d)
{
return Math.max(0, y(d.y + d.dy));
});
// d3.json("budget.json", function(json) {
// var nodes = partition.nodes({children: json});
d3.json("budget.json", function(error, root) {
// var path = vis.selectAll("path").data(nodes);
// path.enter().append("path")
var path = svg.selectAll("path")
.data(partition.nodes(root))
.enter()
.append("path")
.attr("id", function(d, i)
{
return "path-" + i;
})
.attr("d", arc)
.attr("fill-rule", "evenodd")
.style("fill", function(d)
{
return color((d.parent ? d : d.children).depth);
})
.on("click", click)
.on("mouseover", mouseover)
.on("mouseout", mouseout);
//add text
var text = svg.selectAll("text")
.data(partition.nodes(root));
var textEnter = text
.enter()
.append("text")
//starting opacity
//hides all those but the inner ring
.style("fill-opacity", function(d)
{
//if the depth is 1, innermost, then it's seen
if (d.depth === 1)
{
return 1;
}
//else the depth is not one, then it's hidden
else
{
return 0;
}
})
//color fill
//#000000 is black
.style("fill", "#000000")
.attr("text-anchor", function(d)
{
return x(d.x + d.dx / 2) > Math.PI ? "end" : "start";
})
.attr("dy", ".2em")
//checks for multiline names
.attr("transform", function(d)
{
var multiline = (d.name || "")
.split(" ")
.length > 1.5, angle = x(d.x + d.dx / 2) * 180 / Math.PI - 90, rotate = angle + ( multiline ? -.5 : 0);
return "rotate(" + rotate + ")translate(" + (y(d.y) + padding) + ")rotate(" + (angle > 90 ? -180 : 0) + ")";
})
.on("click", click)
//added mouseover and mouseout for the text as well.
.on("mouseover", mouseover)
.on("mouseout", mouseout);
//1st row of text
textEnter
.append("tspan")
.attr("x", 0)
.text(function(d)
{
return d.depth ? d.name.split(" ")[0] : "";
});
//2nd row of text
textEnter
.append("tspan")
.attr("x", 0)
.attr("dy", ".9em")
.text(function(d)
{
return d.depth ? d.name.split(" ")[1] || "" : "";
});
//3rd row
textEnter
.append("tspan")
.attr("x", 0)
.attr("dy", ".9em")
.text(function(d)
{
return d.depth ? d.name.split(" ")[2] || "" : "";
});
//fourth row (if necessary)
textEnter
.append("tspan")
.attr("x", 0)
.attr("dy", ".9em")
.text(function(d)
{
return d.depth ? d.name.split(" ")[3] || "" : "";
});
//click function
function click(d)
{
path
.transition()
//duration is predefined above at 1500 (1.75 seconds)
.duration(duration)
.attrTween("d", arcTween(d));
// Somewhat of a hack as it relies on arcTween updating the scales.
text
.style("visibility", function(e)
{
return isParentOf(d, e) ? null : d3.select(this).style("visibility");
})
.transition()
.duration(duration)
.attrTween("text-anchor", function(d)
{
return function()
{
return x(d.x + d.dx / 2) > Math.PI ? "end" : "start";
};
})
.attrTween("transform", function(d)
{
var multiline = (d.name || "")
.split(" ")
.length > 1.5;
return function()
{
var angle = x(d.x + d.dx / 2) * 180 / Math.PI - 90, rotate = angle + ( multiline ? -.5 : 0);
return "rotate(" + rotate + ")translate(" + (y(d.y) + padding) + ")rotate(" + (angle > 90 ? -180 : 0) + ")";
};
})
//.style("fill-opacity", function(e)
//{
// return isParentOf(d, e) ? 1 : 0;
//})
//.style("fill-opacity", function(d)
//{
//if the depth is 1, innermost, then it's seen
// if (d.depth === 1)
// {
// return 1;
// }
//else if (d.depth == 2 && d.children)
//{
// return 1;
//}
//else the depth is not one, then it's hidden
// else
// {
// return 0;
// }
//})
.each("end", function(e)
{
d3.select(this)
.style("visibility", isParentOf(d, e) ? null : "hidden");
});
}
//mouseover function which will send the values to the legend
function mouseover(d)
{
content.append("p")
.attr("id", "current")
.text(d.name)// + " - 2013 appropriations: " + d.appropriation13 + " - Which was a " + d.percentChange13 + "% change of the previous year.")
content.append("p")
//.attr("id", "name")
.text("2014 appropriation: $" + format(d.appropriation14))
content.append("p")
.text("Percent change from 2013: " + format1((d.appropriation14 - d.appropriation13)/d.appropriation13))
content.append("p")
.text("Percent change from 2009: " + format1((d.appropriation14 - d.appropriation09)/d.appropriation09))
content1.append("p")
.attr("id", "annotate")
.text(d.annotation)
if (d.annotation2 != null)
{
content1.append("br")
content1.append("p")
.text(d.annotation2);
}
}
//mouseout function which removes the values and replaces them with a blank space
function mouseout(d)
{
content.html(' ');
content1.html(' ');
}
});
d3.selectAll("input").on("change", function change()
{
var value = this.value === "show" ? 1 : 0;
d3.selectAll("text")
.style("fill-opacity", function(d)
{
if (value === 1)
{
return 1;
}
else
{
//if the depth is 1, innermost, then it's seen
if (d.depth === 1)
{
return 1;
}
//else the depth is not one, then it's hidden
else
{
return 0;
}
}
});
});
function isParentOf(p, c)
{
if (p === c)
return true;
if (p.children)
{
return p.children.some(function(d)
{
return isParentOf(d, c);
});
}
return false;
}
//to determine the innermost ring
//function isInnermost(d)
//{
//if (d.children)
//{
//return true;
//}
//else
//{
//return false;
//}
//}
// function colour(d) {
// if (d.children) {
// // There is a maximum of two children!
// var colours = d.children.map(colour),
// a = d3.hsl(colours[0]),
// b = d3.hsl(colours[1]);
// // L*a*b* might be better here...
// return d3.hsl((a.h + b.h) / 2, a.s * 1.2, a.l / 1.2);
// }
// return d.colour || "#fff";
// }
// Interpolate the scales!
function arcTween(d)
{
var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]), yd = d3.interpolate(y.domain(), [d.y, 1]), yr = d3.interpolate(y.range(), [d.y ? 20 : 0, radius]);
return function(d, i)
{
return i ? function(t)
{
return arc(d);
} : function(t)
{
x.domain(xd(t));
y.domain(yd(t)).range(yr(t));
return arc(d);
};
};
}
function maxY(d)
{
return d.children ? Math.max.apply(Math, d.children.map(maxY)) : d.y + d.dy;
}
// http://www.w3.org/WAI/ER/WD-AERT/#color-contrast
function brightness(rgb)
{
return rgb.r * .299 + rgb.g * .587 + rgb.b * .114;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment