Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrkalinin authored Feb 7, 2017
2 parents a362081 + f9a3996 commit e33e2e9
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 54 deletions.
8 changes: 7 additions & 1 deletion CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ First line of the git message has to be in the following format: `<type>(<scope>
* `<scope>` is a specific module within SOCRAT you're contributing to, i.e. `Core` or `Charts` or `PowerCalc`
* `<subject>` is a description of the change starting with a verb in imperative form, present tense, not capitalized, without period in the end; when commiting unfinished work (e.g. with known bugs), prepend `<subject>` with `WIP`.

Additional details can be added on a second line of the message.
Additional details can be added on a second line of the message.

## SOCR Datasets for testing

**Iris** - famous dataset in machine learning [1]. To be able to use it locally for testing, download [CSV file](https://drive.google.com/file/d/0BzJubeARG-hsdTdRTC03RFdhRTg/view?usp=sharing) and place it under ``_build/datasets/iris.csv``

[1] Lichman, M. (2013). [UCI Machine Learning Repository](http://archive.ics.uci.edu/ml). Irvine, CA: University of California, School of Information and Computer Science.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

A scalable and highly flexible HTML5/JS platform to build and run in-browser applications for interactive data analysis and visualization.

* Web site: http://socr.umich.edu
* Issue-tracking and project management: https://socredu.atlassian.net/browse/SOCRFW
* [Web site](http://socr.umich.edu)
* [Issue-tracking and project management](https://github.com/SOCR/SOCRAT-issues)
* [Contribution guidelines](https://github.com/SOCR/SOCRAT/blob/master/CONTRIBUTE.md)
* **Note: project is under active development, unit tests currently are not passing, bugs are possible**

[![Build Status](https://travis-ci.org/SOCR/SOCRAT.svg?branch=master)](https://travis-ci.org/SOCR/SOCRAT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ module.exports = class GetDataMainCtrl extends BaseCtrl
data = @dataAdaptor.toDataFrame dataResults
@passReceivedData data
else
console.log 'rejected:' + msg
console.log 'GETDATA: request failed'

getJsonByUrl: (type) ->
@d3.json @jsonUrl,
Expand Down
105 changes: 86 additions & 19 deletions app/scripts/analysis/charts/ChartsPieChart.service.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = class ChartsPieChart extends BaseService
return obj

drawPie: (data,width,height,_graph, pie) -> # "pie" is a boolean
radius = Math.min(width, height) / 2 - 15
radius = Math.min(width, height) / 2
outerRadius = radius
arc = d3.svg.arc()
.outerRadius(outerRadius)
Expand All @@ -55,38 +55,105 @@ module.exports = class ChartsPieChart extends BaseService
.sort(null)

formatted_data = @makePieData data

sum = @valueSum
clickOn = (false for [0..formatted_data.length-1])

# PIE ARCS / SLICES

arcs = _graph.selectAll(".arc")
.data(pie(formatted_data))
.enter()
.append('g')
.attr("class", "arc")

paths = arcs.append('path')
.attr('d', arc)
.attr('fill', (d) -> color(d.data.value))
.on('mouseover', handleMouseOver)
.on('mouseout', handleMouseOut)
.on('click', handleClick)

# Create Event Handlers for mouse
handleMouseOver = (d, i) ->
if clickOn[i] is false
# Use d3 to select element
d3.select(this)
.attr("stroke","white")
.transition()
.attr("d", arcOver)
.attr("stroke-width",3)

# bold the label
d3.select(this.parentNode)
.select('text')
.attr('font-weight', 'bold')

handleMouseOut= (d, i) ->
if clickOn[i] is false
d3.select(this)
.transition()
.attr('d', arc)
.attr("stroke", "none")

# unbold the label
d3.select(this.parentNode)
.select('text')
.attr('font-weight', 'normal')


handleClick= (d,i) ->
if clickOn[i] is true
clickOn[i] = false
d3.select(this)
.transition()
.attr('d', arc)
.attr("stroke", 'none')

# unbold the label
d3.select(this.parentNode)
.select('text')
.attr('font-weight', 'normal')

else
clickOn[i] = true
d3.select(this)
.attr('stroke', 'white')
.transition()
.attr('d', arcOver)
.attr('stroke', 3)


arcs.append('path')
.attr('d', arc)
.attr('fill', (d) -> color(d.data.value))
.on('mouseenter', (d) ->
d3.select(this).attr("stroke","white") .transition().attr("d", arcOver).attr("stroke-width",3)
).on('mouseleave', (d) ->
d3.select(this).transition().attr('d', arc).attr("stroke", "none")
)

# TEXT LABELS
.on('mouseover', handleMouseOver)
.on('mouseout', handleMouseOut)
.on('click', handleClick)


# Specify where to put text label
arcs.append('text')
.attr('transform', (d) ->
c = arc.centroid(d)
x = c[0]
y = c[1]
h = Math.sqrt(x*x + y*y)
desiredLabelRad = 220
'translate('+ (x/h * desiredLabelRad) + ',' + (y/h * desiredLabelRad) + ')')
.attr('text-anchor', 'middle')
.text (d) => d.data.key + ': ' + parseFloat(100 * d.data.value / @valueSum).toFixed(2) + '%'
.style('font-size', '16px')
.attr('class', 'text')
.attr('transform', (d) ->
c = arc.centroid(d)
x = c[0]
y = c[1]
h = Math.sqrt(x*x + y*y)
desiredLabelRad = 220
'translate(' + (x/h * desiredLabelRad) + ',' + (y/h * desiredLabelRad) + ')'
).transition()
.text (d) =>
d.data.key + ' (' + parseFloat(100 * d.data.value / sum).toFixed(1) + '%)'
.style('font-size', '16px')












62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,48 @@
"url": "https://github.com/SOCR/SOCRAT.git"
},
"dependencies": {
"angular": "^1.5.0",
"angular-animate": "^1.5.0",
"angular": "~1.5.0",
"angular-animate": "~1.5.0",
"angular-bootstrap-switch": "^0.5.1",
"angular-cookies": "^1.5.0",
"angular-messages": "^1.5.0",
"angular-resource": "^1.5.0",
"angular-route": "^1.5.0",
"angular-sanitize": "^1.5.0",
"angular-touch": "^1.5.0",
"angular-ui-bootstrap": "^1.3.0",
"angular-cookies": "~1.5.0",
"angular-messages": "~1.5.0",
"angular-resource": "~1.5.0",
"angular-route": "~1.5.0",
"angular-sanitize": "~1.5.0",
"angular-touch": "~1.5.0",
"angular-ui-bootstrap": "~1.3.0",
"angular-ui-router": "~0.2.18",
"bootstrap": "^3.3.6",
"bootstrap": "~3.3.6",
"bootstrap-switch": "~3.0.2",
"bootstrap-tagsinput": "^0.7.1",
"browserify-versionify": "^1.0.6",
"compassql": "^0.6.7",
"connect": "^3.5.0",
"bootstrap-tagsinput": "~0.7.1",
"browserify-versionify": "~1.0.6",
"compassql": "~0.6.7",
"connect": "~3.5.0",
"d3": "~3.5.15",
"data-wrangler": "^1.0.5",
"data-wrangler": "~1.0.5",
"datalib": "1.7.2",
"datatables.net": "^1.10.12",
"datatables.net-dt": "^1.10.12",
"designmodo-flat-ui": "^2.3.0",
"flatui-radiocheck": "^0.1.2",
"handsontable": "^0.26.0",
"holderjs": "^2.9.3",
"jquery": "^2.1.0",
"datatables.net": "~1.10.12",
"datatables.net-dt": "~1.10.12",
"designmodo-flat-ui": "~2.3.0",
"flatui-radiocheck": "~0.1.2",
"handsontable": "~0.26.0",
"holderjs": "~2.9.3",
"jquery": "~2.1.0",
"jquery-highlight": "~3.3.0",
"jquery-ui": "^1.12.0",
"jquery-ui": "~1.12.0",
"jquery-ui-layout": "git+https://github.com/benosman/layout.git",
"jsfeat": "~0.0.8",
"jstat": "~1.5.2",
"jstransform": "^11.0.2",
"jstransform": "~11.0.2",
"ng-handsontable": "git+https://github.com/handsontable/ngHandsontable.git",
"select2": "^4.0.3",
"serve-static": "^1.11.1",
"through": "^2.3.8",
"transform-loader": "^0.2.3",
"select2": "~4.0.3",
"serve-static": "~1.11.1",
"through": "~2.3.8",
"transform-loader": "~0.2.3",
"typeahead.js": "git+https://github.com/twitter/typeahead.js.git",
"vega": "^2.6.3",
"vega-embed": "^2.2.0",
"vega-lite": "^1.3.1"
"vega": "~2.6.3",
"vega-embed": "~2.2.0",
"vega-lite": "~1.3.0"
},
"devDependencies": {
"angular-mocks": "^1.5.0",
Expand Down

0 comments on commit e33e2e9

Please sign in to comment.