Select proper database for Plot Widget
Friday, 6 January 2023 · 10 messages · last reply 11 Jan 2023
BP
Ben Pracht6 Jan 2023 08:13 #
I like having a convenient inline plotting for data, but I can't figure out how to select the right database to query from for the BaseX GUI plot widget. I can only select X and Y values from what I think is the country database.
Best Regards,
Ben Pracht
919.809.2439
ben.pracht at gmail.com
CG
Christian Grün7 Jan 2023 14:48 #
Hi Ben,
Do you have some specific data that you would like to see reasonably visualized by the Plot View, or are you rather looking for arbitrary data that could be rendered by this visualization?
Best,
Christian
Quoted text · Ben Pracht · 8 lines
On Fri, Jan 6, 2023 at 7:13 AM Ben Pracht <ben.pracht at gmail.com> wrote: > > I like having a convenient inline plotting for data, but I can't figure out how to select the right database to query from for the BaseX GUI plot widget. I can only select X and Y values from what I think is the country database. > > Best Regards, > Ben Pracht > 919.809.2439 > ben.pracht at gmail.com
BP
Ben Pracht8 Jan 2023 05:26 #
Christian,
I like the chart type. I've got a separate database with gold prices over time. I want to put the price of 1oz on the Y axis and a timestamp on the X axis.
I'd like to specify maybe the database and an xquery expression for the X and Y series.
Thanks for your help,
Ben
Quoted text · Christian Grün · 18 lines
On 1/7/23 08:48, Christian Grün wrote: > Hi Ben, > > Do you have some specific data that you would like to see reasonably > visualized by the Plot View, or are you rather looking for arbitrary > data that could be rendered by this visualization? > > Best, > Christian > > > On Fri, Jan 6, 2023 at 7:13 AM Ben Pracht <ben.pracht at gmail.com> wrote: >> I like having a convenient inline plotting for data, but I can't figure out how to select the right database to query from for the BaseX GUI plot widget. I can only select X and Y values from what I think is the country database. >> >> Best Regards, >> Ben Pracht >> 919.809.2439 >> ben.pracht at gmail.com
CG
Christian Grün9 Jan 2023 16:17 #
Hi Ben,
My recommended solution (albeit a bit static) is to generate a new XML document that contains attributes or elements with the relevant data, create a database from it, and open the plot for that database.
Hope this helps,
Christian
Quoted text · Ben Pracht · 30 lines
On Sun, Jan 8, 2023 at 12:23 AM Ben Pracht <ben.pracht.news at gmail.com> wrote: > > Christian, > I like the chart type. I've got a separate database with gold prices over time. I want to put the price of 1oz on the Y axis and a timestamp on the X axis. > > I'd like to specify maybe the database and an xquery expression for the X and Y series. > > Thanks for your help, > Ben > > On Sat, Jan 7, 2023, 08:49 Christian Grün <christian.gruen at gmail.com> wrote: >> >> Hi Ben, >> >> Do you have some specific data that you would like to see reasonably >> visualized by the Plot View, or are you rather looking for arbitrary >> data that could be rendered by this visualization? >> >> Best, >> Christian >> >> >> On Fri, Jan 6, 2023 at 7:13 AM Ben Pracht <ben.pracht at gmail.com> wrote: >> > >> > I like having a convenient inline plotting for data, but I can't figure out how to select the right database to query from for the BaseX GUI plot widget. I can only select X and Y values from what I think is the country database. >> > >> > Best Regards, >> > Ben Pracht >> > 919.809.2439 >> > ben.pracht at gmail.com
CG
Feel free to send us (a possibly minimized version of) the document that allows us to reproduce the behavior. Thanks in advance…
Quoted text · Ben Pracht · 50 lines
On Mon, Jan 9, 2023 at 4:28 PM Ben Pracht <ben.pracht at gmail.com> wrote: > > I'm working with a separate database and opened it. Many documents have > attributes already, but the problem is I'm not able to select any of > those attributes in the plot. It only allows me to select the attributes > from some other database. Specifically, the first drop down says 95 > entries and has @longitude, @height and many others. What am I missing > to get the plot to read from the open database? > > Thanks, > Ben > > On 1/9/23 10:17, Christian Grün wrote: > > Hi Ben, > > > > My recommended solution (albeit a bit static) is to generate a new XML > > document that contains attributes or elements with the relevant data, > > create a database from it, and open the plot for that database. > > > > Hope this helps, > > Christian > > > > > > On Sun, Jan 8, 2023 at 12:23 AM Ben Pracht <ben.pracht.news at gmail.com> wrote: > >> Christian, > >> I like the chart type. I've got a separate database with gold prices over time. I want to put the price of 1oz on the Y axis and a timestamp on the X axis. > >> > >> I'd like to specify maybe the database and an xquery expression for the X and Y series. > >> > >> Thanks for your help, > >> Ben > >> > >> On Sat, Jan 7, 2023, 08:49 Christian Grün <christian.gruen at gmail.com> wrote: > >>> Hi Ben, > >>> > >>> Do you have some specific data that you would like to see reasonably > >>> visualized by the Plot View, or are you rather looking for arbitrary > >>> data that could be rendered by this visualization? > >>> > >>> Best, > >>> Christian > >>> > >>> > >>> On Fri, Jan 6, 2023 at 7:13 AM Ben Pracht <ben.pracht at gmail.com> wrote: > >>>> I like having a convenient inline plotting for data, but I can't figure out how to select the right database to query from for the BaseX GUI plot widget. I can only select X and Y values from what I think is the country database. > >>>> > >>>> Best Regards, > >>>> Ben Pracht > >>>> 919.809.2439 > >>>> ben.pracht at gmail.com
BP
I'm working with a separate database and opened it. Many documents have attributes already, but the problem is I'm not able to select any of those attributes in the plot. It only allows me to select the attributes from some other database. Specifically, the first drop down says 95 entries and has @longitude, @height and many others. What am I missing to get the plot to read from the open database?
Thanks,
Ben
Quoted text · Christian Grün · 38 lines
On 1/9/23 10:17, Christian Grün wrote: > Hi Ben, > > My recommended solution (albeit a bit static) is to generate a new XML > document that contains attributes or elements with the relevant data, > create a database from it, and open the plot for that database. > > Hope this helps, > Christian > > > On Sun, Jan 8, 2023 at 12:23 AM Ben Pracht <ben.pracht.news at gmail.com> wrote: >> Christian, >> I like the chart type. I've got a separate database with gold prices over time. I want to put the price of 1oz on the Y axis and a timestamp on the X axis. >> >> I'd like to specify maybe the database and an xquery expression for the X and Y series. >> >> Thanks for your help, >> Ben >> >> On Sat, Jan 7, 2023, 08:49 Christian Grün <christian.gruen at gmail.com> wrote: >>> Hi Ben, >>> >>> Do you have some specific data that you would like to see reasonably >>> visualized by the Plot View, or are you rather looking for arbitrary >>> data that could be rendered by this visualization? >>> >>> Best, >>> Christian >>> >>> >>> On Fri, Jan 6, 2023 at 7:13 AM Ben Pracht <ben.pracht at gmail.com> wrote: >>>> I like having a convenient inline plotting for data, but I can't figure out how to select the right database to query from for the BaseX GUI plot widget. I can only select X and Y values from what I think is the country database. >>>> >>>> Best Regards, >>>> Ben Pracht >>>> 919.809.2439 >>>> ben.pracht at gmail.com
CG
Christian Grün10 Jan 2023 18:32 #
Quoted text · Ben Pracht · 2 lines
> I think any non-stock database would work to show this, but below is the > code I was using. This is the part of the dialog I'd like to get working:
Thanks. I’m confused, though: Are you struggling with the Plot or the Explorer visualization, or both?
CG
Christian Grün10 Jan 2023 19:06 #
Hi Ben,
Your query seems to be based on a different input ("GRCMAPLE-1" is not included in the example XML document), and…
Quoted text · Christian Grün · 1 line
> CREATE DB bullion-2 /home/bpracht/java/basex-10.4/
…by running this command, you are creating a database with all XML documents found in the given filesystem path (that’s why your database is not empty).
The attached query might give you a clue on how data can be prepared to get price/timestamp data displayed in the Plot visualization. After having run the query, you need to open the generated "test" database and enable the Plot visualization.
Best,
Christian
Quoted text · Ben Pracht · 92 lines
On Tue, Jan 10, 2023 at 5:16 PM Ben Pracht <ben.pracht.news at gmail.com> wrote: > > I think any non-stock database would work to show this, but below is the > code I was using. This is the part of the dialog I'd like to get working: > > https://i.imgur.com/ocGXjlP.png > > I apologize for the bad markering, but it shows the drop downs that > refer only to items in some other un-selected database. > > To recreate: > > 1. Please create a database. I kept most of the defaults: > > CREATE DB bullion-2 /home/bpracht/java/basex-10.4/ > > 2. Add a document: > > let $item := <item> > <vendor>sdbullion</vendor> > <img-url>https://sdbullion.com/media/catalog/product/cache/092a78d23e77560f092c3f80d85b629c/2/0/2022_50_1oz_9999_au_gml_core_rev_f_1_-min.jpg</img-url> > <detail-url>https://sdbullion.com/2022-1-oz-canadian-gold-maple-leaf-coin</detail-url> > <detail-title>2022 1 oz Gold Maple Leaf Coin BU</detail-title> > <schedule skus="GRC22MAPLE-1" timestamp="1672932572402"> > <tier quantity="1 - 9" cash-price="1930.26" cc-price="2010.69" > paypal-price="2010.69"/> > <tier quantity="10 - 19" cash-price="1925.26" cc-price="2005.48" > paypal-price="2005.48"/> > <tier quantity="20 - 99" cash-price="1920.26" cc-price="2000.27" > paypal-price="2000.27"/> > <tier quantity="100+" cash-price="1915.26" cc-price="1995.06" > paypal-price="1995.06"/> > </schedule> > </item> > let $add := db:add('bullion-2',$item,"test-item") > return $item > > 3. Test code: > > declare function > local:get-price-for-quantity($schedule,$price-type,$quantity as > xs:integer) { > let $matching-tier := for $tier in $schedule/tier > let $range := $tier/@quantity/data() > let $minimum := number(if > (contains($range,'-')) then > substring-before($range,'-') > else > substring-before($range,'+')) > let $maximum:= number(if > (contains($range,'-')) then > substring-after($range,'-') > else > xs:double("INF")) > return if ($quantity >= $minimum and > $quantity <= $maximum) then > $tier > else > () > > return $matching-tier/@*[local-name(.) = $price-type]/data() > }; > > for $schedule in collection("bullion")/item/schedule > let $timestamp := $schedule/@timestamp/data() > let $price-type := "cash-price" > let $price := local:get-price-for-quantity($schedule,"cash-price",1) > order by $timestamp ascending > return if ($schedule/@skus/data() = 'GRCMAPLE-1') then > ($timestamp,$price) > else > () > > The test code above should show the timestamp and price of the item. I > was going to put the timestamp as the X and the price as the Y, but I > can't figure out how. > > > Bonus concern: For some reason, it didn't create an empty database, but > rather had these other documents too: > > repo/http-www.functx.com-1.0/cxan.xml > repo/http-www.functx.com-1.0/expath-pkg.xml > webapp/WEB-INF/jetty.xml > webapp/WEB-INF/web.xml > etc/factbook.xml > etc/w3-catalog.xml > > > Thanks for your help, > > Ben
BP
Ben Pracht11 Jan 2023 07:30 #
It looks like the plot only supports first level attributes and nothing custom then? Basically, I can't have <level1><level2><level3 year="2020" price="234123"/></level2></level3>?
As a feature request, I think it would be very useful to have a drop down to select the database, then a separate drop down to select the X series and a separate value to select the Y series, or xquery functions to generate either of these :)
Regards,
Ben
Quoted text · Christian Grün · 113 lines
On 1/10/23 13:06, Christian Grün wrote: > Hi Ben, > > Your query seems to be based on a different input ("GRCMAPLE-1" is not > included in the example XML document), and… > >> CREATE DB bullion-2 /home/bpracht/java/basex-10.4/ > …by running this command, you are creating a database with all XML > documents found in the given filesystem path (that’s why your database > is not empty). > > The attached query might give you a clue on how data can be prepared > to get price/timestamp data displayed in the Plot visualization. After > having run the query, you need to open the generated "test" database > and enable the Plot visualization. > > Best, > Christian > > > > > On Tue, Jan 10, 2023 at 5:16 PM Ben Pracht <ben.pracht.news at gmail.com> wrote: >> I think any non-stock database would work to show this, but below is the >> code I was using. This is the part of the dialog I'd like to get working: >> >> https://i.imgur.com/ocGXjlP.png >> >> I apologize for the bad markering, but it shows the drop downs that >> refer only to items in some other un-selected database. >> >> To recreate: >> >> 1. Please create a database. I kept most of the defaults: >> >> CREATE DB bullion-2 /home/bpracht/java/basex-10.4/ >> >> 2. Add a document: >> >> let $item := <item> >> <vendor>sdbullion</vendor> >> <img-url>https://sdbullion.com/media/catalog/product/cache/092a78d23e77560f092c3f80d85b629c/2/0/2022_50_1oz_9999_au_gml_core_rev_f_1_-min.jpg</img-url> >> <detail-url>https://sdbullion.com/2022-1-oz-canadian-gold-maple-leaf-coin</detail-url> >> <detail-title>2022 1 oz Gold Maple Leaf Coin BU</detail-title> >> <schedule skus="GRC22MAPLE-1" timestamp="1672932572402"> >> <tier quantity="1 - 9" cash-price="1930.26" cc-price="2010.69" >> paypal-price="2010.69"/> >> <tier quantity="10 - 19" cash-price="1925.26" cc-price="2005.48" >> paypal-price="2005.48"/> >> <tier quantity="20 - 99" cash-price="1920.26" cc-price="2000.27" >> paypal-price="2000.27"/> >> <tier quantity="100+" cash-price="1915.26" cc-price="1995.06" >> paypal-price="1995.06"/> >> </schedule> >> </item> >> let $add := db:add('bullion-2',$item,"test-item") >> return $item >> >> 3. Test code: >> >> declare function >> local:get-price-for-quantity($schedule,$price-type,$quantity as >> xs:integer) { >> let $matching-tier := for $tier in $schedule/tier >> let $range := $tier/@quantity/data() >> let $minimum := number(if >> (contains($range,'-')) then >> substring-before($range,'-') >> else >> substring-before($range,'+')) >> let $maximum:= number(if >> (contains($range,'-')) then >> substring-after($range,'-') >> else >> xs:double("INF")) >> return if ($quantity >= $minimum and >> $quantity <= $maximum) then >> $tier >> else >> () >> >> return $matching-tier/@*[local-name(.) = $price-type]/data() >> }; >> >> for $schedule in collection("bullion")/item/schedule >> let $timestamp := $schedule/@timestamp/data() >> let $price-type := "cash-price" >> let $price := local:get-price-for-quantity($schedule,"cash-price",1) >> order by $timestamp ascending >> return if ($schedule/@skus/data() = 'GRCMAPLE-1') then >> ($timestamp,$price) >> else >> () >> >> The test code above should show the timestamp and price of the item. I >> was going to put the timestamp as the X and the price as the Y, but I >> can't figure out how. >> >> >> Bonus concern: For some reason, it didn't create an empty database, but >> rather had these other documents too: >> >> repo/http-www.functx.com-1.0/cxan.xml >> repo/http-www.functx.com-1.0/expath-pkg.xml >> webapp/WEB-INF/jetty.xml >> webapp/WEB-INF/web.xml >> etc/factbook.xml >> etc/w3-catalog.xml >> >> >> Thanks for your help, >> >> Ben
CG
Christian Grün11 Jan 2023 10:24 #
Quoted text · Ben Pracht · 4 lines
> As a feature request, I think it would be very useful to have a drop > down to select the database, then a separate drop down to select the X > series and a separate value to select the Y series, or xquery functions > to generate either of these :)
That’s probably out of scope, and it introduces challenges we cannot control that easily (such as inefficient queries that slow down rendering a lot; descendant elements might have attributes with identical names; etc.). One feature we might support one day is the ad-hoc visualization of query results.
Written for BaseX 10.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery