score:0
First you can determine the x and y scales for your data:
xScale = d3.scaleLinear()
.domain(d3.extent(data, d => d.GDP))
.range([0, width]);
yScale = d3.scaleLinear()
.domain(d3.extent(data, d => d.GNI))
.range([height, 0]);
If you want a separate line for each of the political parties, then you probably need to prepare a different data array for each party by filtering the original data.
const congress = data.filter(d => d.Party === 'Congress');
const bjp = data.filter(d => d.Party === 'BJP');
...
etc
Then you can build the line generator that can be used to draw each line:
const lineGenerator = d3.line()
.x(d => xScale(d))
.y(d => yScale(d));
...
etc
Then you can add each line to the chart:
const svg = d3.select('svg');
svg.append('path')
.datum(congress)
.style('stroke', 'darkgreen')
.style('fill', 'none')
.attr('d', lineGenerator);
...
etc
Source: stackoverflow.com
Related Query
- Line Chart with different line colors in d3
- d3.js chart area filling with different colors
- dc.js line chart with range of colors
- Changing the colors of each of the Stacked Bar chart with different Color in D3
- Fill line chart area with multiple colors
- How to create a line chart with vertical line and different backgrounds?
- render bar chart with different colors in react native
- On common x-axis how to draw a chart with different unit of dataset array (multi line chart)
- Drawing a line with two different colors using D3
- Line chart alignment with different data sets
- nvd3 line chart with string values on x-axis
- D3.JS time-series line chart with real-time data, panning and zooming
- Multiseries line chart with mouseover tooltip
- NVD3 line chart with realtime data
- javascript charting - nvd3 line chart with two Y-axis
- d3 Line Chart with enter-update-exit logic
- NVD3 line chart with vertical line
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- Special donut chart with different rings/arcs for positive and negative values
- Line chart using ordinal x-axis with d3.js and nvd3.js
- Draw D3 Simple Line chart With an Array
- Visualize date specific data with a line chart in browser with javascript
- d3 v4 drag line chart with x and y axes
- Error in A Simple D3 Line chart with Legend and Tooltips for D3v 3.5.13
- d3.js scatterplot with different colors and symbols - issues encountered
- Two lined D3.js line chart, with one line starting at different position
- d3.js line chart with negative numbers
- Dimple.js line chart with composite axis, no links between points on series
- Align lines and dots with x-axis values in line chart
- C3js - combination chart with data labels only for line
More Query from same tag
- line chart using arrays of an object using d3
- Plotting two datasets
- D3 mouseover event is not triggered on the bottom elements
- Installing rubygem d3js into a Rails 5 app, receiving railties compatibility issues
- d3 multiline voronoi not working
- D3 Path in Group does not show up in Firefox, only shows up in Chrome
- tooltip on chart not working
- transition().each() changes after D3 v3
- How can I speed up loading thousands of images?
- Creating a d3.js Treemap zoomable with CSV
- Making a variable from a csv file
- d3 ignore SVG on selectAll
- Angular 6 and D3 v.5.5, this.<variable> undefined
- PHP: d3.js script does not display anything
- D3 animation (transition) does NOT work on Angular app
- d3 Version4 getting null object
- How to link 2 php scripts to run simultaneously in d3
- Simple D3js code not working
- Trying to add an XHR to Queue.js to show progress
- Convert D3 force chart to v4
- how to change the color of circle to back with original color on clicking of another circle in D3 Js chart
- D3.js bar chart - axis and labels not working / transitioning
- d3.xhr example or AJAX d3's way
- D3.js - Updating title for svg path
- Splitting and grouping records into daily sets using d3.js and dc.js
- Having trouble making a bar chart bar onClick create changes to scatter chart points using D3
- Get one element from d3js selection, by index
- Crossfilter/d3.js -can I show the fraction of records that have been selected via a crossfilter?
- How to add a symbol to a group depending on its data
- How to fill a single value in the 'Donut Chart'