I am a YouTuber! Check out my channel!
hswolff / betterweather Goto Github PK
View Code? Open in Web Editor NEWAn example application to show how to use D3 in a React Native application.
License: MIT License
An example application to show how to use D3 in a React Native application.
License: MIT License
I am a YouTuber! Check out my channel!
Hi, could you show some code for adding axis by using d3-axis?
'query-string' (android)
The first datapoint on the graph shows in position 0 even tho the value is 72 of the y axis. on Android. Thanks for the great work.
I saw that you put import Morph from 'art/morph/path';
in one of the files, but I can't seem to find the file art/morph/path
in the project.
I'm trying to run this on Android, I usually use expo for react native, but I can't seem to get this program to open. Do you have any solutions?
Hey, really enjoying perusing this codebase
I can't figure out what this syntax is:
import * as scale from 'd3-scale';
import * as shape from 'd3-shape';
import * as d3Array from 'd3-array';
const d3 = {
scale,
shape,
};
/**
* Create an x-scale.
* @param {number} start Start time in seconds.
* @param {number} end End time in seconds.
* @param {number} width Width to create the scale with.
* @return {Function} D3 scale instance.
*/
function createScaleX(start, end, width) {
return d3.scale.scaleTime()
.domain([new Date(start * 1000), new Date(end * 1000)])
.range([0, width]);
}
/**
* Create a y-scale.
* @param {number} minY Minimum y value to use in our domain.
* @param {number} maxY Maximum y value to use in our domain.
* @param {number} height Height for our scale's range.
* @return {Function} D3 scale instance.
*/
function createScaleY(minY, maxY, height) {
return d3.scale.scaleLinear()
.domain([minY, maxY]).nice()
// We invert our range so it outputs using the axis that React uses.
.range([height, 0]);
}
/**
* Creates a line graph SVG path that we can then use to render in our
* React Native application with ART.
* @param {Array.<Object>} options.data Array of data we'll use to create
* our graphs from.
* @param {function} xAccessor Function to access the x value from our data.
* @param {function} yAccessor Function to access the y value from our data.
* @param {number} width Width our graph will render to.
* @param {number} height Height our graph will render to.
* @return {Object} Object with data needed to render.
*/
export function createLineGraph({
data,
xAccessor,
yAccessor,
width,
height,
}) {
const lastDatum = data[data.length - 1];
const scaleX = createScaleX(
data[0].time,
lastDatum.time,
width
);
// Collect all y values.
const allYValues = data.reduce((all, datum) => {
all.push(yAccessor(datum));
return all;
}, []);
// Get the min and max y value.
const extentY = d3Array.extent(allYValues);
const scaleY = createScaleY(extentY[0], extentY[1], height);
const lineShape = d3.shape.line()
.x(d => scaleX(xAccessor(d)))
.y(d => scaleY(yAccessor(d)));
return {
data,
scale: {
x: scaleX,
y: scaleY,
},
path: lineShape(data),
ticks: data.map((datum) => {
const time = xAccessor(datum);
const value = yAccessor(datum);
return {
x: scaleX(time),
y: scaleY(value),
datum,
};
}),
};
}
specifically the export function createLineGraph({}){}
call is confusing me
what exactly is going on? :)
It seems to work but I have no idea what that's about :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.