https://bl.ocks.org/d3noob/629790fc15cc1afba0253f29a4d246e7
This is a simple line graph written to illustrate a method of changing the colour of an axis in v4 of d3.js.
I suspect that it is not the best or most efficient method, so I am standing this up as an example to seek advice on a better solution. The question asked on Stack Overflow is
forked from the block:Simple line graph with v4
index.html#
<!DOCTYPE html>
<meta charset="utf-8">
<style> /* set the CSS */
.line {
fill: none;
stroke: steelblue;
stroke-width: 2px;
}
.axisRed line{
stroke: red;
}
.axisRed path{
stroke: red;
}
.axisRed text{
fill: red;
}
</style>
<body>
<!-- load the d3.js library -->
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
// set the dimensions and margins of the graph
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
// parse the date / time
var parseTime = d3.timeParse("%d-%b-%y");
// set the ranges
var x = d3.scaleTime().range([0, width]);
var y = d3.scaleLinear().range([height, 0]);
// define the line
var valueline = d3.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.close); });
// append the svg obgect to the body of the page
// appends a 'group' element to 'svg'
// moves the 'group' element to the top left margin
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
// Get the data
d3.csv("data.csv", function(error, data) {
if (error) throw error;
// format the data
data.forEach(function(d) {
d.date = parseTime(d.date);
d.close = +d.close;
});
// Scale the range of the data
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain([0, d3.max(data, function(d) { return d.close; })]);
// Add the valueline path.
svg.append("path")
.data([data])
.attr("class", "line")
.attr("d", valueline);
// Add the X Axis
svg.append("g")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x));
// Add the Y Axis
svg.append("g")
.attr("class", "axisRed")
.call(d3.axisLeft(y));
});
</script>
</body>
data.csv
相關推薦
https://bl.ocks.org/d3noob/629790fc15cc1afba0253f29a4d246e7
https://bl.ocks.org/d3noob/629790fc15cc1afba0253f29a4d246e7 This is a simple line graph written to illustrate a method of changing the colour of an axis in v4 of d3.js.
AndroidStudio報錯:Could not install Gradle distribution from ‘https://services.gradle.org/distribution
AndroidStudio報錯:Could not install Gradle distribution from \'https://services.gradle.org/distributions/gradle
OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/)
全文轉自:https://www.cnblogs.com/madhevin/p/10481930.html keras在視覺化時,如果呼叫plot_model函式,可能是出現OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.or
2-Maven問題:Downloading from central: https://repo1.maven.org/maven2/org/apache/maven/plugins/maven-a
參考:https://blog.csdn.net/qq_43443900/article/details/104377441 今天在使用IDEA建立Maven的webapp時遇見這樣一個不叫問題的問題:Downloading from central: https://repo1.maven.org/maven2/org/apache/maven
Failure to find org.glassfish:javax.el:pom:3.0.1-b08-SNAPSHOT in https://repository.apache.org/snapshots was cached in the local repository,
Failure to find org.glassfish:javax.el:pom:3.0.1-b08-SNAPSHOT in xxx 問題描述: 在進行程式編譯編譯的時候發生通過pom下載檔案之後進行編譯報錯:
cn.arxiv.org || https://arxiv.org/xxxx 訪問失敗
https://arxiv.org/xxxx 訪問失敗解決方法問題:原論文網址::https://arxiv.org/xxxx無法訪問
python pip升級報錯問題:Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max
1 提醒我升級pip WARNING: You are using pip version 20.2.2; however, version 20.2.4 is available.You should consider upgrading via the \'e:\\python\\anz\\python.exe -m pip install --upgrade pip\' comma
釋出npm包報錯: 403 Forbidden - PUT https://registry.npm.taobao.org/extract - no_perms
出現這個問題是因為當前設定的是cnpm 登入到的是cnpm,所以需要切換回來 可以輸入一下命令檢視當前的登入源:
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificat
問題描述 cmd 輸入 pip install {包名} 或者 cmd 輸入python -m pip install --upgrade pip 出現如下錯誤:
https://eggjs.org/zh-cn/cor e/security.html#安全威脅csrf的防範
技術標籤:eggjs各種報錯解決方案 報錯提示 https://eggjs.org/zh-cn/core/security.html#安全威脅csrf的防範
[解決:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile錯誤](https://www
技術標籤:mavenjavamysqlspring 問題分析: 不能執行依賴包maven-compiler-plugin:2.3.2,判斷原因是缺少這個jar包。 問題解決: 開啟pom.xml檔案,在適當位置加入下列依賴(缺什麼添什麼):
安裝pyspark時報錯——Could not fetch URL https://pypi.org/simple/pyspark/
報錯如下: Could not fetch URL https://pypi.org/simple/pyspark/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=\'pypi.org\', port=443): Max retries exceeded with url:
vue-element-admin npm install --registry=https://registry.npm.taobao.org ERR code128 問題
F:\\vue-element-admin>npm install --registry=https://registry.npm.taobao.org npm ERR! code 128 npm ERR! An unknown git error occurred
簡單“三步”讓你的網站支援https!
關於Let\'s Encrypt Let\'s Encrypt作為一個公共且免費SSL的專案逐漸被廣大使用者傳播和使用,是由Mozilla、Cisco、Akamai、IdenTrust、EFF等組織人員發起,主要的目的也是為了推進網站從HTTP向HTTPS過度的程式,目前
Ubuntu Nginx下配置ssl實現https訪問
前言 因為要寫個微信小程式,要請求我自己伺服器上的介面必須將我的域名新增至白名單,而且必須是要https訪問,故需此番折騰。
k8s nginx 跨域和 https 配置
問題描述 前端跨域問題:當頁面中載入或者非同步請求與原始頁面不同源的資源時,瀏覽器的同源策略會攔截請求,比較簡單的方式是後端增加一個 nginx 服務,給響應資料加上 CORS 相關的 header
Haproxy安裝與配置(HTTPS)
安裝方式一 通過apt-get安裝: sudo apt-get update sudo apt-get install haproxy 複製程式碼 安裝方式二
HTTPS協議是如何保證安全的?
相信大家對於HTTPS協議都不陌生,但是應該存在以下疑問: HTTPS協議到底是如何運作的?
HTTP基礎與HTTPS加密過程
一、前言 這篇文章主要是對HTTP/HTTPS的部分總結,由HTTP協議基礎知識引入HTTP協議的缺陷,進而描述HTTPS是如何解決HTTP的缺陷以及HTTPS的工作原理。
Spring Boot專案如何同時支援HTTP和HTTPS協議
本文首發於個人網站:Spring Boot專案如何同時支援HTTP和HTTPS協議 如今,企業級應用程式的常見場景是同時支援HTTP和HTTPS兩種協議,這篇文章考慮如何讓Spring Boot應用程式同時支援HTTP和HTTPS兩種協議。