Skip to content

Instantly share code, notes, and snippets.

@AlexDaGr8
Last active December 14, 2018 16:50
Show Gist options
  • Save AlexDaGr8/1ecdada7c972b59a398d9e4ae3037f9f to your computer and use it in GitHub Desktop.
Save AlexDaGr8/1ecdada7c972b59a398d9e4ae3037f9f to your computer and use it in GitHub Desktop.
Linking scatter plots and bar charts
license: mit
gender ethnicity parentEducation lunch testPrepCourse math reading writing
female group D some high school standard none 63 70 73
female group B some high school free/reduced none 54 56 62
female group E some college free/reduced none 73 82 78
male group D bachelor's degree standard none 53 49 44
female group E some college standard none 67 79 74
female group B high school standard completed 70 76 71
male group B some high school standard completed 62 70 66
female group C bachelor's degree standard none 48 65 60
female group C bachelor's degree free/reduced none 65 79 73
female group E master's degree standard completed 60 63 68
female group D associate's degree standard none 60 71 69
female group D some college standard completed 64 65 72
male group B bachelor's degree standard none 87 83 81
male group C some high school standard none 72 56 56
male group A some high school free/reduced completed 61 56 61
female group C some high school free/reduced none 51 59 57
male group E some college free/reduced none 48 52 38
male group B some college free/reduced none 37 40 37
female group D some college standard completed 73 88 92
female group C high school standard completed 65 77 82
male group C some high school standard none 51 42 35
female group A some high school standard none 65 80 73
female group D some high school standard completed 79 90 88
male group E master's degree standard none 69 62 57
female group B some college standard completed 77 76 85
male group D high school standard completed 73 80 81
male group D associate's degree standard none 92 94 86
female group D high school standard none 74 80 81
female group B high school free/reduced none 35 53 45
male group B high school standard none 51 47 44
female group D some high school standard completed 75 90 94
male group E associate's degree standard none 81 64 58
male group B high school standard none 89 82 73
female group D associate's degree free/reduced completed 93 95 100
female group C bachelor's degree standard none 59 68 61
male group E bachelor's degree free/reduced completed 99 99 96
male group C high school free/reduced none 77 78 74
female group D high school standard none 71 80 77
male group D some high school standard none 58 53 50
male group E high school standard completed 82 77 76
female group D some high school standard completed 90 87 94
male group E associate's degree free/reduced none 78 75 69
male group A high school free/reduced completed 64 65 65
female group E some college standard none 98 96 95
female group A some high school free/reduced none 44 58 52
male group C some high school standard completed 86 92 93
male group A associate's degree standard completed 63 67 63
male group C associate's degree standard none 85 85 80
male group D some college standard completed 53 55 62
female group C bachelor's degree free/reduced none 50 61 60
female group E some college standard none 75 76 72
female group B some college free/reduced none 55 75 69
male group E associate's degree free/reduced none 70 60 48
female group E high school free/reduced none 68 79 73
male group B high school standard none 77 75 71
female group E associate's degree standard completed 84 90 91
female group B some college standard none 61 62 64
female group C associate's degree standard none 49 60 62
male group C some high school standard none 49 43 36
female group C some high school standard none 55 63 69
female group D some high school free/reduced completed 78 90 94
female group D associate's degree standard none 81 87 91
male group C some high school free/reduced none 54 41 35
female group B some college standard none 71 79 74
male group E high school standard none 70 61 55
male group A bachelor's degree standard none 87 70 69
male group B some high school free/reduced completed 40 41 40
female group A some college standard completed 72 80 86
male group C some college standard none 72 65 54
male group D some high school standard none 64 72 64
female group C high school standard completed 77 92 91
female group B bachelor's degree free/reduced none 64 72 74
male group C associate's degree standard completed 76 73 70
male group C master's degree standard none 91 83 86
female group C high school free/reduced completed 56 73 72
female group B some college free/reduced none 40 41 49
male group D some high school standard completed 78 67 72
male group C some high school standard completed 76 82 75
male group E high school standard completed 75 83 79
male group D bachelor's degree standard none 88 68 76
male group B high school standard none 75 73 69
male group E bachelor's degree free/reduced none 69 74 63
female group D master's degree standard none 61 64 75
female group D some high school standard completed 73 81 83
female group B some college standard none 88 93 96
male group C associate's degree standard none 57 47 42
female group C associate's degree free/reduced none 59 74 72
male group C some college standard none 86 84 83
female group C master's degree standard none 64 69 61
male group E high school standard none 83 69 64
female group B high school free/reduced completed 62 69 75
male group C high school free/reduced none 58 57 55
female group E high school standard completed 83 91 91
female group D some college standard none 50 59 58
female group B associate's degree standard none 89 90 93
female group D some high school free/reduced none 78 85 85
female group A some college free/reduced none 42 51 51
male group A some high school free/reduced none 69 57 58
female group D some college free/reduced completed 55 71 76
male group C high school free/reduced none 71 58 55
female group C high school free/reduced completed 78 80 82
male group A some college free/reduced completed 67 68 67
male group C associate's degree standard completed 93 97 99
male group C high school standard none 86 88 83
male group D associate's degree free/reduced completed 63 70 73
female group B associate's degree standard none 66 85 79
male group B some high school standard completed 80 76 74
male group D master's degree standard completed 76 81 83
female group C associate's degree free/reduced none 54 69 66
male group E some high school standard none 77 58 55
male group B bachelor's degree free/reduced none 52 55 47
male group D associate's degree free/reduced none 72 69 65
male group B high school standard none 60 58 51
female group B some college standard none 66 65 62
male group A some college standard none 85 89 86
male group C bachelor's degree standard none 82 76 75
male group B some college standard none 61 53 52
female group D high school standard completed 58 73 76
male group D some college standard none 59 49 51
female group B bachelor's degree standard none 85 95 93
female group C some high school standard none 71 87 73
male group B some college standard completed 84 89 89
female group D associate's degree free/reduced none 55 51 55
male group D some high school standard completed 85 78 78
male group A some college standard none 79 74 71
female group B some high school standard completed 55 66 67
male group D some college standard completed 86 82 82
male group C master's degree standard none 96 82 79
male group C associate's degree standard none 73 74 71
female group E associate's degree free/reduced completed 54 63 59
male group A some college standard none 72 57 57
female group B high school standard none 55 57 60
female group C some college standard none 62 71 69
male group C associate's degree free/reduced none 48 44 38
female group E some college standard none 89 87 81
female group A associate's degree free/reduced none 48 62 58
male group E some high school free/reduced none 64 59 53
female group D some high school standard none 71 80 74
male group E some high school free/reduced none 55 56 47
male group C associate's degree free/reduced none 68 66 60
female group D associate's degree standard completed 67 77 81
male group D bachelor's degree standard none 88 85 87
female group B bachelor's degree free/reduced none 55 64 57
male group D high school free/reduced none 61 60 55
female group C associate's degree standard none 70 72 79
male group E some high school free/reduced none 83 76 79
female group B master's degree free/reduced none 65 75 75
female group B high school free/reduced none 62 74 76
male group E master's degree standard none 85 81 75
male group C high school standard none 78 78 65
female group C high school standard completed 85 87 92
male group D high school standard none 67 70 69
male group C some high school free/reduced none 63 59 54
male group E high school free/reduced completed 81 67 68
male group D associate's degree free/reduced none 81 78 76
male group B high school standard completed 80 70 72
female group C some high school free/reduced completed 66 81 79
female group C master's degree standard none 79 90 94
female group C some high school standard none 34 50 46
male group D bachelor's degree standard none 88 85 87
female group C master's degree standard none 66 72 70
male group B master's degree standard completed 83 81 82
female group B high school standard none 69 76 70
male group D associate's degree standard none 67 49 56
female group E some high school standard completed 60 73 73
female group C associate's degree standard none 50 53 55
female group D associate's degree standard none 73 69 73
male group C high school standard none 68 71 67
male group E associate's degree standard none 98 91 88
male group B master's degree standard none 82 76 71
female group C master's degree standard completed 73 94 100
male group A high school standard none 66 57 51
male group D associate's degree standard none 83 85 80
male group C some high school standard completed 69 79 79
female group C some high school standard completed 71 68 75
female group D some college standard completed 73 82 85
female group B some college standard none 54 59 57
female group C associate's degree standard completed 72 85 84
female group B high school free/reduced completed 39 53 54
female group D some college standard none 73 85 88
female group A high school free/reduced completed 47 47 51
female group B some college free/reduced none 45 52 53
female group D associate's degree standard completed 67 70 80
female group E associate's degree standard none 79 82 77
female group D some high school standard completed 66 73 84
male group C high school standard completed 73 72 62
female group C bachelor's degree standard none 87 99 99
male group C some college free/reduced none 57 64 58
female group D high school standard none 76 93 90
male group A some high school standard none 59 44 40
male group E some college standard completed 100 93 95
male group C associate's degree free/reduced none 65 65 65
male group E high school standard none 65 46 49
female group D some high school free/reduced none 61 77 72
male group D bachelor's degree standard none 72 66 70
female group D some college standard none 78 94 95
male group A associate's degree standard none 59 54 50
female group D associate's degree standard completed 76 96 94
female group C some high school free/reduced completed 17 18 24
male group C some college standard none 72 72 63
male group C some high school standard none 71 73 67
female group A associate's degree standard none 51 60 59
male group D some college standard none 67 60 56
female group B master's degree free/reduced completed 40 64 60
female group B associate's degree free/reduced none 58 63 61
male group C associate's degree standard completed 80 79 79
female group B high school standard completed 60 74 76
female group D some college standard none 71 83 89
female group B master's degree standard completed 56 54 62
male group E bachelor's degree standard none 100 82 84
male group E bachelor's degree free/reduced completed 45 41 39
female group D some college free/reduced none 48 55 53
male group D high school standard none 40 48 43
female group D associate's degree standard none 82 86 87
male group E associate's degree standard none 94 87 77
female group C associate's degree standard none 82 93 87
male group E high school free/reduced none 83 71 70
male group D some college standard completed 73 51 57
male group B associate's degree standard completed 92 85 89
male group C bachelor's degree standard completed 69 61 65
male group D high school free/reduced none 62 46 50
female group E some high school free/reduced completed 52 58 62
male group A some college standard none 72 74 68
male group C high school standard completed 71 69 72
male group C bachelor's degree standard none 72 73 69
male group D associate's degree standard none 73 66 70
male group C high school standard completed 60 56 52
female group B master's degree free/reduced none 65 77 71
female group B high school free/reduced completed 29 45 47
male group C high school free/reduced none 55 58 45
female group D some high school standard none 63 72 76
female group B high school standard none 65 80 73
female group C some high school standard none 38 46 44
female group C some college standard none 66 64 66
female group B high school free/reduced completed 35 53 47
female group B associate's degree standard none 63 74 73
female group D bachelor's degree standard completed 96 97 100
male group C high school free/reduced none 35 36 28
male group C high school standard none 86 79 80
male group B some high school standard completed 75 65 68
male group B bachelor's degree standard completed 79 84 83
female group D master's degree standard none 80 86 91
female group E associate's degree standard completed 67 83 82
female group D bachelor's degree free/reduced completed 71 87 86
female group C associate's degree standard completed 89 87 86
male group D some college free/reduced none 62 54 51
female group E some high school standard completed 74 80 82
female group C some college standard none 76 84 77
female group C some college standard none 71 76 73
female group C bachelor's degree standard none 58 65 64
male group B master's degree standard none 87 74 74
male group C master's degree standard completed 81 79 75
female group B some college standard none 71 75 72
male group C high school standard none 35 31 30
female group C bachelor's degree standard none 65 72 73
male group E some high school standard none 95 97 93
male group D bachelor's degree free/reduced none 92 84 87
male group B high school free/reduced completed 72 63 67
female group C some college free/reduced completed 58 67 69
male group D associate's degree standard completed 84 68 75
female group B associate's degree free/reduced completed 57 71 72
female group C some college standard completed 81 94 92
female group B some college free/reduced none 67 82 76
female group B bachelor's degree standard none 70 81 82
female group B some college standard none 40 53 47
male group D some college standard none 63 55 57
male group E some high school standard none 69 64 55
female group B high school standard none 50 66 63
male group B bachelor's degree free/reduced completed 79 84 80
female group C some college standard completed 87 97 100
male group C some college standard none 47 39 41
male group E some high school free/reduced completed 61 57 58
female group D associate's degree free/reduced completed 80 93 100
male group D some college free/reduced none 49 48 45
male group C high school standard completed 87 83 79
female group C some high school standard completed 64 62 69
female group B some college standard none 57 73 71
female group D bachelor's degree standard none 82 90 88
male group D bachelor's degree free/reduced none 80 75 74
male group A some college standard none 62 59 49
female group E associate's degree standard none 100 96 95
female group D some college free/reduced completed 68 87 88
male group A some college standard none 75 72 66
female group B high school standard completed 82 85 94
male group C bachelor's degree free/reduced none 42 51 40
male group D high school free/reduced completed 75 73 78
female group E some high school standard completed 60 48 57
female group D bachelor's degree standard none 89 100 100
male group D some college free/reduced none 66 62 62
female group E high school standard none 79 87 85
female group C associate's degree free/reduced completed 58 63 72
male group D some college standard completed 74 59 69
male group C some college free/reduced none 83 83 76
male group B associate's degree standard none 65 69 58
male group D associate's degree standard none 69 63 64
female group B associate's degree standard none 63 66 65
female group B master's degree standard completed 89 91 94
female group C associate's degree standard none 76 73 76
male group B some high school standard none 85 86 82
female group C bachelor's degree standard none 69 75 79
male group B some college standard none 66 69 63
female group E high school standard none 77 90 84
male group C high school free/reduced none 63 58 62
female group E bachelor's degree free/reduced none 73 81 75
female group C bachelor's degree free/reduced none 73 97 94
male group E high school standard none 70 58 53
male group E some college free/reduced completed 85 74 78
female group D some high school free/reduced none 56 72 71
male group D some high school standard none 66 63 62
male group D associate's degree standard none 46 34 27
female group D some college standard none 63 78 75
female group E associate's degree standard none 67 75 65
male group D master's degree standard none 83 74 73
male group C some college standard none 88 74 78
female group B bachelor's degree standard completed 70 84 92
female group D high school standard none 84 87 87
female group C bachelor's degree standard none 80 92 90
female group C master's degree free/reduced none 68 75 76
female group B associate's degree free/reduced none 49 57 63
male group A associate's degree standard none 68 59 58
female group B associate's degree standard completed 70 72 81
female group E master's degree standard none 76 80 82
female group B bachelor's degree free/reduced none 51 61 55
male group C some high school standard completed 92 94 88
male group A high school standard completed 61 65 58
female group E some college standard none 80 84 82
female group D some college standard none 64 60 68
male group C some high school free/reduced completed 72 78 72
female group D high school free/reduced none 68 66 69
female group C bachelor's degree standard completed 80 92 90
male group C associate's degree standard none 59 62 55
male group D some high school standard none 54 48 49
male group B associate's degree standard none 77 77 74
female group E some college standard none 51 53 55
male group B bachelor's degree standard completed 78 81 73
female group C some high school standard completed 59 77 74
female group C associate's degree standard none 60 64 66
male group C associate's degree free/reduced completed 57 60 62
female group C high school standard completed 69 82 85
female group B high school standard completed 74 90 85
female group E high school free/reduced none 39 43 36
female group B high school standard none 69 68 73
male group A bachelor's degree standard completed 88 78 80
female group E associate's degree standard none 64 66 62
male group D some college free/reduced completed 51 50 53
female group E some high school standard none 56 63 60
male group D bachelor's degree free/reduced none 55 60 58
female group C associate's degree standard completed 86 100 98
male group D master's degree free/reduced none 78 75 75
male group B some college standard none 70 69 67
female group D high school standard none 69 71 71
male group C high school standard completed 75 83 80
male group B high school free/reduced none 48 48 45
female group D associate's degree standard none 59 64 60
female group B some high school standard none 68 67 63
male group C bachelor's degree standard none 64 55 58
female group E associate's degree standard none 64 68 74
female group B some high school standard none 73 81 77
male group C high school free/reduced none 67 74 56
female group B bachelor's degree standard none 83 87 82
female group D some college standard none 93 93 100
male group C some high school free/reduced completed 53 51 52
male group D some high school standard none 59 60 59
male group B bachelor's degree standard none 79 74 71
male group B high school standard completed 66 69 67
female group C some high school standard none 54 55 64
male group B bachelor's degree standard completed 71 74 70
female group B some high school standard none 58 58 56
female group C high school free/reduced none 58 77 72
male group C some college standard none 54 47 47
female group D bachelor's degree standard none 77 88 82
female group C some college standard none 50 55 57
female group D some high school free/reduced none 48 58 60
male group B some college standard none 85 73 77
female group D bachelor's degree free/reduced completed 63 80 83
female group D some college standard none 81 97 100
male group C associate's degree free/reduced none 63 68 64
male group D master's degree standard none 71 68 67
female group D some high school standard none 53 50 44
female group A associate's degree free/reduced none 68 69 67
female group B some high school standard none 66 74 68
male group C master's degree free/reduced none 59 58 63
male group C some college free/reduced none 81 78 72
male group C associate's degree standard none 74 57 56
female group D master's degree standard none 53 54 61
male group C bachelor's degree standard none 86 85 80
male group E associate's degree standard completed 70 64 65
female group B associate's degree standard completed 80 100 100
male group B some high school standard none 70 71 65
male group D some college standard none 70 68 63
male group C some high school standard none 65 52 52
male group E some college standard none 100 86 87
male group D some college free/reduced none 67 72 71
female group D some college free/reduced none 50 61 56
male group A some college standard none 87 83 79
female group C some college free/reduced none 55 69 67
male group C associate's degree standard none 55 42 44
male group C high school standard none 65 48 51
female group A some college standard completed 65 71 74
female group D associate's degree free/reduced none 63 70 77
male group E associate's degree standard none 73 61 59
female group E some high school free/reduced none 67 69 70
male group C some college standard completed 56 44 53
female group D high school standard none 56 67 62
male group C associate's degree free/reduced none 79 77 77
male group D high school standard none 75 66 61
female group D some high school free/reduced none 57 69 63
male group A some high school standard completed 68 66 64
female group C some college standard none 84 96 93
female group B some high school free/reduced none 65 78 74
male group B some high school standard none 78 73 70
female group D some college standard none 41 50 55
male group B some college standard none 75 69 67
female group D bachelor's degree standard none 75 74 79
female group E associate's degree standard none 68 74 73
male group D associate's degree free/reduced none 86 81 78
male group D high school standard none 85 78 78
male group C some high school free/reduced none 35 41 30
female group E some college standard completed 58 52 63
female group C associate's degree standard none 76 90 83
male group B some high school standard none 78 72 67
female group E some college free/reduced completed 72 77 81
female group E master's degree free/reduced none 66 81 74
female group E some high school free/reduced completed 65 69 70
female group B high school standard none 66 75 70
male group A associate's degree standard completed 88 89 86
male group E bachelor's degree standard completed 90 88 87
male group C master's degree standard none 77 79 74
male group B associate's degree free/reduced none 69 77 68
female group A some high school free/reduced none 64 71 64
female group D some college free/reduced none 61 81 76
female group C high school standard none 46 63 61
female group D high school free/reduced none 29 56 45
male group A associate's degree standard none 68 66 56
female group A bachelor's degree free/reduced none 74 93 95
male group D high school free/reduced none 40 41 42
male group E some high school standard completed 79 73 74
male group B some college standard none 73 67 65
female group C associate's degree standard none 68 75 75
female group C some high school standard none 82 85 89
male group C some high school standard none 88 80 72
female group D bachelor's degree free/reduced none 54 68 65
male group D associate's degree standard none 90 83 87
male group D associate's degree standard none 54 46 43
female group D some high school free/reduced completed 47 63 68
female group C master's degree standard completed 83 97 100
male group D associate's degree standard completed 62 56 58
female group D associate's degree free/reduced none 61 62 63
female group E master's degree free/reduced completed 75 88 94
female group B master's degree standard none 65 72 74
male group B master's degree standard completed 60 65 63
female group D some high school standard completed 78 91 92
female group C high school standard completed 64 74 73
male group B some college standard completed 60 63 71
female group C some high school standard completed 84 88 89
male group B associate's degree free/reduced none 64 66 58
female group B high school free/reduced none 33 39 43
male group B associate's degree standard none 64 63 59
female group D master's degree standard none 61 73 68
female group A bachelor's degree standard none 83 100 100
female group E associate's degree standard none 50 49 51
female group D some college standard completed 91 97 100
male group E bachelor's degree standard completed 82 76 72
female group D some high school standard completed 50 59 67
male group C some college standard none 49 50 48
female group C some college standard completed 76 84 93
female group B high school standard none 58 62 64
female group B associate's degree standard completed 59 78 81
male group E high school standard none 76 59 63
female group E bachelor's degree standard none 91 89 89
female group C associate's degree free/reduced completed 66 81 84
male group A bachelor's degree standard none 83 72 68
female group C some college standard none 74 78 71
female group B some college free/reduced completed 43 64 69
male group B associate's degree standard none 59 57 53
male group D associate's degree standard completed 86 83 83
female group A some college standard completed 74 72 79
male group B some high school free/reduced none 55 50 48
female group B master's degree standard none 76 84 85
female group C high school free/reduced none 64 65 64
male group D high school standard none 84 72 74
male group C high school free/reduced none 66 61 56
female group B high school standard none 48 59 63
female group D master's degree standard none 71 76 79
female group D some college standard completed 54 68 72
male group E bachelor's degree free/reduced completed 84 78 78
male group C high school free/reduced none 70 69 67
female group D some college standard completed 73 86 96
male group B master's degree standard none 62 63 60
female group B high school free/reduced completed 60 79 77
female group E master's degree standard none 65 75 68
female group E master's degree standard none 69 75 70
female group E associate's degree free/reduced none 52 57 55
male group C some college standard none 48 59 50
female group E master's degree standard none 85 91 83
male group C some high school free/reduced none 49 44 39
male group B some high school free/reduced none 48 47 36
female group C master's degree standard none 78 82 79
male group B high school standard none 80 67 63
male group D bachelor's degree free/reduced none 55 50 49
male group D high school standard none 88 82 81
female group D some college free/reduced none 39 52 49
male group B associate's degree free/reduced completed 63 73 62
female group E some college free/reduced none 49 45 50
female group D bachelor's degree free/reduced none 85 91 85
female group B some college free/reduced none 47 49 44
female group C some high school standard none 59 67 58
male group D high school free/reduced completed 65 67 66
female group C some college standard completed 65 66 68
male group D associate's degree free/reduced completed 44 45 45
female group A some high school standard none 46 59 58
female group D associate's degree standard none 84 86 86
male group D associate's degree standard none 84 78 77
female group A high school standard completed 65 73 75
female group B some high school standard none 30 37 36
female group B master's degree standard none 67 67 66
female group B associate's degree standard none 85 97 94
female group E high school free/reduced completed 60 68 69
female group D bachelor's degree standard none 73 86 87
female group B high school free/reduced none 59 62 58
female group C some college free/reduced completed 44 48 53
male group C some college free/reduced completed 43 49 50
male group D bachelor's degree free/reduced none 48 55 55
male group B some college free/reduced none 40 35 36
male group C master's degree standard none 66 72 68
male group E high school standard completed 67 65 66
male group D associate's degree standard completed 91 76 86
female group E associate's degree standard none 78 77 82
female group E master's degree standard completed 94 93 94
male group C some high school free/reduced none 49 33 35
female group D some high school standard none 68 79 74
female group B some college standard completed 77 93 91
female group B some high school free/reduced none 27 46 36
female group B some high school free/reduced completed 22 33 40
female group C some high school standard none 79 91 91
male group B high school standard none 33 28 23
male group C some high school free/reduced none 38 48 37
male group E some high school standard none 84 67 67
female group D high school free/reduced none 47 53 54
female group E some college standard none 63 57 61
female group A some college standard none 58 70 68
male group B associate's degree standard none 61 54 46
male group E master's degree free/reduced completed 84 93 87
male group B bachelor's degree standard none 72 58 62
female group C some college free/reduced completed 55 74 70
female group C some college standard none 69 81 80
male group C some high school standard completed 76 72 67
female group B associate's degree standard none 56 62 67
male group A master's degree free/reduced none 71 76 70
male group C associate's degree standard none 90 83 77
male group D some high school standard none 61 65 63
male group C bachelor's degree standard completed 75 84 83
female group D high school free/reduced none 50 73 72
male group B some high school standard none 61 63 56
male group C some college free/reduced completed 85 84 85
male group C high school standard none 79 69 65
female group E associate's degree standard completed 76 75 76
male group A associate's degree standard completed 75 70 72
male group C bachelor's degree standard none 73 77 77
male group D some high school standard completed 76 76 75
male group D some college standard none 81 79 74
female group C some college standard none 82 90 89
male group C associate's degree standard completed 84 75 77
female group E bachelor's degree standard none 82 89 96
male group C bachelor's degree free/reduced none 72 77 73
female group D master's degree free/reduced none 35 45 46
female group C some high school free/reduced none 57 73 70
female group E some high school free/reduced none 58 68 65
male group B associate's degree free/reduced completed 54 61 59
male group D some high school standard none 52 46 48
male group D some high school free/reduced completed 62 67 70
male group C master's degree free/reduced none 62 61 51
male group D some college free/reduced none 80 82 75
male group C some college standard completed 82 74 78
female group B some high school standard completed 86 92 91
male group C some college free/reduced none 79 81 79
female group C high school standard completed 75 84 86
female group D associate's degree standard none 76 81 81
female group C associate's degree free/reduced completed 53 56 61
female group D some college free/reduced none 44 58 56
female group A some college standard completed 77 88 94
male group D some college standard none 76 69 62
female group E some high school standard completed 59 73 74
male group E master's degree free/reduced none 75 72 62
male group C some college standard completed 73 62 69
male group C some college free/reduced none 41 45 46
female group B some high school free/reduced none 42 53 50
female group D some college standard none 73 79 75
female group C master's degree standard none 80 81 83
male group B some college standard completed 86 79 77
male group A bachelor's degree standard completed 77 95 96
female group C some college free/reduced none 51 68 69
female group B some college standard none 59 61 62
female group B associate's degree standard none 80 90 94
male group C bachelor's degree standard none 98 87 86
male group D master's degree free/reduced completed 72 72 75
male group B some college standard completed 81 79 85
male group E associate's degree standard completed 100 98 98
female group D some college free/reduced none 56 69 74
female group C associate's degree standard none 72 72 73
male group E high school free/reduced none 55 52 45
male group C high school standard none 60 59 51
male group D high school standard completed 65 63 68
female group C high school free/reduced completed 57 74 63
female group D associate's degree standard completed 66 67 78
female group C associate's degree standard none 86 100 97
female group D some college standard none 63 74 75
male group C some college standard none 65 70 66
female group B some college free/reduced none 76 88 82
female group D associate's degree free/reduced none 36 38 40
male group E high school free/reduced completed 93 82 82
female group D master's degree free/reduced none 63 64 71
male group C some college standard none 62 57 53
male group D some college standard completed 97 89 90
female group C some high school standard none 54 53 57
male group C some high school standard none 83 79 74
male group A some college standard completed 54 42 47
male group E bachelor's degree standard completed 100 100 99
female group A some college free/reduced completed 54 68 70
female group D high school standard none 70 79 73
male group E some college free/reduced none 62 65 58
male group D some college standard completed 86 78 82
male group E high school standard completed 75 74 79
female group D high school standard completed 78 87 93
male group E high school standard none 94 83 80
male group B some high school standard completed 56 55 58
female group D some college standard none 51 59 58
female group B high school free/reduced none 56 79 75
female group C some high school standard none 67 80 74
male group B some high school standard none 54 50 52
female group E associate's degree free/reduced completed 72 80 72
female group E master's degree standard none 100 100 100
female group C some high school standard none 44 49 50
female group C associate's degree standard completed 46 63 63
female group C associate's degree standard completed 63 70 72
male group C some college standard completed 78 73 75
male group C associate's degree free/reduced none 70 72 69
female group B associate's degree free/reduced none 56 73 71
female group C bachelor's degree standard none 65 76 79
female group B some high school standard none 46 53 55
male group D some college standard none 74 66 64
male group D some high school standard none 55 54 47
female group C some college standard none 47 54 56
female group C some high school free/reduced completed 79 85 91
female group B some high school standard none 72 85 85
male group B bachelor's degree standard completed 80 72 72
female group D master's degree standard none 71 84 79
female group C some high school free/reduced none 61 58 53
male group D some college standard none 76 80 77
male group A some high school standard none 71 74 63
female group C some college free/reduced completed 47 57 60
female group C associate's degree free/reduced completed 51 62 61
male group C some high school standard none 60 65 57
male group C some college standard completed 91 82 83
female group B associate's degree free/reduced none 66 74 71
female group C some high school standard none 52 67 65
male group C some college standard completed 69 62 55
female group C associate's degree standard none 82 83 82
male group D some college standard none 63 58 60
female group C some college standard none 56 69 68
male group E high school standard completed 88 80 77
female group D associate's degree standard none 67 71 79
male group D high school free/reduced none 64 58 57
female group C master's degree standard none 68 72 71
male group D associate's degree standard none 81 86 81
female group D some college standard completed 76 88 96
female group D some high school standard completed 40 54 59
female group C high school free/reduced completed 57 66 62
female group C high school standard none 63 66 62
male group E associate's degree standard none 93 78 70
male group D associate's degree standard none 95 88 87
male group C master's degree free/reduced none 50 57 55
male group B associate's degree free/reduced none 51 60 57
female group D some college free/reduced none 59 62 70
female group C bachelor's degree standard none 64 71 75
male group D some college standard none 57 47 49
female group B some high school standard none 84 83 78
female group B some high school standard completed 71 80 81
female group E bachelor's degree standard none 90 86 92
male group C some high school standard none 52 44 44
female group C associate's degree standard none 55 67 61
male group E associate's degree free/reduced none 75 63 65
male group B high school free/reduced none 60 65 58
male group D high school free/reduced completed 75 74 68
female group C some high school standard none 53 63 55
male group D some high school free/reduced none 64 63 60
male group C master's degree standard none 67 67 59
female group E some college standard none 94 87 85
male group D some college standard none 63 66 61
male group D some high school standard none 76 64 71
male group B some high school free/reduced completed 75 72 67
female group E some college free/reduced none 67 65 68
male group B some college free/reduced none 58 54 51
male group C some college free/reduced completed 66 74 71
male group C associate's degree free/reduced none 36 44 36
female group B some college standard none 91 82 89
male group D some college standard none 68 66 65
male group D bachelor's degree standard completed 76 71 74
male group B associate's degree standard none 47 43 39
female group C some college standard none 51 61 61
female group D master's degree free/reduced none 56 65 62
male group B associate's degree free/reduced none 70 75 68
male group B master's degree free/reduced none 59 54 53
female group B some college standard completed 78 88 87
male group D bachelor's degree free/reduced completed 64 58 66
female group C associate's degree free/reduced none 53 56 56
female group D some college free/reduced none 54 67 65
female group C some high school free/reduced none 68 76 79
female group C some high school standard none 33 33 31
male group D high school standard completed 85 85 86
female group A some college standard completed 36 56 59
female group D bachelor's degree standard none 86 100 96
male group C associate's degree standard none 87 90 82
male group C master's degree standard completed 94 85 87
male group C some high school free/reduced completed 81 88 80
male group C some college standard none 59 54 54
female group B some college free/reduced completed 31 34 43
male group B some college free/reduced completed 61 60 60
female group D some college standard completed 64 72 79
female group C some college standard none 66 69 65
female group C associate's degree free/reduced none 65 65 65
male group A some high school standard none 52 50 42
female group D associate's degree standard none 69 79 83
female group B associate's degree free/reduced none 69 75 81
female group A some college free/reduced completed 47 66 63
female group C some college standard none 53 63 58
male group B high school free/reduced completed 83 76 77
male group A some college standard none 58 44 44
female group E high school standard none 58 67 69
male group A some college free/reduced completed 67 79 74
female group C bachelor's degree free/reduced none 55 62 60
male group C high school standard none 77 70 63
female group D some high school free/reduced none 63 77 70
female group D some college free/reduced completed 82 95 95
female group B some college free/reduced completed 60 73 68
male group B some high school standard none 44 44 36
male group C some college free/reduced none 55 68 59
male group B associate's degree free/reduced none 44 38 33
male group B some college standard none 81 76 72
male group C some college standard none 76 61 66
female group E associate's degree standard completed 69 79 73
female group D associate's degree standard completed 95 100 100
female group C associate's degree standard completed 91 100 99
male group D some college standard none 86 76 79
female group C some college standard completed 73 82 85
female group A master's degree standard completed 85 94 95
female group B associate's degree free/reduced completed 65 74 77
female group D high school standard none 68 73 75
male group D high school standard completed 76 72 70
male group D some high school standard completed 77 69 68
male group C associate's degree free/reduced completed 59 62 55
female group D high school standard none 61 66 71
male group C associate's degree standard none 93 78 79
male group D master's degree standard completed 84 85 91
female group C master's degree standard none 75 77 79
female group D bachelor's degree standard completed 95 100 100
male group E high school free/reduced completed 75 64 62
female group B some high school standard completed 78 81 77
male group A associate's degree standard none 64 60 55
male group D some college free/reduced completed 62 54 53
female group A master's degree free/reduced completed 40 68 65
female group D master's degree standard none 70 71 71
female group C associate's degree free/reduced completed 77 98 97
female group D master's degree standard none 86 89 92
female group E some college standard none 80 82 86
male group A associate's degree standard none 91 86 88
female group B bachelor's degree free/reduced none 47 59 63
male group D high school free/reduced completed 67 67 63
male group E associate's degree standard none 81 74 73
male group B high school standard none 74 50 54
female group C high school free/reduced completed 61 67 77
female group C some high school standard none 56 70 69
female group C high school free/reduced none 31 41 41
female group B some high school free/reduced none 50 58 50
male group D high school standard completed 85 80 81
female group A some college standard completed 88 100 100
male group C high school free/reduced completed 77 71 77
female group D some high school free/reduced none 66 81 77
female group C high school standard none 65 71 67
female group E bachelor's degree free/reduced none 71 75 73
male group D high school standard none 51 57 51
female group C bachelor's degree standard completed 74 85 92
male group D some high school free/reduced completed 47 46 49
female group E master's degree standard none 78 80 76
female group B master's degree standard completed 72 73 78
female group E some college standard none 87 87 92
male group A some college standard completed 63 63 58
female group B some high school standard none 84 89 82
female group C bachelor's degree standard none 64 62 62
female group B high school standard completed 71 69 70
male group D high school free/reduced completed 48 48 49
female group E bachelor's degree standard none 64 57 61
male group B bachelor's degree standard none 58 52 52
female group D some college free/reduced none 19 35 30
female group D some college free/reduced none 33 46 47
female group B associate's degree standard none 58 64 61
male group E some high school free/reduced completed 71 69 69
female group C associate's degree standard completed 83 90 91
female group B some high school standard none 70 92 86
female group B high school standard none 54 65 66
male group B some college standard none 100 92 84
female group D some college standard completed 54 74 72
female group C high school free/reduced none 48 57 56
male group B master's degree standard none 64 46 52
male group C bachelor's degree free/reduced none 67 65 62
male group B some college standard none 75 58 57
female group C some college free/reduced none 47 53 55
female group C master's degree standard completed 67 79 81
male group D bachelor's degree free/reduced none 79 76 77
female group C high school standard completed 75 79 86
male group B associate's degree free/reduced completed 67 69 67
female group D some college standard none 60 65 66
male group C high school free/reduced none 48 42 42
female group B high school free/reduced none 49 58 60
male group E associate's degree standard completed 93 84 89
female group B some college free/reduced completed 71 80 83
male group D high school standard none 72 66 64
male group E some high school free/reduced completed 73 65 61
female group B some high school free/reduced none 67 75 68
male group E associate's degree standard completed 79 89 80
female group B some college standard completed 76 86 89
female group A some high school standard none 66 58 63
male group E some college standard completed 74 59 60
male group C some high school standard none 69 78 65
male group E high school standard none 94 77 73
male group A some college standard none 72 59 59
male group B high school free/reduced none 48 41 35
male group D some college standard completed 53 49 51
female group C some college free/reduced completed 66 75 73
male group C associate's degree standard none 93 84 86
male group C associate's degree free/reduced completed 57 59 63
male group B associate's degree free/reduced none 61 59 58
male group D some college standard none 75 63 65
female group C some college free/reduced completed 64 79 71
male group D some high school free/reduced none 81 73 75
male group A some college free/reduced none 53 62 60
male group C associate's degree standard none 62 67 61
male group D master's degree free/reduced none 70 62 64
male group C associate's degree standard none 66 54 53
female group C high school standard none 51 67 60
male group B some high school standard none 86 83 79
female group C some college free/reduced none 40 58 55
male group D some college standard completed 86 81 83
male group B master's degree standard none 97 88 88
male group C some high school free/reduced none 43 55 42
female group B high school free/reduced none 62 64 65
female group E some high school standard completed 86 88 83
male group D some high school free/reduced none 68 75 68
male group E associate's degree standard completed 91 90 90
female group D master's degree standard none 83 96 92
male group D high school standard none 67 48 50
female group E some college free/reduced none 69 74 73
male group D high school standard completed 96 83 83
female group D associate's degree standard none 64 63 67
female group D some high school standard none 74 94 92
female group B associate's degree free/reduced completed 72 78 83
female group D high school standard none 75 82 89
female group D some college standard none 88 97 98
male group C associate's degree standard none 69 75 68
female group C associate's degree standard none 84 94 89
male group C high school standard completed 61 63 53
female group C master's degree standard none 64 71 73
female group D some college standard none 72 68 72
female group C bachelor's degree free/reduced none 56 57 59
female group C some high school standard none 60 75 77
male group B bachelor's degree standard none 89 88 79
male group C master's degree standard completed 80 73 70
female group C associate's degree free/reduced completed 58 60 61
male group C high school standard none 71 66 62
male group B associate's degree standard none 60 53 51
male group E bachelor's degree standard none 100 87 90
female group D some college standard none 51 55 59
female group C some college free/reduced none 51 74 73
male group C some college standard completed 76 74 73
male group D bachelor's degree standard none 98 84 89
male group C some college standard none 71 65 64
male group C some high school standard completed 81 80 75
female group B bachelor's degree standard completed 69 86 90
female group A bachelor's degree free/reduced none 37 56 49
female group E some college standard none 70 76 74
female group C some high school free/reduced none 67 74 81
male group E high school standard none 94 80 79
female group C some high school free/reduced none 45 50 52
male group C some college free/reduced none 42 45 44
male group C bachelor's degree free/reduced completed 46 56 48
male group B some college free/reduced completed 57 57 57
male group A some college standard none 51 46 37
female group E some college standard none 63 70 70
male group A some college standard none 94 80 80
female group B some college free/reduced none 52 59 55
female group C high school standard none 47 57 59
female group C high school standard none 53 63 58
female group B high school standard none 60 71 70
male group D some high school standard none 55 51 40
male group D master's degree free/reduced none 82 81 75
male group B high school free/reduced none 46 47 46
female group B some high school standard none 71 86 84
male group E some high school standard none 55 53 52
female group D bachelor's degree standard none 73 85 88
male group A some college standard none 71 79 74
male group D high school standard completed 71 64 66
male group E high school standard none 48 41 35
male group A bachelor's degree standard completed 100 98 99
male group C high school free/reduced completed 49 49 54
female group D bachelor's degree free/reduced none 72 84 83
male group D associate's degree standard completed 80 70 71
male group B some high school free/reduced completed 48 53 47
male group C high school free/reduced completed 71 83 74
male group E master's degree standard completed 85 70 69
female group D associate's degree standard none 67 65 69
male group C some college free/reduced none 61 42 41
male group D high school standard none 75 72 73
female group E some high school free/reduced none 53 63 59
male group C some high school standard none 71 71 59
female group A some college free/reduced completed 31 47 45
female group C some college standard none 86 97 96
female group A some high school standard none 47 53 57
female group D some college standard none 87 88 96
female group C associate's degree standard none 67 79 79
female group A some college free/reduced none 61 69 68
female group C some high school standard none 51 59 60
male group A bachelor's degree free/reduced none 58 56 49
female group D some high school free/reduced none 62 66 66
female group D high school free/reduced completed 65 77 77
female group D some high school standard none 77 76 77
female group D associate's degree free/reduced none 55 62 69
male group B associate's degree standard none 75 80 74
female group A some college free/reduced completed 82 88 85
male group B associate's degree standard completed 61 67 61
female group A master's degree standard none 66 73 73
female group E some college standard none 79 96 92
male group B associate's degree standard completed 93 93 95
female group E bachelor's degree free/reduced none 81 81 83
male group B high school standard completed 86 87 85
male group E some college standard none 100 97 86
female group E master's degree free/reduced completed 85 90 95
male group C bachelor's degree free/reduced none 55 59 54
female group E some high school standard none 95 94 93
male group B some high school free/reduced none 50 50 43
female group C high school standard completed 59 63 62
male group D some high school standard none 62 55 49
female group D some college standard none 77 85 81
male group B high school free/reduced none 78 71 65
female group C associate's degree free/reduced none 46 63 63
female group C bachelor's degree free/reduced none 53 64 64
female group B some college standard none 58 72 68
female group C high school standard none 57 72 67
female group A some college free/reduced completed 44 59 69
female group C some high school standard none 79 85 87
male group B some college standard completed 56 49 47
male group E bachelor's degree standard none 55 48 44
female group D some high school standard none 68 74 73
male group B some college standard none 89 84 84
male group C high school free/reduced none 38 44 40
female group C some college standard none 75 85 84
male group B master's degree free/reduced none 87 92 76
male group C some college standard none 50 41 38
male group C some high school standard none 68 63 53
female group B associate's degree free/reduced completed 53 62 62
female group C some high school free/reduced none 45 53 46
female group D master's degree free/reduced completed 48 80 77
female group D associate's degree standard completed 90 90 92
female group D some college standard none 67 70 70
male group C some college standard none 62 59 54
male group B some high school standard none 67 70 60
female group D some high school standard completed 89 96 97
male group D some high school standard none 60 45 41
male group D high school standard none 89 87 90
female group E some college standard none 79 73 74
female group C associate's degree standard none 59 71 63
male group B high school free/reduced none 49 68 58
male group B some high school free/reduced none 71 79 70
male group D master's degree standard completed 100 96 100
male group A bachelor's degree free/reduced completed 59 63 63
female group B high school free/reduced completed 66 72 74
female group B bachelor's degree standard none 53 61 61
male group C some college standard completed 92 94 93
female group C some college standard none 88 90 95
female group D associate's degree standard none 55 64 71
male group E some high school free/reduced none 59 45 47
male group D master's degree standard none 83 73 74
female group D associate's degree free/reduced completed 54 70 70
female group E associate's degree standard completed 82 83 85
female group D some college standard none 85 94 92
male group C associate's degree free/reduced none 59 62 56
male group D high school standard completed 79 76 79
male group C associate's degree standard none 74 57 61
male group D associate's degree standard none 66 44 49
male group B associate's degree standard completed 54 49 55
female group E high school free/reduced none 68 77 72
male group C associate's degree standard completed 76 78 76
male group A high school free/reduced none 50 48 40
male group D master's degree standard none 100 94 91
female group B associate's degree free/reduced none 28 48 35
female group D associate's degree standard none 62 65 67
female group E some high school standard none 83 74 73
male group E some high school standard none 81 72 75
female group D some high school free/reduced completed 39 65 66
male group C bachelor's degree standard none 92 75 77
female group E some high school standard completed 69 76 74
d3.histoChart = function() {
var histoX = d3.scaleBand()
.padding(.15),
histoY = d3.scaleLinear(),
histoColor = d3.scaleOrdinal(d3.schemeCategory10),
yAxisCall = d3.axisRight(),
width, height, colorscheme,
binVal,
colorVal,
histoRectGs,
yAxis,
bins,
histDomain;
function chart (selection) {
selection.each(function(data) {
var el = d3.select(this)
el.append('style')
.text('.yAxis .domain { stroke: none; }')
bins = d3.histogram()
.value(binVal)
.domain(x.domain())
.thresholds(x.ticks(10))
(data)
if (colorscheme) histoColor = d3.scaleOrdinal(colorscheme)
histoColor.domain(data.map(d => d[colorVal]))
histDomain = histoColor.domain();
bins.forEach(d => {
d.nest = d3.nest()
.key(d => d[colorVal])
.rollup(d => d.length)
.entries(d)
histDomain.forEach(v => {
if (!d.nest.find(k => k.key == v)) d.nest.push({key: v, value: 0})
});
d.nest.sort((a,b) => a.key.localeCompare(b.key))
})
histoX.range([0,width])
.domain(bins.map(d => d.x0));
var yMax = d3.max(bins, d => d3.max(d.nest, v => v.value));
histoY.range([height,0])
.domain([0,yMax])
.nice()
el.append('text')
.text((binVal + '').split('.')[1].replace(/^\w/, c => c.toUpperCase()))
.attr('x', width/2)
.attr('y', -5)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.attr('font-size', "15")
el.append('g')
.attr('transform', 'translate(0,' + height + ')')
.call(d3.axisBottom(histoX))
yAxis = el.append('g')
.attr('class', 'yAxis')
.call(yAxisCall.scale(histoY).ticks(6).tickSize(width))
.call(g => {
//g.select(".domain").remove();
g.selectAll(".tick:not(:first-of-type) line").attr("stroke", "#777").attr("stroke-dasharray", "2,2");
g.selectAll(".tick text").attr("x", 4).attr("dy", -4)
})
histoRectGs = el.selectAll('g.rectG')
.data(bins)
.enter().append('g')
.attr('class', 'rectG')
.attr('transform', d => 'translate(' + histoX(d.x0) + ',0)');
histoRectGs.selectAll('rect')
.data(d => d.nest)
.enter().append('rect')
.attr('x', (d,i) => histoX.bandwidth()/histDomain.length * i)
.attr('y', d => histoY(d.value))
.attr('width', histoX.bandwidth()/histDomain.length)
.attr('height', d => height - histoY(d.value))
.attr('fill', d => histoColor(d.key))
})
}
chart.width = function (_){
return arguments.length ? (width = _, chart) : width;
};
chart.height = function (_){
return arguments.length ? (height = _, chart) : height;
};
chart.colorScheme = function (_){
return arguments.length ? (colorscheme = _, chart) : colorscheme;
};
chart.binVal = function (_){
return arguments.length ? (binVal = _, chart) : binVal;
};
chart.colorVal = function (_){
return arguments.length ? (colorVal = _, chart) : colorVal;
};
chart.updateData = function(newData) {
var bins = d3.histogram()
.value(binVal)
.domain(x.domain())
.thresholds(x.ticks(10))
(newData)
bins.forEach(d => {
d.nest = d3.nest()
.key(d => d[colorVal])
.rollup(d => d.length)
.entries(d)
histDomain.forEach(v => {
if (!d.nest.find(k => k.key == v)) d.nest.push({key: v, value: 0})
});
d.nest.sort((a,b) => a.key.localeCompare(b.key))
})
var yMax = d3.max(bins, d => d3.max(d.nest, v => v.value));
histoY.domain([0,yMax])
yAxis.transition()
.call(yAxisCall.scale(histoY).ticks(6).tickSize(width))
.call(g => {
g.select(".domain").remove();
g.selectAll(".tick:not(:first-of-type) line").attr("stroke", "#777").attr("stroke-dasharray", "2,2");
g.selectAll(".tick text").attr("x", 4).attr("dy", -4)
})
histoRectGs.data(bins)
histoRectGs.selectAll('rect')
.data(d => d.nest)
.transition()
.attr('y', d => histoY(d.value))
.attr('height', d => height - histoY(d.value))
return chart;
}
return chart;
}
<!DOCTYPE html>
<body>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="histoChart.js"></script>
<script src="scatterChart.js"></script>
<script>
var m = [40, 30, 40, 40],
w = 960 - m[1] - m[3],
h = 500 - m[0] - m[2],
wTrip = w/3 - m[1],
hTrip = h/2 - m[0];
var x = d3.scaleLinear()
.range([0,wTrip])
.domain([0,100]),
y = d3.scaleLinear()
.range([hTrip,0])
.domain([0,100]),
z = d3.scaleLinear()
.range([5,20])
.domain([0,100]),
color = d3.scaleOrdinal(d3.schemeDark2);
var svg = d3.select("body").append("svg")
.attr("width", w + m[1] + m[3])
.attr("height", h + m[0] + m[2])
.append("g")
.attr("transform", "translate(" + m[3] + "," + m[0] + ")");
//d3.csv('exams.csv')
// .then(data => render(data))
d3.csv('examsLess.csv')
.then(data => render(data))
function render(data) {
data.forEach(d => {
d.math = +d.math;
d.reading = +d.reading;
d.writing = +d.writing;
});
console.log(data)
var scatterRadius = 1.5,
colorScheme = d3.schemeDark2,
type = 'ethnicity';
var scatMathReading = d3.scatter()
.width(wTrip)
.height(hTrip)
.scheme(colorScheme)
.xVal('math')
.yVal('reading')
.colorVal(type)
.radius(scatterRadius)
var scatMathWriting = d3.scatter()
.width(wTrip)
.height(hTrip)
.scheme(colorScheme)
.xVal('math')
.yVal('writing')
.colorVal(type)
.radius(scatterRadius)
var scatReadingWriting = d3.scatter()
.width(wTrip)
.height(hTrip)
.scheme(colorScheme)
.xVal('reading')
.yVal('writing')
.colorVal(type)
.radius(scatterRadius)
var mathHisto = d3.histoChart()
.width(wTrip)
.height(hTrip)
.colorScheme(colorScheme)
.binVal(d => d.math)
.colorVal(type);
var readingHisto = d3.histoChart()
.width(wTrip)
.height(hTrip)
.colorScheme(colorScheme)
.binVal(d => d.reading)
.colorVal(type);
var writingHisto = d3.histoChart()
.width(wTrip)
.height(hTrip)
.colorScheme(colorScheme)
.binVal(d => d.writing)
.colorVal(type);
scatMathReading.update([
{chart: scatMathWriting, type: 'data'},
{chart: scatReadingWriting, type: 'data'},
{chart: mathHisto, type: 'data'},
{chart: readingHisto, type: 'data'},
{chart: writingHisto, type: 'data'}
]);
scatMathWriting.update([
{chart: scatMathReading, type: 'data'},
{chart: scatReadingWriting, type: 'data'},
{chart: mathHisto, type: 'data'},
{chart: readingHisto, type: 'data'},
{chart: writingHisto, type: 'data'}
])
scatReadingWriting.update([
{chart: scatMathReading, type: 'data'},
{chart: scatMathWriting, type: 'data'},
{chart: mathHisto, type: 'data'},
{chart: readingHisto, type: 'data'},
{chart: writingHisto, type: 'data'}
])
var nest = d3.nest()
.key(d => d[type])
.entries(data);
var colors = d3.scaleOrdinal(colorScheme)
.domain(nest.map(d => d.key));
var legend = svg.append('g')
.selectAll('g.legendItem')
.data(nest)
.enter().append('g')
.attr('class', d => d.key.replace(/\s|\//, ''))
.on('click', function(a,b,c) {
console.log('a', a)
console.log('b', b)
console.log('c', c)
var g = d3.select(c[b])
if (g.select('rect').attr('fill') === '#bbb') {
g.select('rect')
.attr('fill', d => colors(d.key))
scatMathReading.updateData(data)
scatMathWriting.updateData(data)
scatReadingWriting.updateData(data)
mathHisto.updateData(data)
readingHisto.updateData(data)
writingHisto.updateData(data)
} else {
g.select('rect')
.attr('fill', '#bbb')
scatMathReading.updateData(a.values)
scatMathWriting.updateData(a.values)
scatReadingWriting.updateData(a.values)
mathHisto.updateData(a.values)
readingHisto.updateData(a.values)
writingHisto.updateData(a.values)
}
})
legend.append('rect')
.attr('x', 0)
.attr('y', 0)
.attr('width', 10)
.attr('height', 10)
.attr('stroke', function (d) { return colors(d.key); })
.attr('stroke-width', 2)
.attr('fill', function (d) { return colors(d.key); });
legend.append('text')
.text(function (d) { return d.key.replace(/^\w/, c => c.toUpperCase()); })
.attr('x', 15)
.attr('y', 10);
var moveLegend = 0;
legend.each(function (g) {
var gDiv = svg.select('g.' + g.key.replace(/\s|\//, ''));
var gWidth = gDiv.node().getBoundingClientRect().width + 10;
moveLegend += gWidth;
gDiv.attr('transform', 'translate(' + [(moveLegend - gWidth) + 40, 0] + ')');
});
svg.append("g")
.attr('transform', 'translate(' + 0 + ',' + m[0] + ')' )
.datum(data)
.call(scatMathReading)
svg.append("g")
.attr('transform', 'translate(' + (wTrip + m[1]) + ',' + m[0] + ')' )
.datum(data)
.call(scatMathWriting)
svg.append("g")
.attr('transform', 'translate(' + (wTrip + m[1])*2 + ',' + m[0] + ')' )
.datum(data)
.call(scatReadingWriting)
svg.append("g")
.attr('transform', 'translate(' + 0 + ',' + (hTrip + m[0]*2) + ')' )
.datum(data)
.call(mathHisto)
svg.append("g")
.attr('transform', 'translate(' + (wTrip + m[1]) + ',' + (hTrip + m[0]*2) + ')' )
.datum(data)
.call(readingHisto)
svg.append("g")
.attr('transform', 'translate(' + (wTrip + m[1])*2 + ',' + (hTrip + m[0]*2) + ')' )
.datum(data)
.call(writingHisto)
function renderWithType(str) {
}
}
</script>
</body>
</html>
d3.scatter = function() {
var width, height, scheme,
x = d3.scaleLinear(),
y = d3.scaleLinear(),
color = d3.scaleOrdinal(d3.schemeCategory10),
xVal, yVal, colorVal,
brush = d3.brush(),
updates,
el,
radius,
circles;
function chart (selection) {
selection.each(function(data) {
el = d3.select(this)
x.range([0,width]).domain([0, d3.max(data, d => d[xVal])])
y.range([height,0]).domain([0, d3.max(data, d => d[yVal])])
if (scheme) color = d3.scaleOrdinal(scheme);
color.domain(data.map(d => d[colorVal]))
el.append('style')
.text('.brush rect.selection { fill-opacity: 0.1; }')
el.append('text')
.text(xVal.replace(/^\w/, c => c.toUpperCase()) + ' vs ' + yVal.replace(/^\w/, c => c.toUpperCase()))
.attr('x', width/2)
.attr('y', -10)
.attr('text-anchor', 'middle')
var xAxis = el.append('g')
.call(d3.axisBottom(x).tickSize(height))
.call(g => {
g.select('.domain').remove()
g.selectAll('line').attr('stroke', '#aaa')
g.select('.tick:last-of-type text').clone()
.attr('y', height - 8)
.attr('text-anchor', 'end')
.attr('font-weight', 'bold')
.text(xVal.replace(/^\w/, c => c.toUpperCase()))
g.select('.tick:last-of-type line').remove()
g.select('.tick:first-of-type line').remove()
g.select('.tick:first-of-type text').attr('x', -4)
})
var yAxis = el.append('g')
.attr('transform', 'translate(' + width + ',0)')
.call(d3.axisLeft(y).tickSize(width))
.call(g => {
g.select('.domain').remove()
//g.selectAll('text').remove()
g.selectAll('line').attr('stroke', '#aaa')
g.select('.tick:last-of-type text').clone()
.attr('x', -width + 4)
.attr('text-anchor', 'start')
.attr('font-weight', 'bold')
.text(yVal.replace(/^\w/, c => c.toUpperCase()))
g.select('.tick:last-of-type line').remove()
g.select('.tick:first-of-type line').remove()
g.select('.tick:first-of-type text').remove()
})
circles = el.selectAll('circle')
.data(data)
.enter().append('circle')
.attr('class', 'active')
.attr('cx', d => x(d[xVal]))
.attr('cy', d => y(d[yVal]))
.attr('fill', d => color(d[colorVal]))
.attr('r', radius ? radius : 3)
brush.extent([[0, 0], [width, height]])
.on("start brush", brushed)
.on("end", brushend);
el.append("g")
.attr("class", "brush")
.call(brush)
function brushed() {
var s = d3.event.selection;
if (s) {
var brushSelected = circles.filter(function() {
return isBrushed(s, d3.select(this).attr('cx'), d3.select(this).attr('cy'));
});
brushSelected.transition()
.attr('fill', d => color(d[colorVal]))
circles.filter(function() {
return !isBrushed(s, d3.select(this).attr('cx'), d3.select(this).attr('cy'));
}).transition()
.attr('fill', '#bbb')
if (updates && (d3.event.sourceEvent.type === "mousemove" || d3.event.sourceEvent.type === "mousedown")) {
updates.forEach(update => {
if (update.type === 'brush') update.chart.updateBrush(s)
else if (update.type === 'data') update.chart.updateData(brushSelected.data())
})
}
}
}
function brushend() {
if (!d3.event.selection) {
circles.transition()
.attr('fill', d => color(d[colorVal]))
if (updates) {
updates.forEach(update => {
if (update.type === 'data') update.chart.updateData(circles.data())
})
}
}
}
})
}
function isBrushed(brush_coords, cx, cy) {
return brush_coords[0][0] <= cx && cx <= brush_coords[1][0] && brush_coords[0][1] <= cy && cy <= brush_coords[1][1];
}
chart.width = function(_) {
return arguments.length ? (width = _, chart) : width;
}
chart.height = function(_) {
return arguments.length ? (height = _, chart) : height;
}
chart.scheme = function(_) {
return arguments.length ? (scheme = _, chart) : scheme;
}
chart.xVal = function(_) {
return arguments.length ? (xVal = _, chart) : xVal;
}
chart.yVal = function(_) {
return arguments.length ? (yVal = _, chart) : yVal;
}
chart.colorVal = function(_) {
return arguments.length ? (colorVal = _, chart) : colorVal;
}
chart.update = function(_) {
return arguments.length ? (updates = _, chart) : updates;
}
chart.updateData = function(newData) {
circles.filter(function(d) {
return newData.indexOf(d) > -1;
}).transition()
.attr('fill', d => color(d[colorVal]));
circles.filter(function(d) {
return newData.indexOf(d) === -1;
}).transition()
.attr('fill', '#bbb');
return chart;
}
chart.resetData = function() {
circles.transition()
.attr('fill', d => color(d[colorVal]));
return chart;
}
chart.updateBrush = function(extent) {
el.select(".brush").call(brush.move, extent);
return chart;
}
chart.radius = function(_) {
return arguments.length ? (radius = _, chart) : radius;
}
chart.colorScale = function() {
return color;
}
return chart;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment