Skip to content

Instantly share code, notes, and snippets.

@asizer
asizer / README.md
Last active November 8, 2019 07:37
d3 Horizontal BoxPlot

This sample is based on Mike Bostock's Box Plots. The box.js file has been modified in a number of ways besides making the box plots horizontal: the transitions have been removed, the 1.5 iqr function is included as the default to compute the whisker length, data objects are attached to the whisker ends and outlier dots (instead of just the values), and there are transparent q1-q2 and q2-q3 boxes that contain those respective data points for possible future use.

Hovering over outlier dots in the boxplot highlights them on the table and vice-versa. This also demonstrates a move-to-front functionality -- when an outlier circle is highlighted, it is moved to the end of the svg's elements so that it appears on top of the other outliers.

Also, the axis rounds its range to intervals that go into a power of 10 (see the cleanUpChartRange function).

The variable being plotted is a generated logNoraml distribution, to demonstrate outliers more prominently (sometimes there are so many, the table gets cut

@asizer
asizer / README.md
Last active August 29, 2015 14:00
Map with header/footer

This example gets around the map's need for a height when you don't know the height of the map, but you do know the height of the header and footer. Set the map container's position: absolute and the top and bottom properties to account for the header and footer heights.

Firefox seems to treat box-sizing differently, so add 4 px to the map's top/bottom to account for the header/footer borders

@asizer
asizer / LayerSearch.css
Last active August 29, 2015 14:00
Layer Search
.esriLayerSearcher .esriLayerSearcherClearFloat {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
.simpleLayerSearcher .esriLayerSearcherContainer *,
@asizer
asizer / README.md
Last active August 29, 2015 14:03
Map horizontal repeat

Demonstrates the ability to repeat a map horizontally.

The map's container's container gets a clip dynamically added to it such that repeated tiles are not shown. To get rid of the clip, we just need:

.map .container .container {
  clip: inherit !important;
}

Note: Only the basemap layers will be repeated. The data layers will appear once.

@asizer
asizer / Widget.js
Created July 11, 2014 22:25
Make dojo xhrRequest work with secured service
/* all this is around line 334 of SQLQuery/Widget.js */
// option 1 is to query the rest endpoint for unique values.
// option 2 is to store featureSet clientside (1000 limit)
var tokenRequest = esri.id.findCredential(this.activeInfo.fLayerUrl); // THIS IS NEW!
if (!this.activeInfo.featureSet) {
dojoXhr(this.activeInfo.fLayerUrl + '/query', {
query: {
where: '1=1',
outFields: fieldInfo.name,
@asizer
asizer / README.md
Last active August 29, 2015 14:04 — forked from mbostock/.block
@asizer
asizer / index.html
Created September 11, 2014 03:13
LabelClass on DynamicLayer
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<link rel="stylesheet" href="//js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body, #map {
height: 100%; width: 100%; margin: 0; padding: 0;
@asizer
asizer / README.md
Created October 28, 2014 15:46
Feature Layer with Multi-Line Labels

Multi-line labels on a Feature Layer

This is a workaround to add line breaks to the Label Layer

NOTE: I can't figure out a way to return all the labels for a Feature Layer here, unfortunately. The Label Layer only returns the labels that will fit into their elements, or not conflict with other labels, as calculated based on the original, single-line label. Splitting these labels into multiple lines might reduce conflicts, or allow them to fit properly within their polygons, but because they were conflicted out in the first place, we never see them.

@asizer
asizer / index.html
Created November 7, 2014 01:13
Colors for labels
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Feature Layer Multi-Line Labels</title>
<link rel="stylesheet" href="//js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body, #map {
height: 100%; width: 100%; margin: 0; padding: 0;
@asizer
asizer / partialGruntfile.js
Last active August 29, 2015 14:12
Use grunt concat to create single file for dojo modules AND TEMPLATES!
concat: {
options: {
banner: 'require({\ncache: {\n',
process: function(src, filepath) {
var returnStr = '// Source: ' + filepath + '\n';
if (filepath.indexOf('.js') > 0) {
// add file name
returnStr += '\'' + filepath.replace('js/', '').replace('.js', '') + '\': ';
// add function and file text
returnStr += 'function() {\n' + src + '}';