automeris-io / WebPlotDigitizer

Computer vision assisted tool to extract numerical data from plot images.
https://automeris.io
GNU Affero General Public License v3.0
2.63k stars 362 forks source link

Override data point values functionality #211

Closed ewchow closed 4 years ago

ewchow commented 4 years ago

Hey Ankit,

Been a while! Hope all is well.

Got a fairly hefty update for you here, but I think you'll like the new functionality. This is related to #142. I extended the Adjust Point (S) functionality in a few ways, the main addition is the ability to override point values. I opted to store the override values in each point's metadata field, and since bar charts uses that field for labels, override values currently does not support bar charts.

I wanted to get your input on the metadata field before I make any changes there. What do you think about converting metadata into an object instead of an array? (With backwards compatibility of course.)

But, without further ado, the outline of the changes are follows:

As always, happy to make any changes you'd like me to. Let me know what you think.

ankitrohatgi commented 4 years ago

Thanks! I'll try to finish the review this weekend :)

ankitrohatgi commented 4 years ago

I wanted to get your input on the metadata field before I make any changes there. What do you think about converting metadata into an object instead of an array? (With backwards compatibility of course.)

I am not opposed to the change. I think I put in metadata as a hack to make bar charts work, but if we need to change it to accommodate new things, then we should change it.

ankitrohatgi commented 4 years ago

So I checked out your branch to try this out myself. Based on the description and UI behavior, I was assuming overriding value would effectively shift the point at that location (more precise shift than what you get with a keyboard/mouse). But looks like that's not the intention here - I'm wondering why you wanted to store the overridden values in metadata vs just shifting the point itself?

image
ewchow commented 4 years ago

I am not opposed to the change. I think I put in metadata as a hack to make bar charts work, but if we need to change it to accommodate new things, then we should change it.

Great! I will make the change. This will allow for bar chart support as well.

So I checked out your branch to try this out myself. Based on the description and UI behavior, I was assuming overriding value would effectively shift the point at that location (more precise shift than what you get with a keyboard/mouse). But looks like that's not the intention here - I'm wondering why you wanted to store the overridden values in metadata vs just shifting the point itself?

So I originally leaned in the direction of shifting the point, but when I took a closer look at #142, I realized the axes values could be discontinuous or be something other than numbers. In those cases, I thought directly (or indirectly via dataToPixel) modifying the coordinates could lead to misleading placement of points or a loss of information. So I ultimately went in the direction of storing the information as metadata for flexibility and axes integrity.

ewchow commented 4 years ago

Few new changes based on our conversation:

billdenney commented 4 years ago

Hey, thanks for this PR!

For the idea of shifting the point or not, I'd prefer not to shift it. The rationale is that there are times when I will know what a point value is (like in #74) but if the value were shifted, it would not be in the visually-correct location on the graph.

ankitrohatgi commented 4 years ago

@billdenney, @ewchow - based on your use case, it looks like the override values are more like "labels". Do you think just renaming it to something other than "overrides" is possible?

I'm ok with the general approach - just the name "override" threw me off a bit since I was expecting that to change the point locations.

ankitrohatgi commented 4 years ago

Also, I'll try to do a more detailed code review later tonight. Apologies that reviews have been kind of slow :(

billdenney commented 4 years ago

@ankitrohatgi, I don't have a name preference. If you would prefer something else, perhaps "replace" would fit the action better? Does that work for you?

ankitrohatgi commented 4 years ago

This looks good mostly - the we can change the name for "override" later, it was just a nitpicky comment.

I did give this a shot manually and things work fine - I'll go ahead and merge this.

ewchow commented 4 years ago

Happy to change the name to whatever you prefer later. Thanks for looking through the code changes!

ankitrohatgi commented 4 years ago

I'm seeing that this has broken a lot of things for bar charts :(

For example, I can not change label and see that label in the "view data" window anymore. I also found a number of save/resume bugs that had to be fixed. If I can't fix these bugs soon, then I'm going to have to revert this PR.

ankitrohatgi commented 4 years ago

I think I have a fix for some of the bugs now. Just checked those into master.

ewchow commented 4 years ago

Must have missed some cases with the later commits, sorry about that. I'll run through all the workflows again. Are there any known issues I can look into?

ewchow commented 4 years ago

Ah, I missed the auto extraction functionality. Thanks for fixing them. I haven't seen anything else so far, but please let me know if you find anything else. I'll include qunit tests with the next updates.

ankitrohatgi commented 4 years ago

Yeah, the code coverage of the tests is quite sparse unfortunately :( I never had the bandwidth to write tests. I'm in the process of testing and hardening various things we added in the last few months and officially switch to 4.3 on the website in the next few days.