const lineSeries = fc.seriesSvgLine() .crossValue(d => d.date) .mainValue(d => d.forceIndex); // use a line annotation to show the zero value / baseline const lineAnnotation = fc.annotationSvgLine(); // merge the annotation and line into a single series that is associated with the chart const mergedSeries = fc.seriesSvgMulti() .series([lineSeries, lineAnnotation]) .mapping((data, index, series) => { // the data source for the line series is the bound series, however, the datasource // for the annotation is a hard coded array of values switch(series[index]) { case lineSeries: return data; case lineAnnotation: return [0]; } }) const chart = fc.chartCartesian( d3.scaleTime(), d3.scaleLinear() ) .yTickFormat(d3.format(',.3s')) .yOrient('left') .svgPlotArea(mergedSeries); // use the extent component to determine the x domain const xExtent = fc.extentDate() .accessors([d => d.date]); // the y extent is padded by 10% and symmetrical about zero const yExtent = fc.extentLinear() .accessors([d => d.forceIndex]) .pad([0.1, 0.1]) .symmetricalAbout(0); const parseDate = d3.timeParse("%d-%b-%y"); const forceIndexAlgorithm = fc.indicatorForceIndex() .closeValue(d => d.close) .volumeValue(d => d.volume); d3.csv('data.csv', row => ({ open: Number(row.Open), close: Number(row.Close), high: Number(row.High), low: Number(row.Low), date: parseDate(row.Date), volume: Number(row.Volume) })).then(data => { // the CSV data is in reverse date order data = data.reverse(); // compute the RSI const forceIndexData = forceIndexAlgorithm(data); // merge into a single series const mergedData = data.map((d, i) => Object.assign({}, d, { forceIndex: forceIndexData[i] }) ); // set the domain based on the data chart.xDomain(xExtent(mergedData)) .yDomain(yExtent(mergedData)); // select and render d3.select('#chart-element') .datum(mergedData) .call(chart); });