Conversation
Deploying vega with
|
| Latest commit: |
aabd3ac
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://79a76ad7.vega-628.pages.dev |
| Branch Preview URL: | https://sort-functions.vega-628.pages.dev |
|
Thanks. I added a more generic comparator so we don't need two methods and added docs as well. |
|
That's great, thank you! Having just one method is much preferred. |
|
Hey @joelostblom, thanks for putting this together! Using the branch preview ( https://sort-functions.vega-628.pages.dev/#/ ), could you link to a sample Vega or Vega-Lite definition that would make use of this new expression? We probably want at least 1 case each for each happy path (numbers, strings, maybe one with missing data). I'm not sure we need to have an especially "nice" behavior for the mixed datatype case other than to not crash.
I looked to see how tests in this package |
|
Sorry for the delay in getting back to you @hydrosquall . I was trying out the branch preview editor right now, and it seems like it doesn't recognize the |
|
I tried this spec btw. It definitely worked for me before but I also get |
|
@joelostblom - I’m puzzled about how the other expressions for sequences
are working given that they’re only listed in one place. This is my first
time seeing a function added to the core lib rather than adding via the
extensions API.
From grepping the code for “unrecognized”, I think we might have to add
this new sort function to Vega-expression too. This package is used when
Vega is used in strict mode to be compliant with CSP.
https://github.com/vega/vega/blob/main/packages/vega-expression/src/functions.js
…On Wed, Sep 18, 2024 at 3:57 PM Dominik Moritz ***@***.***> wrote:
I tried this spec btw. It definitely worked for me before but I also get Unrecognized
function: sort right now.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"signals": [
{
"name": "foo",
"update": "sort([1,2,3])"
}
]
}
—
Reply to this email directly, view it on GitHub
<#3962 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACE2MM7DR22NQ7T7FGALPC3ZXHLJRAVCNFSM6AAAAABND67FNKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJZGI4TGOBSGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hmm, doesn't that sound odd given that other array functions such as Give that @domoritz mentioned the spec worked for him before, maybe there is something going on with the deploy preview? |
|
I couldn't get it to work locally either yesterday. Need to dig a bit more what I did before |
|
From what I can see, the editor doesn’t use the strict interpreter, it uses
the faster default “Function” constructor
https://vega.github.io/vega/usage/interpreter/
https://github.com/vega/editor/blob/master/src/components/renderer/renderer.tsx#L168-L171
…On Thu, Sep 19, 2024 at 5:04 PM Dominik Moritz ***@***.***> wrote:
I couldn't get it to work locally either yesterday. Need to dig a bit more
what I did before
—
Reply to this email directly, view it on GitHub
<#3962 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACE2MM5WGRWQBTJTMWS3SWLZXM36VAVCNFSM6AAAAABND67FNKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRSGE4TINBZGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Yes, but reverse works so I'm confused. Need to dig into it more. |
|
Reverse is also defined and exported from the Vega-functions package -
maybe we have to add it to the shared function context object.
https://github.com/vega/vega/blob/main/packages/vega-functions/src/codegen.js#L236
(What I’m taking away from this PR is we may want to have a guide to adding
new functions for contributors, if doing so involves changing files in
multiple packages)
…On Thu, Sep 19, 2024 at 10:46 PM Dominik Moritz ***@***.***> wrote:
Yes, but reverse works so I'm confused. Need to dig into it more.
—
Reply to this email directly, view it on GitHub
<#3962 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACE2MMYIBLYFCLVJWU2HSPLZXOEAJAVCNFSM6AAAAABND67FNKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRSGYZTSNJUGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
I can't speak to why the relevant code is missing from that localhost screenshot (that does seem odd), but adding the method to From revisiting the package descriptions, it looks like Since the editor doesn't run in CSP mode, it didn't call
(Apologies @joelostblom , as I steered you incorrectly when I suggested I'm not sure about how extensively we need to test here (I still think having a realistic Vega spec that shows the application of this sort function is desirable), but I'll add something more isolated in the downstream PR for consideration in |
|
Moved to #3973 |
…3973) ## Motivation This PR tests a [fix](#3962 (comment)) for #3962 , with the goal of adding a `sort` function to the default set of Vega functions in the expression language. ## Changes - Includes @domoritz and @joelostblom's doc and `vega-interpreter` commits from #3962, rebased against latest `main` - Added + tests sort in `vega-functions`: 5e6190d#diff-328f6311e6ab7be84b1167d9ca245bea77f0ae6e078ffcd4b71bb7b2340e810b ## Testing - This worked locally when using `yarn link vega` - This is also working in the [Cloudflare preview](https://cameron-yick-sort-functions.vega-628.pages.dev/#/url/vega/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykSArJQBWENgDsQAGhBMkUANZkATmwbiAJmhAB3GHTjSQOJBo01xZNAJk6aG+mgBMABhkRMATwA2h9FDhvbyMNJEwUVABtUHEkBD8QMQZlAIB9FyNiJG8GOAg0aJAIkABBIyZnAA4AXwBdaqkYuITQ8PSjJJSEzrSMmUxlJHEIADM2ZQQC0C8cBLGJhm8UGTgADxxlbTFlTAAKSIByEYOpAAIDpBPzzCuDpgPagEojJHz0TDzMEDq69xoyWLeN6FWLxbSeVIeOA4TLZXLOFwNJpg9Dwf5YIwMHCtBJyTQQEwBXYaNjICy7A6eA6PSi+Sz0M4ARjOLkoAkepwAVKcIVCYb8QMhlApgciEkKRUYZgkPqsvu4vL4CiBZV9ajIRqpJqhQK1inr2g0QHBxFA2Bo-KAsTi0KARjQgraQFkcrilopvjILdBlDQcJh2JIdYl-oDtAAdFWfVCnSOnADUp12NAgADVsvZiWEGAhIpGPh5I09TgB+U6tHN5qOFkC1U4xyOR+MV3P5z5F55G1ZOiCh7LaOwOGBGBCLL6oVkCI2eHtQbIJGcamiBLTvT6eoreUNOl3w-wmj6bI1yCCBCyW51w8X2DRK6r3gXQeeikCghdSzyzbQ4NgWeUgEkySDXUwn1UD2iXFdtALf9tnHAZciNQZLAvPkez7YJ0F5D5+SNEwzAsKwJzZAUkFWPIpkSOclSwoxxmXcRxxAXwRn-FR7DQEZslPfo6Bo6t-wALwsC1uwnH4gA) Uses test spec JSON: ``` { "$schema": "https://vega.github.io/schema/vega/v5.json", "background": "white", "padding": 5, "width": 20, "style": "cell", "data": [ {"name": "source_0", "values": [{"a": "A", "b": 28}]}, { "name": "data_0", "source": "source_0", "transform": [ {"type": "formula", "expr": "sort(['f', 'a', 't', 'b'])", "as": "test"} ] } ], "signals": [ {"name": "y_step", "value": 20}, { "name": "height", "update": "bandspace(domain('y').length, 1, 0.5) * y_step" } ], "marks": [ ], "scales": [ { "name": "y", "type": "point", "domain": {"data": "data_0", "field": "test", "sort": true}, "range": {"step": {"signal": "y_step"}}, "padding": 0.5 } ], "axes": [ { "scale": "y", "orient": "left", "grid": false, "title": "test", "zindex": 0 } ] } ``` --------- Co-authored-by: Joel Ostblom <joelostblom@users.noreply.github.com> Co-authored-by: Dominik Moritz <domoritz@gmail.com>


I think it would be useful to have sort function in the expression language. My immediate use case is for vega/altair#3394 (review), where we need to sort an array returned by
domain().I'm not at all sure what the best implementation is here, or what tests are needed, so this PR is partly to move the discussion I started with @hydrosquall on slack and get additional input. I think that ideally there would just be one
sortfunction that handles both numbers, strings, and mixed types, but that seems considerably more complex and I'm not comfortable writing it so I'm suggesting these simple ones which @hydrosquall showed me on slack and that directly maps to the built in JS array methods.