home scroll deno

deno learning blog April 2023

Apr 2, 2023

Dynamically updated chart with scrolling x-axis works in React!

Apr 4, 2023

Update a chart based on d3no-data

Back to deno.
I don't know how to get a reference to the chart for calling the update function.
New approach:
Modify the d3no-data library itself.
Download the code and put it into a folder named library.
Change the import statements from
import { BarChart } from "https://deno.land/x/d3nodata@v0.1.3.1/charts.ts";
to
import { BarChart } from "../library/charts.ts";
Works!

How to call the update function in the library module BarChart.tsx?
The useEffect hook will be called every time the variable in the array change.

useEffect(() => {
//Runs on the first render
//And any time any dependency value changes
}, [prop, state]);
https://www.w3schools.com/react/react_useeffect.asp
Thos works, but some errors in the updated chart appear, for example wrong y-axis scale.


Apr 7, 2023

So far, only the examples work where the javascript is in an html file:
https://www.tutorialsteacher.com/d3js

Apr 8, 2023

In the example
https://www.tutorialsteacher.com/d3js/create-bar-chart-using-d3js
Removing indivual bars works, they were named with selectAll upon creation:
g.selectAll(".bar")
.data(data)
.enter()
g.select(".bar").remove();
Removing the xaxis also works by adding an id
https://stackoverflow.com/questions/19387898/how-to-assign-unique-id-to-svg-text-element-in-d3-javascript
g.append("g")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(xScale))
.attr("id", "xaxis")
g.select("#xaxis") .remove();
Note the refers to the element after which we call the id naming.
If we place the statement after the label creation
g.append("g")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(xScale))
.append("text")
.attr("id", "xaxis")
only the label will be removed.

This method works in deno as well!

Apr 11, 2023

React hooks, keeping value between renders
https://www.w3schools.com/react/showreact.asp?filename=demo2_react_useref

Apr 14, 2023

Fetching data from a web site
https://www.sitepoint.com/deno-fetch-data-third-party-api/

Apr 20, 2023

x axis vertical tick lines disappear after removing and adding x axis
This shows how to examine the svg structure in the elements inspector.
https://subscription.packtpub.com/book/web-development/9781782162162/5/ch05lvl1sec38/drawing-grid-lines

Observation:
before removing x-axis

<line stroke="currentColor" y2="-420" stroke-width="0.5" opacity="0.3">
after removing and adding x-axis
<line stroke="currentColor" y2="6" stroke-width:="" opacity:="">
When I change the y2 value to -420, the vertical line re-appears.

Apr 25, 2023

working on a branch of D3NO DATA
https://github.com/oslabs-beta/d3no-data/blob/main/CONTRIBUTING.md
  • fork the d3nodata repository
  • create a branch that we will be working on
  • git branch 
  • clone the branch that we are working on:
    git clone -b livechart https://github.com/atmelino/d3no-data.git
  • How do I know which branch I have on my computer?
    git branch
    results in
    * livechart
    https://www.atlassian.com/git/tutorials/using-branches
  • every commit and push will now update the livechart branch on github.

Apr 28, 2023

Work on contributing to d3nodata continues
Issues to resolve:
when updating the chart, and if
addLegend, addLabel, and/or addTooltip is enabled,
we add a new legend, label, tooltips to the chart
potentially causing memory issues.
This can be verified by looking at the elements in the console of the browser:

d3_legend 
A text element "TITLE" is unnecessarily added in each cycle.

Date

New Card

Follow Me

discord