master a399f2ea5c1f cached
21 files
36.7 KB
9.8k tokens
10 symbols
1 requests
Download .txt
Repository: thetylerwolf/sketch-data-studio
Branch: master
Commit: a399f2ea5c1f
Files: 21
Total size: 36.7 KB

Directory structure:
gitextract_dhow8vzv/

├── .gitignore
├── LICENSE
├── README.md
└── sketch-data-studio-free.sketchplugin/
    └── Contents/
        └── Sketch/
            ├── controllers/
            │   ├── genChart.js
            │   └── genTable.js
            ├── csvUpload/
            │   └── importCSVToTable.js
            ├── functions/
            │   └── inputs.js
            ├── genCharts/
            │   ├── barChart.js
            │   └── lineChart.js
            ├── genTables/
            │   ├── rand01.js
            │   ├── rand0100.js
            │   ├── randArb.js
            │   ├── randBond.js
            │   ├── randStock.js
            │   └── randSymbol.js
            ├── globals/
            │   ├── chartColors.js
            │   ├── chartTypes.js
            │   ├── dataTypes.js
            │   ├── names.js
            │   └── symbols.js
            └── manifest.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
.DS_Store

================================================
FILE: LICENSE
================================================
Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



================================================
FILE: README.md
================================================
Sketch Data Studio
==================

A Sketch plugin to upload or generate numerical and qualitative data for charts and tables. Ideal for those working on big data interfaces or for data scientists who want charts that look better than those produced by spreadsheet software. Updated frequently.

#### Go Premium
Premium version enables generating Charts from imported CSV data, as well as more chart types to choose from.
#### [Go Premium!](http://thetylerwolf.github.io/sketch-data-studio)

![Screenshot](/../screenshots/screenshots/screenshot_dashboard.png?raw=true)

## Compatibility
Sketch v41 and later only!

## How to use
Enter number of columns, followed by number of rows or number of charts (comma separated) and you're done.

## Data Types
##### *Random 0 - 1*
A random floating point number from 0 - 1

##### *Random 0 - 100*
A random floating point number from 0 - 100

##### *Set your own random values*
Input a comma-separated list of values that will be picked at random for each row. This can be used to select random integers (1,2,3,4...)

##### *Random Stocks*
Stock names randomly chosen from a list of stocks that were found on the internet.

##### *Random Bonds*
Bond names randomly chosen from a list of stocks that were found on the internet, then a random number between 1 and 10 is chosen and concatenated with the letters "YR" (e.g. 1YR, 4YR, etc.)

##### *Random Stock Symbols*
Stock ticker symbols randomly chosen from a list of stocks that were found on the internet.

## *CSV Import*
Save a spreadsheet in **.csv** format and import it through the dialogue. Only files with a **.csv** or **.CSV** extension will be import-able.

#### *Tables*
Any data should work.

#### *FAQ*
**Q**: My imported CSV data comes in with a weird format/I get an error when uploading CSV!<br>
**A**: Make sure your file is correctly formatted (utf-8). If you're not sure what that means, try the following:
Upload your CSV file to Google Docs
Download the file as a CSV
Try with the newly downloaded file

## Bug reporting
Please include your OS X version as well as your Sketch version in any bug reports.

## Disclaimer
All data labeled "Random" is completely random and is not useful for any sort of financial planning. Data is for mock-up/demo purposes only.

Made by [Tyler Wolf](http://www.tylernwolf.com)


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/controllers/genChart.js
================================================
@import '../functions/inputs.js'
@import '../globals/chartTypes.js'

var input, values,
    firstChoices, group, points,
    seriez, seriesLayer, seriesArray;
var sLoc;


input = askForInput(chartTypes[dt].name, 'charts');
if(input.result == 1001) return;

points = Math.abs(input.points.intValue()) || 1;
seriez = Math.abs(input.items.intValue()) || 1;

group = [MSLayerGroup new];

//If we're using artboards, add to the current artboard
if(doc.currentPage().artboards().count() > 0) {
  var currentArtboard = doc.currentPage().currentArtboard();
  // group = currentArtboard.addLayerOfType('group');

  currentArtboard.addLayers([group]);
} else {
  doc.currentPage().addLayers([group]);
}

group.setName('chart');
group.frame().x = 100;
group.frame().y = 100;
group.frame().height = 120 * seriez;
if(/bar|Bar/.test(dt)) {
  group.frame().width = (points * 30) - 10;
} else if(/line|Line/.test(dt)) {
  group.frame().width = (points * 10);
}


for(i=seriez; i>0; i--) {
    var seriesGroup = [MSLayerGroup new];
    group.addLayers([seriesGroup]);

    seriesGroup.setName('series');

    seriesArray = genSeries(points, i, dt);
    sizeGroup(seriesGroup,seriesArray,i);
    // I'll use sLoc later, I swear it.
    sLoc = generateChart(seriesArray,i,seriesGroup);

}

function sizeGroup(seriesGroup, seriesArray, i) {
    var maxPoint = Math.max.apply(Math,seriesArray);
    var minPoint = Math.min.apply(Math,seriesArray);

    seriesGroup.frame().x = 0;
    seriesGroup.frame().y = 120*(i - 1);

    seriesGroup.frame().height = maxPoint - (minPoint < 0 ? minPoint : 0);

    if(/bar|Bar/.test(dt)) {
      seriesGroup.frame().width = (points * 30) - 10;
    } else if(/line|Line/.test(dt)) {
      seriesGroup.frame().width = (points * 10);
    }
}


function genSeries(numSeries, index, dt) {
    var result = [],
        num;

    for(var i = numSeries; i>0; i--) {
        num = chartTypes[dt].val(index, values);
        result.push(num);
    }

    return result;
}

function generateChart(sArray,i, group) {
    return chartTypes[dt].generate(sArray,i,group);
}

function isText(layer) {
    return layer.isMemberOfClass(MSTextLayer);
}


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/controllers/genTable.js
================================================
@import '../functions/inputs.js';
@import '../globals/names.js';
@import '../globals/symbols.js';
@import '../globals/dataTypes.js';

var input, values,
    firstChoices, group, rows,
    cols, textLayer;

if(dt == 'fromCSV') {
    values = importFromCSV();
    if(values == false) return;
} else {
    //First input
    input = askForInput(dataTypes[dt].name, 'tables', dt);
    if(input.result == 1001) return;

    rows = Math.abs(input.points.intValue()) || 1;
    cols = Math.abs(input.items.intValue()) || 1;

    if(dt == 'arbitrary') {
        var arbValues = input.arb.stringValue()
        arbValues = arbValues.split(',');
        values = arbValues.map(function(d) { return d.trim(); });
    }

}
//If we're using artboards, add to the current artboard
group = [MSLayerGroup new];

//If we're using artboards, add to the current artboard
if(doc.currentPage().artboards().count() > 0) {
  var currentArtboard = doc.currentPage().currentArtboard();
  // group = currentArtboard.addLayerOfType('group');

  currentArtboard.addLayers([group]);
} else {
  doc.currentPage().addLayers([group]);
}

group.setName('columns');

if(dt !== 'fromCSV') {

    for(i=cols; i>0; i--) {
        textLayer = [MSTextLayer new];
        group.addLayers([textLayer]);
        genRows(rows, textLayer, i, dt);
    }

} else {

    for(i=0; i<cols; i++) {
        textLayer = [MSTextLayer new];
        group.addLayers([textLayer]);
        resultStr = values[i].join('\n');
        textLayer.setStringValue(resultStr);
        textLayer.adjustFrameToFit();
        placeLayer(textLayer, i);
    }

}

return;

function genRows(numCols, layer, index, dt) {
    var result = [],
        num;

    for(var i = numCols; i>0; i--) {
        num = dataTypes[dt].val(index, values);
        result.push(num);
    }

    resultStr = result.join('\n');
    layer.setStringValue(resultStr);
    layer.adjustFrameToFit();
    placeLayer(layer, index);
}

function placeLayer(layer, index) {
    layer.frame().setX(index * 100);
    refreshTextLayer(layer);
}

function isText(layer) {
    return layer.isMemberOfClass(MSTextLayer);
}

function importFromCSV() {
    var path = dataTypes[dt].prompt();
    if(!path) return false;

    //get root dir
    // var rootDir = [path stringByDeletingLastPathComponent];
    // if(!Sandbox.authoriseDir(rootDir)) return;

    var contents = dataTypes[dt].load(path);

    var data = dataTypes[dt].transform(contents);
    cols = data.length;

    return data;
}

// Taken from Sketch Data Populator - Thanks!
// https://github.com/preciousforever/sketch-data-populator
function refreshTextLayer(layer) {
    [layer select: true byExpandingSelection: false];
    [layer setIsEditingText: true];
    [layer setIsEditingText: false];
    [layer select: false byExpandingSelection: false];
}

================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/csvUpload/importCSVToTable.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'fromCSV';

	@import '../controllers/genTable.js'
};

================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/functions/inputs.js
================================================
function askForInput(title, type, dt) {
  var alert = [COSAlertWindow new];
        [alert setMessageText: title];

  var optionsView = [[NSView alloc] initWithFrame: NSMakeRect(0, 0, 300, 85)];
  [alert addAccessoryView: optionsView];

  var numItemsText = 'Number of ' + (type == 'charts' ? 'charts' : 'columns');
  var numLabel = addLabel(numItemsText, NSMakeRect(0, 65, 200, 20));
  [optionsView addSubview: numLabel];

  var numInput = addInput(1, NSMakeRect(130, 65, 50, 20));
  [optionsView addSubview: numInput];

  var numPointsText = 'Number of ' + (type == 'charts' ? 'points' : 'rows');
  var pointsLabel = addLabel(numPointsText, NSMakeRect(0, 35, 200, 20));
  [optionsView addSubview: pointsLabel];

  var pointsInput = addInput(10, NSMakeRect(130, 35, 50, 20));
  [optionsView addSubview: pointsInput];

  // add bottom buttons
  [alert addButtonWithTitle:"Generate"];
  [alert addButtonWithTitle:"Cancel"];

  var arbitraryInput;

  log(dt);
  if(dt == 'arbitrary') {
    var arbitraryText = 'Arbitrary values';
    var arbitraryLabel = addLabel(arbitraryText, NSMakeRect(0,5, 150, 20));
    [optionsView addSubview: arbitraryLabel];

    arbitraryInput = addInput('', NSMakeRect(130,5,150,20));
    [optionsView addSubview: arbitraryInput];
  }
  
  var input = [alert runModal];

  return {
    items: numInput,
    points: pointsInput,
    arb: arbitraryInput,
    result: input
  };

  function addLabel(optionValue, frame) {

    var label = [[NSTextField alloc] initWithFrame: frame];
    [label setStringValue: optionValue];
    [label setBezeled:false];
    [label setDrawsBackground:false];
    [label setEditable:false];
    [label setSelectable:false];

    return label;
  }

  function addInput(defaultValue, frame) {

    var input = [[NSTextField alloc] initWithFrame: frame];
    [input setStringValue: defaultValue];
    [input setBezeled:true];
    [input setDrawsBackground:true];
    [input setEditable:true];
    [input setSelectable:true];

    return input;
  }
}


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genCharts/barChart.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'barSeries';

	@import '../controllers/genChart.js';
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genCharts/lineChart.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = "lineSeries";

	@import '../controllers/genChart.js';
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/rand01.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'zeroToOne';

	@import '../controllers/genTable.js';
}


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/rand0100.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'zeroToHundred';

	@import '../controllers/genTable.js'
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randArb.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'arbitrary';

	@import '../controllers/genTable.js';
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randBond.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'bond';

	@import '../controllers/genTable.js';
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randStock.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'stock';

	@import '../controllers/genTable.js';
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randSymbol.js
================================================
var onRun = function(context) {
	var doc = context.document;
	var dt = 'symbol';

	@import '../controllers/genTable.js'
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/chartColors.js
================================================
var chartColors = [
    '#1f77b4',
    '#ff7f0e',
    '#2ca02c',
    '#d62728',
    '#9467bd',
    '#8c564b',
    '#e377c2',
    '#7f7f7f',
    '#bcbd22',
    '#17becf'
];

================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/chartTypes.js
================================================
@import '../globals/chartColors.js'

var chartTypes = {
    lineSeries : {
        name: 'Line Chart (Geometric Time Series)',
        val: function() {
            //Brownian time series for realism
            var direction = this.direction || Math.random() * 3 + -8;
            var prev = this.prev || Math.random() * 100;
            var rand = Math.random() * 10 + direction;
            var mean = 5;
            var vol = 5;
            var dt = 1;

            var result = (mean * dt) + (vol * rand * dt);
            this.prev = result + prev;

            return -this.prev.toFixed(2);
        },
        reset: function() {
            this.prev = undefined;
        },
        chartable: true,
        generate: function(pointsArray, index, group) {
            var avgPoint = pointsArray.reduce(function(a,b) {
                return a + b
              },0);

            var base = Math.max.apply(Math, pointsArray);
            var path = NSBezierPath.bezierPath();

            //initialize path
            var firstP = pointsArray[0];

            path.moveToPoint(NSMakePoint(0, base - firstP));

            //get rid of first point in series
            pointsArray.shift();

            var x;
            pointsArray.forEach(function(d,i) {
              x = (i + 1) * 10;
              path.lineToPoint(NSMakePoint(x, base - d));
            });

            var shape = MSShapeGroup.shapeWithBezierPath(path);

            var border = shape.style().addStylePartOfType(1);

            var idx = index % chartColors.length;
            var iColor = chartColors[idx];
            border.color = MSImmutableColor.colorWithSVGString(iColor);
            border.thickness = 2;

            group.addLayers([shape]);

            this.reset();
        }
    },
    barSeries : {
        name: 'Bar Chart (Random 1 - 100)',
        val: function() {
            var rand = Math.random() * 100 + 1;
            return rand.toFixed(2);
        },
        chartable: true,
        generate: function(va,index, group) {
            var base = Math.max.apply(Math, va);
            var height, width, x, y;
                height = width = x = y = 0;

            va.forEach(function(d,i) {
                var rect = MSRectangleShape.alloc().init();

                width = 20;
                x = i * 30;

                if(d < 0) {
                    y = base;
                    height = -d;

                } else {
                    // Not sure why, but base goes to 0 when d == 0
                    y = base - (d || 1);
                    height = d || 1;
                }

                rect.frame = MSRect.rectWithRect(NSMakeRect(x,y,width,height));

                rect = MSShapeGroup.shapeWithPath(rect);

                rect.setName('bar');

                var rectFill = rect.style().addStylePartOfType(0);

                var idx = index % chartColors.length;
                var iColor = chartColors[idx];
                rectFill.color = MSImmutableColor.colorWithSVGString(iColor);

                rect.frame().constrainProportions = false;

                width = rect.frame().x + rect.frame().width;
                height = Math.max(rect.frame().height, height);
                group.addLayers([rect])
            });

            return {
                w: width,
                h: height,
                x: x,
                y: base
            }

        }
    }
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/dataTypes.js
================================================
var dataTypes = {
    zeroToOne : {
        name: 'Random 0 - 1',
        val: function() {
            var rand = Math.random();
            rand = rand.toFixed(2).toString();
            return rand;
        }
    },
    zeroToHundred : {
        name: 'Random 0 - 100',
        val: function() {
            var rand = Math.random() * 100;
            rand = rand.toFixed(2).toString();
            return rand;
        }
    },
    arbitrary : {
        name: 'Set your own random values',
        val: function(index, values) {
            var pickNum = values.length;
            var rand = Math.random() * values.length;
            rand = Math.floor(rand);
            return values[rand];
        }
    },
    stock : {
        name: 'Random Stocks',
        val: function() {
            var rand = Math.random() * stockNames.length;
            rand = Math.ceil(rand);
            return stockNames[rand-1];
        }
    },
    bond : {
        name: 'Random Bonds',
        val: function() {
            var rand = Math.random() * stockNames.length;
            rand = Math.ceil(rand);
            var years = Math.random() * 10;
            years = Math.ceil(years);
            return stockNames[rand-1] + ' ' + years + 'YR';
        }
    },
    symbol : {
        name: 'Random Stock Symbols',
        val: function() {
            var rand = Math.random() * stockSymbols.length;
            rand = Math.ceil(rand);
            return stockSymbols[rand-1];
        }
    },
    fromCSV : {
        name: 'Generate from CSV',
        prompt: function() {
            var panel = [NSOpenPanel openPanel];

            [panel setTitle: "Select File"];
            [panel setMessage: "Select the CSV file to use"];
            [panel setPrompt: "Choose"];

            [panel setCanCreateDirectories: false];
            [panel setCanChooseFiles: true];
            [panel setCanChooseDirectories: false];
            [panel setAllowsMultipleSelection: false];
            [panel setShowsHiddenFiles: false];
            [panel setExtensionHidden: false];

            var fileTypes = ['csv', 'CSV'];
            [panel setAllowedFileTypes:fileTypes];

            var pressedButton = [panel runModal];
            if(pressedButton == NSOKButton) {
                return [[panel URL] path];
            } else {
                return false;
            }
        },
        load: function(path) {
            var contents = [NSString stringWithContentsOfFile: path encoding: NSUTF8StringEncoding error: false];

            return contents;
        },
        transform: function(content) {
            content = content.replace(/\n\r/g,'\n');
            content = content.replace(/\r\n/g,'\n');
            content = content.replace(/\r/g,'\n');
            var data = content.split('\n');

            // data = data.map(function(d) { return d.split(','); });

            data = data.map(function(d) {
                var exp = new RegExp('["|""]','g');
                var string = d.replace(exp,',');
                string = string.split(',');
                return string;
            });

            data = data[0].map(function(d,i) {
                return data.map(function(j) {
                    return j[i];
                });
            });

            return data;
        }
    }
};


================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/names.js
================================================
var stockNames = [
    "Mol Global Inc.",
    "Digital Ally",
    "Image Sensing Systems",
    "Spansion Inc",
    "Viggle Inc.",
    "Shoe Carnival",
    "Cypress Semiconductor Corp",
    "Ring Energy Inc",
    "Idera Pharmaceuticals",
    "Avanir Pharmaceuticals Inc",
    "Immune Pharmaceuticals Inc.",
    "Digimarc Corp",
    "ANI Pharmaceuticals Inc",
    "Valero Energy Partners LP",
    "Pozen Inc",
    "Lakeland Industries",
    "Callon Petroleum Company",
    "Alpha Pro Tech",
    "Aerie Pharmaceuticals Inc",
    "Taser International",
    "North Atlantic Drilling Ltd. Co",
    "Jd.Com Inc.",
    "Covisint Corp",
    "Dycom Industries",
    "E2Open Inc",
    "Memorial Production Partners LP",
    "Greenbrier Companies",
    "Seadrill Partners Llc",
    "Tg Therapeutics",
    "Phillips 66 Partners LP",
    "Planar Systems",
    "Sequenom Inc",
    "Ptc Therapeutics Inc",
    "Karyopharm Therapeutics Inc",
    "Englobal Corp",
    "Shell Midstream Partners L.P.",
    "Tetraphase Pharmaceuticals Inc",
    "Amyris Inc",
    "Enphase Energy Inc",
    "Dynavax Technologies Corp",
    "Ev Energy Partners L.P.",
    "Magnum Hunter Resources Corp",
    "Atlas Pipeline Partners L.P.",
    "Nanometrics Inc",
    "The Bancorp",
    "Truecar Inc.",
    "Energy Xxi [Bermuda] Limited",
    "Turquoise Hill Resources Ltd",
    "Sportsman'S Warehouse Holdi",
    "Teekay Shipping Corp",
    "Flamel Technologies S.A.",
    "Magal Security Systems Ltd",
    "China Life Insurance Company Limited",
    "Textura Corp",
    "Raptor Pharmaceutical",
    "Limelight Networks",
    "Omnivision Technologies",
    "Fmsa Holdings Inc",
    "Harte-Hanks",
    "Dominion Midstream Partners LP",
    "Enable Midstream Partners LP",
    "Coherus Biosciences Inc.",
    "Breitburn Energy Partners L.P.",
    "Western Refining",
    "Sophiris Bio Inc",
    "Achillion Pharmaceuticals",
    "Sky-Mobi Limited",
    "Renewable Energy Group Inc",
    "Golar Lng Partners LP",
    "Noah Holdings Ltd",
    "Boardwalk Pipeline Partners L.P.",
    "Nevro Corp",
    "Ligand Pharmaceuticals Inc",
    "Biogen Idec Inc",
    "Oneok Partners L.P.",
    "Idreamsky Technology Ltd",
    "Mplx LP",
    "Royal Caribbean Cruises Ltd",
    "Stealthgas",
    "USD Partners LP",
    "Acadia Pharmaceuticals Inc",
    "Neuralstem",
    "Allot Communications Ltd",
    "Safe Bulkers Inc",
    "Can-Fite Biopharma Ltd Sponsore",
    "Insmed Inc",
    "Customers Bancorp",
    "Ngl Energy Partners LP",
    "Tripadvisor Inc",
    "Soufun Holdings",
    "Formfactor",
    "Advanced Energy Industries",
    "Powersecure International Inc",
    "Liberty Tripadvisor Holdings I",
    "Retractable Technologies",
    "Travelcenters of America Llc",
    "Nustar Energy L.P.",
    "Isle of Capri Casinos",
    "Equity Midstream Partners LP",
    "Hi-Crush Partners LP",
    "Gran Tierra Energy Inc",
    "Targa Resources",
    "Straight Path Communications In",
    "Golar Lng Limited",
    "Lrr Energy L.P.",
    "Teekay Tankers Ltd",
    "The Exone Company",
    "Smart",
    "King Digital Entertainment Plc",
    "Synergy Resources Cp",
    "Hydrogenics Corp",
    "Dcp Midstream Partners LP",
    "Buckeye Partners L.P.",
    "Rocket Fuel Inc.",
    "Audiovox Corp",
    "Clayton Williams Energy",
    "Qunar Cayman Islands Limited",
    "Comscore Inc",
    "Delek US Holdings",
    "Sizmek Inc.",
    "Cyberark Software Ltd.",
    "Whiting USA Trust II",
    "Cheniere Energy Partners LP",
    "Himax Technologies",
    "AK Steel Holding Corp",
    "National Bank of Greece Sa",
    "Rada Electronics Industries Limited",
    "Just Energy Group Inc",
    "World Wrestling Entertainment",
    "Ballard Power Systems",
    "Niska Gas Storage Partners Llc",
    "Richmont Mines",
    "Alliance Fiber Optic Products",
    "Tekmira Pharmaceuticals Corp",
    "JA Solar Holdings Co.",
    "Polypore International Inc",
    "Nuvasive Inc",
    "Mellanox Technologies",
    "Svb Financial Group",
    "Bluebird Bio Inc",
    "Canadian Solar Inc",
    "Marathon Petroleum Corp",
    "Methode Electronics",
    "NPS Pharmaceuticals",
    "Viewpoint Financial Group",
    "Abengoa Yield Plc",
    "Orexigen Therapeutics",
    "Yingli Green Energy Holding Company",
    "Transocean Partners Llc",
    "Sanmina-Sci Corp",
    "Pacific Biosciences of California",
    "PBF Energy Inc",
    "Antares Pharma",
    "Crestwood Midstream Partners LP",
    "Graftech International Ltd",
    "Emerge Energy Services LP Commo",
    "Atlas Resource Partners L.P. C",
    "Entravision Communications Corp",
    "Pembina Pipeline Cor",
    "Sanderson Farms",
    "Hong Kong Highpower Technology",
    "Orasure Technologies",
    "Acxiom Corp",
    "Wesco Aircraft Holdings Inc",
    "Southcross Energy Partners L.",
    "Cytokinetics Inc",
    "Penn National Gaming",
    "Novavax Inc",
    "Synergy Pharmaceuticals Inc",
    "Flexion Therapeutics Inc",
    "Amerigas Partners L.P.",
    "E-House [China] Holdings",
    "Aegerion Pharmaceuticals",
    "Futurefuel Corp",
    "Maxwell Technologies",
    "Rubicon Technology",
    "Voc Energy Trust",
    "Ocean Rig Udw Inc",
    "Lee Enterprises Inc",
    "Nustar Gp Holdings Llc",
    "Anacor Pharmaceuticals",
    "Tidewater Inc",
    "Jakks Pacific",
    "Ophthotech Corp",
    "Quantum Fuel Systems Technologies",
    "Xcerra Corp.",
    "Delek Logistics Partners LP",
    "Saia Inc",
    "Celldex Therapeutics Inc",
    "Weatherford International Ltd",
    "Willbros Group",
    "Jinkosolar Holding Company Limited",
    "Audience Inc",
    "Energy Recovery",
    "Itt Educational Services",
    "Theravance Biopharma Inc.",
    "Carbo Ceramics",
    "Harvest Natural Resources Inc",
    "Solazyme Inc",
    "Mid-Con Energy Partners LP"
]

================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/symbols.js
================================================
var stockSymbols = [
    "CBST",
    "SAEX",
    "XLRN",
    "CALA",
    "MTEX",
    "CEMP",
    "TTPH",
    "KE",
    "MDGN",
    "PRTK",
    "AKBA",
    "LPX",
    "VTSS",
    "ISIS",
    "VCYT",
    "VIMC",
    "HQY",
    "BLUE",
    "AGEN",
    "GERN",
    "ALNY",
    "AMCN",
    "XOMA",
    "GV",
    "DMD",
    "PTCT",
    "IDRA",
    "FBP",
    "GLUU",
    "HABT",
    "CSLT",
    "DPLO",
    "JRJC",
    "INCR",
    "CISG",
    "MZOR",
    "VTAE",
    "SAND",
    "TXTR",
    "FGEN",
    "HRTG",
    "HCI",
    "EYES",
    "FPRX",
    "ALDR",
    "KMDA",
    "CGEN",
    "SBGL",
    "ADXS",
    "NUS",
    "UTHR",
    "NLS",
    "LIOX",
    "CDZI",
    "SIGM",
    "UIHC",
    "IMMU",
    "CLDN",
    "BIG",
    "PCTY",
    "CELG",
    "EXAS",
    "RLYP",
    "FOR",
    "FNHC",
    "ACAD",
    "DGII",
    "IAG",
    "INSY",
    "MDCA",
    "GOLD",
    "ZNH",
    "AEO",
    "CORT",
    "GCO",
    "TPUB",
    "TREC",
    "FSGI",
    "UVE",
    "AGIO",
    "INCY",
    "MCY",
    "AUY",
    "MMSI",
    "ONE",
    "MDCO",
    "ATHN",
    "AUQ",
    "EGO",
    "FRPT",
    "BMRN",
    "BBY",
    "STML",
    "FRAN",
    "RYAM",
    "BDR",
    "EW",
    "LPTN",
    "BIND",
    "PRQR"
];

================================================
FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/manifest.json
================================================
{
  "name": "Sketch Data Studio Free",
  "description": "Plugin to import data from CSV to generate tables and charts. Also generate random data for charts.",
  "author": "Tyler Wolf",
  "homepage": "http://thetylerwolf.github.io/sketch-data-studio",
  "version": 1.0,
  "identifier": "com.tylerwolf.sketch.sketch-data-studio",
  "compatibleVersion": 3,
  "bundleVersion": 1,
  "commands": [
    {
      "name": "Import CSV to Table",
      "identifier": "csvToTable",
      "script": "csvUpload/importCSVToTable.js"
    },
    {
      "name": "Bar Chart",
      "identifier": "barChart",
      "script": "genCharts/barChart.js"
    },
    {
      "name": "Line Chart",
      "identifier": "lineChart",
      "script": "genCharts/lineChart.js"
    },
    {
      "name": "Random 0 - 1",
      "identifier": "rand01",
      "script": "genTables/rand01.js"
    },
    {
      "name": "Random 0 - 100",
      "identifier": "rand0100",
      "script": "genTables/rand0100.js"
    },
    {
      "name": "Random Bond",
      "identifier": "randBond",
      "script": "genTables/randBond.js"
    },
    {
      "name": "Random Stock Symbols",
      "identifier": "randStockSymbol",
      "script": "genTables/randSymbol.js"
    },{
      "name": "Random Stocks",
      "identifier": "randStock",
      "script": "genTables/randStock.js"
    },{
      "name": "Set Your Own Random Values",
      "identifier": "randArb",
      "script": "genTables/randArb.js"
    }
  ],
  "menu": {
    "title": "Sketch Data Studio Free",
    "items": [
      {
        "title": "CSV Upload",
        "items": [
          "csvToTable"
        ]
      },
      {
        "title": "Generate Chart",
        "items": [
          "barChart",
          "lineChart"
        ]
      },
      {
        "title": "Generate Table",
        "items": [
          "rand01",
          "rand0100",
          "randBond",
          "randStockSymbol",
          "randStock",
          "randArb"
        ]
      }
    ]
  }
}
Download .txt
gitextract_dhow8vzv/

├── .gitignore
├── LICENSE
├── README.md
└── sketch-data-studio-free.sketchplugin/
    └── Contents/
        └── Sketch/
            ├── controllers/
            │   ├── genChart.js
            │   └── genTable.js
            ├── csvUpload/
            │   └── importCSVToTable.js
            ├── functions/
            │   └── inputs.js
            ├── genCharts/
            │   ├── barChart.js
            │   └── lineChart.js
            ├── genTables/
            │   ├── rand01.js
            │   ├── rand0100.js
            │   ├── randArb.js
            │   ├── randBond.js
            │   ├── randStock.js
            │   └── randSymbol.js
            ├── globals/
            │   ├── chartColors.js
            │   ├── chartTypes.js
            │   ├── dataTypes.js
            │   ├── names.js
            │   └── symbols.js
            └── manifest.json
Download .txt
SYMBOL INDEX (10 symbols across 3 files)

FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/controllers/genChart.js
  function sizeGroup (line 52) | function sizeGroup(seriesGroup, seriesArray, i) {
  function genSeries (line 69) | function genSeries(numSeries, index, dt) {
  function generateChart (line 81) | function generateChart(sArray,i, group) {
  function isText (line 85) | function isText(layer) {

FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/controllers/genTable.js
  function genRows (line 66) | function genRows(numCols, layer, index, dt) {
  function placeLayer (line 81) | function placeLayer(layer, index) {
  function isText (line 86) | function isText(layer) {
  function importFromCSV (line 90) | function importFromCSV() {
  function refreshTextLayer (line 108) | function refreshTextLayer(layer) {

FILE: sketch-data-studio-free.sketchplugin/Contents/Sketch/functions/inputs.js
  function askForInput (line 1) | function askForInput(title, type, dt) {
Condensed preview — 21 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (42K chars).
[
  {
    "path": ".gitignore",
    "chars": 9,
    "preview": ".DS_Store"
  },
  {
    "path": "LICENSE",
    "chars": 11325,
    "preview": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licens"
  },
  {
    "path": "README.md",
    "chars": 2327,
    "preview": "Sketch Data Studio\n==================\n\nA Sketch plugin to upload or generate numerical and qualitative data for charts a"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/controllers/genChart.js",
    "chars": 2149,
    "preview": "@import '../functions/inputs.js'\n@import '../globals/chartTypes.js'\n\nvar input, values,\n    firstChoices, group, points,"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/controllers/genTable.js",
    "chars": 2808,
    "preview": "@import '../functions/inputs.js';\n@import '../globals/names.js';\n@import '../globals/symbols.js';\n@import '../globals/da"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/csvUpload/importCSVToTable.js",
    "chars": 123,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'fromCSV';\n\n\t@import '../controllers/genTable.js'"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/functions/inputs.js",
    "chars": 2003,
    "preview": "function askForInput(title, type, dt) {\n  var alert = [COSAlertWindow new];\n        [alert setMessageText: title];\n\n  va"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genCharts/barChart.js",
    "chars": 127,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'barSeries';\n\n\t@import '../controllers/genChart.j"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genCharts/lineChart.js",
    "chars": 128,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = \"lineSeries\";\n\n\t@import '../controllers/genChart."
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/rand01.js",
    "chars": 126,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'zeroToOne';\n\n\t@import '../controllers/genTable.j"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/rand0100.js",
    "chars": 130,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'zeroToHundred';\n\n\t@import '../controllers/genTab"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randArb.js",
    "chars": 127,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'arbitrary';\n\n\t@import '../controllers/genTable.j"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randBond.js",
    "chars": 122,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'bond';\n\n\t@import '../controllers/genTable.js';\n}"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randStock.js",
    "chars": 123,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'stock';\n\n\t@import '../controllers/genTable.js';\n"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/genTables/randSymbol.js",
    "chars": 123,
    "preview": "var onRun = function(context) {\n\tvar doc = context.document;\n\tvar dt = 'symbol';\n\n\t@import '../controllers/genTable.js'\n"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/chartColors.js",
    "chars": 171,
    "preview": "var chartColors = [\n    '#1f77b4',\n    '#ff7f0e',\n    '#2ca02c',\n    '#d62728',\n    '#9467bd',\n    '#8c564b',\n    '#e377"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/chartTypes.js",
    "chars": 3429,
    "preview": "@import '../globals/chartColors.js'\n\nvar chartTypes = {\n    lineSeries : {\n        name: 'Line Chart (Geometric Time Ser"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/dataTypes.js",
    "chars": 3321,
    "preview": "var dataTypes = {\n    zeroToOne : {\n        name: 'Random 0 - 1',\n        val: function() {\n            var rand = Math."
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/names.js",
    "chars": 5742,
    "preview": "var stockNames = [\n    \"Mol Global Inc.\",\n    \"Digital Ally\",\n    \"Image Sensing Systems\",\n    \"Spansion Inc\",\n    \"Vigg"
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/globals/symbols.js",
    "chars": 1195,
    "preview": "var stockSymbols = [\n    \"CBST\",\n    \"SAEX\",\n    \"XLRN\",\n    \"CALA\",\n    \"MTEX\",\n    \"CEMP\",\n    \"TTPH\",\n    \"KE\",\n    \""
  },
  {
    "path": "sketch-data-studio-free.sketchplugin/Contents/Sketch/manifest.json",
    "chars": 1984,
    "preview": "{\n  \"name\": \"Sketch Data Studio Free\",\n  \"description\": \"Plugin to import data from CSV to generate tables and charts. A"
  }
]

About this extraction

This page contains the full source code of the thetylerwolf/sketch-data-studio GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 21 files (36.7 KB), approximately 9.8k tokens, and a symbol index with 10 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!