- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.9k
[WIP] Transforms [rebase of timelyportfolio's work] #936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9bb2b10
              582d210
              d0ef359
              9574f4f
              77e2b27
              aa1f1d3
              6015768
              6daeac5
              3e0f209
              d735b64
              a820b0c
              2dd3646
              c30f94e
              e9bde33
              c6355e8
              5765f66
              02742e8
              b23d2ff
              55f9e0c
              462b2f0
              9cafe1e
              87de31f
              61f3385
              57d0c13
              7085729
              392844d
              1dd93bb
              1ea2fd7
              59b741d
              a5dad2a
              79dcbc3
              aa70e4c
              523f61b
              4efe6a9
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * Copyright 2012-2016, Plotly, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|  | ||
|  | ||
| 'use strict'; | ||
|  | ||
| // returns true for a valid value object and false for tree nodes in the attribute hierarchy | ||
| module.exports = function(obj) { | ||
| return obj && obj.valType !== undefined; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /** | ||
| * Copyright 2012-2016, Plotly, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|  | ||
|  | ||
| 'use strict'; | ||
|  | ||
| var Lib = require('../lib'); | ||
|  | ||
| var crawler = module.exports = {}; | ||
|  | ||
| crawler.IS_SUBPLOT_OBJ = '_isSubplotObj'; | ||
| crawler.IS_LINKED_TO_ARRAY = '_isLinkedToArray'; | ||
| crawler.DEPRECATED = '_deprecated'; | ||
|  | ||
| // list of underscore attributes to keep in schema as is | ||
| crawler.UNDERSCORE_ATTRS = [crawler.IS_SUBPLOT_OBJ, crawler.IS_LINKED_TO_ARRAY, crawler.DEPRECATED]; | ||
|  | ||
| crawler.crawl = function(attrs, callback, specifiedLevel) { | ||
|          | ||
| var level = specifiedLevel || 0; | ||
| Object.keys(attrs).forEach(function(attrName) { | ||
| var attr = attrs[attrName]; | ||
|  | ||
| if(crawler.UNDERSCORE_ATTRS.indexOf(attrName) !== -1) return; | ||
|  | ||
| callback(attr, attrName, attrs, level); | ||
|  | ||
| if(Lib.isValObject(attr)) return; | ||
| if(Lib.isPlainObject(attr)) crawler.crawl(attr, callback, level + 1); | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -9,7 +9,7 @@ | |
|  | ||
| 'use strict'; | ||
|  | ||
| var PlotSchema = require('./../plot_api/plot_schema') | ||
| var crawler = require('./../plot_api/crawler'); | ||
| var d3 = require('d3'); | ||
| var isNumeric = require('fast-isnumeric'); | ||
|  | ||
|  | @@ -797,13 +797,13 @@ function applyTransforms(fullTrace, fullData, layout) { | |
|  | ||
| stack = stack.slice(0, level).concat([attrName]); | ||
|  | ||
| var splittableAttr = attr.valType === 'data_array' || attr.arrayOk === true | ||
| var splittableAttr = attr.valType === 'data_array' || attr.arrayOk === true; | ||
| if(splittableAttr) { | ||
| arraySplitAttributes.push(stack.slice()); | ||
| } | ||
| } | ||
|  | ||
| PlotSchema.crawl(trace._module.attributes, callback); | ||
| crawler.crawl(trace._module.attributes, callback); | ||
|          | ||
|  | ||
| return arraySplitAttributes; | ||
| }); | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, looking over circular dependencies.
I think this function would make more sense in the
src/lib/coerce.jsmodule. Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
coerce.jslooks like the best home for it.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etpinard Where do you specifically want to see it in
coerce.js? Totally separate export (exports.isValObject), or as an element insideexports.valObject, e.g.object: {...}in which case the actual function is incoerceFunction, or something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
exports.isValObjectincoerce.jsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it to
coerce.jsand similarly to how othercoerceconstituents are handled, I directly reexport asLib.isValObject. If it's desirable, I can phase outPlotSchema.isValObjectin favor ofLib.isValObject, what do you think?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet as
Plotly.PlotSchema.isValObjectis currently exposed publicly.