evidence-dev / evidence

Business intelligence as code: build fast, interactive data visualizations in pure SQL and markdown
https://evidence.dev
MIT License
3.44k stars 167 forks source link

LinkedChart Fix + Fix dependencies #698

Closed Winterhart closed 1 year ago

Winterhart commented 1 year ago

Description

In the template project the LinkedChart of svelte-tiny-linked-charts was undefined.

Demo on Template

CleanShot 2023-03-15 at 14 37 39

e.g.


TypeError: Cannot read properties of undefined (reading 'LinkedChart')
    at eval (/src/components/viz/BigValue.svelte:122:114)
    at Object.$$render (/@fs/Users/charles/DEV/github.com/evidence-dev/template/node_modules/svelte/internal/index.mjs:1876:22)
    at eval (/src/pages/+page.md:163:87)
    at Object.$$render (/@fs/Users/charles/DEV/github.com/evidence-dev/template/node_modules/svelte/internal/index.mjs:1876:22)
    at Object.default (root.svelte:48:41)
    at eval (/src/pages/+layout.svelte:155:56)
    at Object.$$render (/@fs/Users/charles/DEV/github.com/evidence-dev/template/node_modules/svelte/internal/index.mjs:1876:22)
    at root.svelte:42:39
    at $$render (/@fs/Users/charles/DEV/github.com/evidence-dev/template/node_modules/svelte/internal/index.mjs:1876:22)
    at Object.render (/@fs/Users/charles/DEV/github.com/evidence-dev/template/node_modules/svelte/internal/index.mjs:1884:26)

How I am testing on template

In the template > index.md replace the query orders_by_month by


select *,
  sales_usd0k / lag(sales_usd0k, -1) over (order by order_month desc) - 1 as sales_growth_pct1
  from (
select
  date_trunc('month', order_datetime) as order_month,
  count(*) as number_of_orders,
  sum(sales) as sales_usd0k,
  sum(sales)/count(*) as average_order_value_usd2
from orders

group by 1 order by 1 desc
  )

and replace the first BigValue by


<BigValue 
  data={orders_by_month} 
  value=sales_usd0k
  comparison=sales_growth_pct1
  sparkline="order_month"
/>

Checklist

changeset-bot[bot] commented 1 year ago

πŸ¦‹ Changeset detected

Latest commit: 6a0290c5d4f86af814309b2e31b74b98645f179f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages | Name | Type | | ----------------------------- | ----- | | @evidence-dev/evidence | Major | | @evidence-dev/preprocess | Minor | | @evidence-dev/snowflake | Minor | | @evidence-dev/components | Minor | | evidence-test-environment | Patch | | @evidence-dev/db-orchestrator | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated
evidence-development-workspace βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Mar 17, 2023 at 6:13PM (UTC)
evidence-docs βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Mar 17, 2023 at 6:13PM (UTC)
hughess commented 1 year ago

I've tested in the monorepo and it works well!

Just tested in the template as well - it works, but there's a flash of an inline error on page refresh: CleanShot 2023-03-17 at 09 49 14

hughess commented 1 year ago

I'm also getting these errors in the browser console on page load - assume they're unrelated to this issue, but wanted to flag as I saw them:

CleanShot 2023-03-17 at 09 53 05@2x
hughess commented 1 year ago

Ok I looked into these errors I just posted and they're actually coming from a Chrome plugin - I turned all my plugins off and back on one-by-one to find the culprit and it turned out to be the Loom Chrome plugin. When I turn Loom off, these errors don't appear, so I think we are good on those!

hughess commented 1 year ago

Also not seeing the scrollbar anymore on show/hide queries!

hughess commented 1 year ago

I'm also getting fully reactive queries in the template now!

archiewood commented 1 year ago

@Winterhart I'm trying to update our stackblitz demo to 15.0.1

https://stackblitz.com/edit/sveltejs-kit-template-default-yppqnv?file=package.json,pages%2Findex.md&terminal=dev

vite is throwing an error:

[vite] Error when evaluating SSR module /src/components/viz/BigValue.svelte: failed to import "svelte-tiny-linked-charts"

Any idea how I might work around?

Other thought

I'm wondering if this svelte-tiny-linked-charts library is worth the pain given how little we see the sparkline used. Perhaps we should just deprecate the feature.

Winterhart commented 1 year ago

You can try adding the svelte-tiny-linked-charts to package.json of the template. We can also add it as peerDependencies on the evidence package.

archiewood commented 1 year ago

I've added it in the above stackblitz example, but it didnt seem to help. peerDeps might help, we'll see.

Winterhart commented 1 year ago

It is already there: https://github.com/evidence-dev/evidence/blob/main/packages/evidence/package.json#L57 πŸ˜