Skip to content
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

Refac thumbnail fv 73 #93

Merged
merged 7 commits into from
Aug 1, 2017
Merged

Conversation

ede0m
Copy link

@ede0m ede0m commented Jul 31, 2017

Mostly involved adding reading in default_display_ids from examples into thumbnail.js

Can run and test the node script with the same command used in this pull request

Copy link
Contributor

@skaymen skaymen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored code looks good besides the single comment I made.

PNG generation works correctly, although the old instructions for running it need to be updated.

@@ -82,7 +83,7 @@ function convert(figure, window, css_path, filename) {
svg_string = inject_style(style_default, null, svg, window);
}
// Takes care of canvas conversion and encodes base64
svg2png(svg_string)
svg2png(svg_string, {height: 300, width: 560})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numbers for height and width are used twice in this file-- maybe we could make them vars?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was refactoring done to height and width within the figure module while I was working on implementing the thumbnail script. When jumping on this current ticket, height and width had been removed from hydrograph.js during svg initialization (lines 116-122). This required me to specify height in width in svg2png because it could not be interpreted from the svg itself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did however, take your suggestion and declare vars at the top for height and width instead of using the actual integers.

Copy link
Collaborator

@mbucknell mbucknell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things and some suggestions for a little reorganization of thumbnail.js

'div_id': '#hydrograph'
};

var map_figure = FV.mapmodule(map_options);
var hydro_figure = FV.hydromodule(hydro_options);
var hydro_figure = hydromodule(hydro_options);

// Use frames to link interactions
var map_to_hydro = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually for https://github.com/ede0m/active-flood-viz/blob/33e572dbf2ce36d182ebeab1ea5311b601928a64/floodviz/static/js/floodviz_onready.js#L45. I would like to see the data passed directly into the init function. It's more explicit to pass it directly in and is not used before init() is called anyways.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this refactor. But I think it fits in better with a new ticket that would encapsulate the FV.default_display_id changes that still need to be made in map, for the sake of consistency across these figure modules. I would happily pick this new ticket up and make those changes tomorrow.

* Non-optional Keys include:
* @prop 'height' v(int) - height of the graph
* @prop 'width' v(int) - width of the graph
* @prop 'data' v(list) - A list of objects representing data points
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one that I would like to see removed and instead passed in through the init() function. Please add a comment for the new display_ids property.

@@ -15,6 +15,7 @@ var jsdom = require('jsdom/lib/old-api.js');
var svg2png = require('svg2png');
// Data imports
var data_hydro = require('../thumbnail/hydrograph_data.json');
var reference = require('../../examples/reference.json');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This location needs instance/reference.json as that is where we are putting it in the dockerfile process.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha!

if (args[0] === '-css') {
style_path = args[1];
} else {
console.log('\nUnrecognized argument: ' + args[0] + '\n');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's show the usage here too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure

@@ -44,19 +51,17 @@ jsdom.env(
[
'./floodviz/static/bower_components/d3/d3.js',
'./floodviz/static/bower_components/proj4/dist/proj4.js',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need proj4 for the hydrograph, so this can be removed. Also remove the map div since we are only doing the hydrograph (that's above this on line 47).

@@ -82,7 +87,7 @@ function convert(figure, window, css_path, filename) {
svg_string = inject_style(style_default, null, svg, window);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is for line 78 where the additional css file is read in. Can this be done after line 30.? This gets the reading of the file done where the config parameter is read. You should be able to assign the value to style_ext and then you only need a single line to inject_style(style_default, style_ext, svg, window).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Idea! Thanks

Copy link
Collaborator

@mbucknell mbucknell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to add the one comment.

* Pass null if there are no such interactions to link.
* @prop 'hover_in' - linked interaction function for hover_in events on this figure.
* @prop 'hover_out' - linked interaction function for hover_out events on this figure.
* @prop 'click' - linked interaction function for click events on this figure.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment for @param data

@mbucknell mbucknell merged commit 7a70155 into USGS-VIZLAB:master Aug 1, 2017
@ede0m ede0m deleted the refac_thumbnail_fv_73 branch August 1, 2017 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants