- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要不同颜色的坐标轴(x 和 y)和图表的网格。我尝试更改 CSS 但无法成功。
我附上了图形代码和 CSS。 css代码如下
.axis path,
.axis line {
fill: none;
/*stroke: #000;*/
stroke: #B2B2B2;
shape-rendering: crispEdges;
opacity: 0.5;
}
.area_characteristics_temperature {
fill: steelblue;
opacity:0.5;
border: 0px;
margin:0px;
overflow: hidden;
}
.area_characteristics_temperature_3yr {
fill: #7da7ca;
opacity:0.5;
border: 0px;
margin:0px;
overflow: hidden;
}
.area_characteristics_temperature_10yr {
fill: #676767;
opacity:0.5;
border: 0px;
margin:0px;
overflow: hidden;
}
.area_characteristics_temperature_prev {
fill: #eec7ea;
opacity:0.5;
border: 0px;
margin:0px;
overflow: hidden;
}
.line {
fill: transparent;
stroke:red;
stroke-width:3px;
}
.line1 {
fill: transparent;
stroke:green;
stroke-width:3px;
}
.line_characteristics_current_temperature_max{
fill: transparent;
/*stroke:red;*/
stroke:#CC3300;
stroke-width:3px;
}
.line_characteristics_current_temperature_min{
fill: transparent;
/*stroke:yellow;*/
stroke:#0099CC;
stroke-width:3px;
}
.line_characteristics_forecast_temperature_max{
fill: transparent;
/*stroke:green;*/
stroke:#CC3300;
stroke-width:3px;
stroke-height:3px;
/*stroke-dasharray:2.5px,6px;*/
stroke-dasharray:2.5px,5.5px,2.5px,5.5px;
stroke-soft:5px;
stroke-linecap:round;
stroke-height:3px;
stroke-width:3.4px;
}
.line_characteristics_forecast_temperature_min{
fill: transparent;
stroke:#0088C3;
stroke-width:3px;
stroke-height:3px;
/*stroke-dasharray:3px,6px,3px,6px;*/
stroke-dasharray:2.5px,5.5px,2.5px,5.5px;
stroke-soft:5px;
stroke-linecap:round;
stroke-height:3px;
stroke-width:3.4px;
strokeDashoffset:10px,5px;
}
#wgtmsr option{
width:150px;
}
/*<DEMO>*/
#nav {
height:200px;
width:100px;
float:left;
padding:5px;
padding-bottom:50px;
}
#section {
width:350px;
float:left;
padding:10px;
}
/* Main style*/
.widget_sidebar{
min-width: 200px;
max-width:25%;
overflow:hidden;
float:left
}
.widget_graphArea{
min-width: 200px;
max-width:75%;
overflow:hidden;
}
图形代码:我正在使用D3进行图形编码
var self = this;
this.divID = divID;
this.forecastEnabled = true;
this.currentEnabled = true;
this.averagesEnabled = true;
this.currentData = [];
this.areaClass = "area_characteristics_temperature";
this.averagesData = []
this.forecastdata = new Array();
this.merged_data = new Array();
this.svg = null;
this._currentDataTrail = {temperature_max: 0, temperature_min: 0, date: 0}
this.parseDate = d3.time.format("%Y-%m-%d").parse;
w = $("#" + this.divID).width();
h = $("#" + this.divID).height();
this.boxing = {top: 20, right: 30, bottom: 30, left: 50},
this.width = w - this.boxing.left - this.boxing.right,
this.height = h - this.boxing.top - this.boxing.bottom;
this.x = d3.time.scale()
.range([0, this.width]);
this.y = d3.scale.linear()
.range([this.height, 0]);
this.xAxis = d3.svg.axis()
.scale(this.x)
// .ticks(d3.time.day, 1)
// .tickFormat(d3.time.format('%b %d'))
.orient("bottom");
this.yAxis = d3.svg.axis()
.scale(this.y)
.orient("left")
.ticks(5, 0)
.tickPadding(10);
this.svg = null;
this.line_characteristics = d3.svg.line()
.x(function (d) {
return self.x(d.date);
})
.y(function (d) {
return self.y(d.temperature);
});
this.line_characteristics_temperature_min = d3.svg.line()
.x(function (d) {
return self.x(d.date);
})
.y(function (d) {
return self.y(d.temperature_min);
});
this.line_characteristics_temperature_max = d3.svg.line()
.x(function (d) {
return self.x(d.date);
})
.y(function (d) {
return self.y(d.temperature_max);
});
this.area_characteristics_temperature = d3.svg.area()
.x(function (d) {
return self.x(d.date);
})
.y0(function (d) {
return self.y(d.temperature_max);
})
.y1(function (d) {
return self.y(d.temperature_min);
});
self.updateCurrentData = function (newData, append)
{
var _currentMaxDate = new Date(0);
newData.forEach(function (d) {
d.date = self.parseDate(d.date);
d.temperature_max = d.temperatures.max;
d.temperature_min = d.temperatures.min;
if (d.date > _currentMaxDate) {
_currentMaxDate = d.date;
self._currentDataTrail.temperature_max = d.temperature_max;
self._currentDataTrail.temperature_min = d.temperature_min;
self._currentDataTrail.date = d.date;
}
});
if (append) {
self.currentData = self.currentData.concat(newData);
} else {
self.currentData = newData;
}
self.forecastData = new Array();
self.updateMerged();
};
self.setAreaClass = function (css_class) {
self.areaClass = css_class;
}
self.updateForecastData = function (newData)
{
self.forecastData = new Array();
newData.forEach(function (d) {
d.date = self.parseDate(d.date);
d.temperature_max = d.forecast[0].temperatures.max;
d.temperature_min = d.forecast[0].temperatures.min;
});
if (self._currentDataTrail && self._currentDataTrail.date) {
self.forecastData.push(self._currentDataTrail)
}
self.forecastData = self.forecastData.concat(newData)
self.updateMerged();
};
self.updateAveragesData = function (newData, append)
{
var _temp = new Date();
var current = new Date(_temp.getFullYear(), 0, 1);
newData.forEach(function (d) {
if (d.minTemp) {
current.setDate(current.getDate() + 1);
d.temperature_max = d.maxTemp.average.toFixed(4);
d.temperature_min = d.minTemp.average.toFixed(4);
var date = current.getFullYear() + "-" + d.day;
d.date = self.parseDate(date);
} else {
d.date = self.parseDate(d.date);
d.date.setFullYear(d.date.getFullYear() + 1)
d.temperature_max = d.temperatures.max;
d.temperature_min = d.temperatures.min;
}
});
if (append) {
self.averagesData = self.averagesData.concat(newData);
} else {
self.averagesData = newData;
}
self.updateMerged();
};
self.updateMerged = function ()
{
self.merged_data = new Array();
if (self.currentData != undefined && self.currentData instanceof Array && self.currentData.length > 0 && self.forecastData != undefined && self.forecastData instanceof Array && self.forecastData.length > 0) {
self.merged_data = self.merged_data.concat(self.currentData)
self.merged_data = self.merged_data.concat(self.forecastData)
} else if (self.currentData != undefined && self.currentData instanceof Array && self.currentData.length > 0) {
self.merged_data = self.merged_data.concat(self.currentData);
} else if (self.forecastData != undefined && self.forecastData instanceof Array && self.forecastData.length > 0) {
self.merged_data = self.merged_data.concat(self.forecastData);
}
};
self.redraw = function () {
w = $("#" + self.divID).width();
h = $("#" + self.divID).height();
self.width = w - self.boxing.left - self.boxing.right,
self.height = h - self.boxing.top - self.boxing.bottom;
self.x = d3.time.scale()
.range([0, self.width]);
self.y = d3.scale.linear()
.range([self.height, 0]);
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.day, 1)
.tickFormat(d3.time.format('%b %d'))
.orient("bottom");
self.yAxis = d3.svg.axis()
.scale(self.y)
.orient("left")
.tickSize(-self.width)
.ticks(5, 0)
.tickPadding(10);
if (self.svg !== null) {
self.svg.remove();
}
$("#" + self.divID).html("");
self.svg = d3.select("#" + self.divID).append("svg")
.attr("width", self.width + self.boxing.left + self.boxing.right)
.attr("height", self.height + self.boxing.top + self.boxing.bottom)
.append("g")
.attr("transform", "translate(" + self.boxing.left + "," + self.boxing.top + ")");
var minDate = new Date(2999, 01, 01);
self.merged_data.forEach(function (d) {
if (d.date < minDate) {
minDate = d.date;
}
});
var maxDate = new Date(0);
self.merged_data.forEach(function (d) {
if (d.date > maxDate) {
maxDate = d.date;
}
});
var totalDateDiff = maxDate - minDate;
totalDateDiff = totalDateDiff / (1000 * 60 * 60 * 24);
if (w < 500 && !isNaN(totalDateDiff)) {
if (totalDateDiff < 30) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.days, 7)
.tickFormat(d3.time.format('%b %d'))
.orient("bottom");
} else if (totalDateDiff > 30 && totalDateDiff < 150) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.months)
.tickFormat(d3.time.format('%b %y'))
.orient("bottom");
} else if (totalDateDiff > 150 && totalDateDiff < 365) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.years)
.tickFormat(d3.time.format('%b %y'))
.orient("bottom");
} else if (totalDateDiff > 365) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.years)
.tickFormat(d3.time.format('%Y'))
.orient("bottom");
}
} else if (w > 500 && !isNaN(totalDateDiff)) {
if (totalDateDiff < 15) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.days, 1)
.tickFormat(d3.time.format('%b %d'))
.orient("bottom");
} else if (totalDateDiff > 15 && totalDateDiff <= 30) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.days, 4)
.tickFormat(d3.time.format('%b %d'))
.orient("bottom");
} else if (totalDateDiff > 30 && totalDateDiff < 100) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.months, 1)
.tickFormat(d3.time.format('%b %y'))
.orient("bottom");
} else if (totalDateDiff > 100 && totalDateDiff < 365) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.months)
.tickFormat(d3.time.format('%b %y'))
.orient("bottom");
} else if (totalDateDiff > 365) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.years)
.tickFormat(d3.time.format('%b %Y'))
.orient("bottom");
}
} else if (isNaN(w) || isNaN(totalDateDiff)) {
self.xAxis = d3.svg.axis()
.scale(self.x)
.ticks(d3.time.years)
.tickFormat(d3.time.format('%Y'))
.orient("bottom");
}
self.x.domain(d3.extent(self.merged_data, function (d) {
return d.date;
}));
self.y.domain([d3.min(self.merged_data, function (d) {
return d.temperature_min - 10;
}), d3.max(self.merged_data, function (d) {
return d.temperature_max + 10;
})]);
self.svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + self.height + ")")
.call(self.xAxis.orient("bottom"));
self.svg.append("text")
.attr("x", 0)
.attr("y", self.height)
.style("text-anchor", "middle")
.text("");
self.svg.append("g")
.attr("class", "y axis")
.call(self.yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("x", -85)
.attr("y", 6)
.attr("dy", ".71em")
.style("text-align", "middle")
.text("Temperature(°C)");
self.svg.append("path")
.datum(self.averagesData)
.attr("class", self.areaClass)
.attr("d", self.area_characteristics_temperature);
if (self.currentEnabled === true && self.currentData instanceof Array && self.currentData.length > 0) {
self.svg.append("path")
.datum(self.currentData)
.attr("class", "line_characteristics_current_temperature_max")
.attr("d", self.line_characteristics_temperature_max);
self.svg.append("path")
.datum(self.currentData)
.attr("class", "line_characteristics_current_temperature_min")
.attr("d", self.line_characteristics_temperature_min);
}
if (self.forecastEnabled === true && self.forecastData instanceof Array && self.forecastData.length > 0) {
self.svg.append("path")
.datum(self.forecastData)
.attr("class", "line_characteristics_forecast_temperature_max")
.attr("d", self.line_characteristics_temperature_max)
.style("stroke-dasharray", "2.5,7");
self.svg.append("path")
.datum(self.forecastData)
.attr("class", "line_characteristics_forecast_temperature_min")
.attr("d", self.line_characteristics_temperature_min)
.style("stroke-dasharray", "2.5,7");
}
}
self.showCurrent = function (show)
{
self.currentEnabled = show;
};
self.showForecast = function (show)
{
self.forecastEnabled = show;
};
self.showAverages = function (show)
{
self.averagesEnabled = show;
};
}
最佳答案
如下所示应用 CSS。
.axis path, .axis line{
stroke: navy;
fill: none;
}
.y.axis path{
stroke: brown;
fill: none;
}
.y.axis line{
stroke: grey;
opacity: 0.5;
}
关于javascript - D3 中轴和网格的不同颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327704/
我有 table 像这样 -------------------------------------------- id size title priority
我的应用在不同的 Activity (4 个 Activity )中仅包含横幅广告。所以我的疑问是, 我可以对所有横幅广告使用一个广告单元 ID 吗? 或者 每个 Activity 使用不同的广告单元
我有任意(但统一)数字列表的任意列表。 (它们是 n 空间中 bin 的边界坐标,我想绘制其角,但这并不重要。)我想生成所有可能组合的列表。所以:[[1,2], [3,4],[5,6]] 产生 [[1
我刚刚在学校开始学习 Java,正在尝试自定义控件和图形。我目前正在研究图案锁,一开始一切都很好,但突然间它绘制不正确。我确实更改了一些代码,但是当我看到错误时,我立即将其更改回来(撤消,ftw),但
在获取 Distinct 的 Count 时,我在使用 Group By With Rollup 时遇到了一个小问题。 问题是 Rollup 摘要只是所有分组中 Distinct 值的总数,而不是所有
这不起作用: select count(distinct colA, colB) from mytable 我知道我可以通过双选来简单地解决这个问题。 select count(*) from (
这个问题在这里已经有了答案: JavaScript regex whitespace characters (5 个回答) 2年前关闭。 你能解释一下为什么我会得到 false比较 text ===
这个问题已经有答案了: 奥 git _a (56 个回答) 已关闭 9 年前。 我被要求用 Javascript 编写一个函数 sortByFoo 来正确响应此测试: // Does not cras
所以,我不得不说,SQL 是迄今为止我作为开发人员最薄弱的一面。也许我想要完成的事情很简单。我有这样的东西(这不是真正的模型,但为了使其易于理解而不浪费太多时间解释它,我想出了一个完全模仿我必须使用的
这个问题在这里已经有了答案: How does the "this" keyword work? (22 个回答) 3年前关闭。 简而言之:为什么在使用 Objects 时,直接调用的函数和通过引用传
这个问题在这里已经有了答案: 关闭 12 年前。 Possible Duplicate: what is the difference between (.) dot operator and (-
我真的不明白这里发生了什么但是: 当我这样做时: colorIndex += len - stopPos; for(int m = 0; m < len - stopPos; m++) { c
思考 MySQL 中的 Group By 函数的最佳方式是什么? 我正在编写一个 MySQL 查询,通过 ODBC 连接在 Excel 的数据透视表中提取数据,以便用户可以轻松访问数据。 例如,我有:
我想要的SQL是这样的: SELECT week_no, type, SELECT count(distinct user_id) FROM group WHERE pts > 0 FROM bas
商店表: +--+-------+--------+ |id|name |date | +--+-------+--------+ |1 |x |Ma
对于 chrome 和 ff,当涉及到可怕的 ie 时,这个脚本工作完美。有问题 function getY(oElement) { var curtop = 0; if (oElem
我现在无法提供代码,因为我目前正在脑海中研究这个想法并在互联网上四处乱逛。 我了解了进程间通信和使用共享内存在进程之间共享数据(特别是结构)。 但是,在对保存在不同 .c 文件中的程序使用 fork(
我想在用户集合中使用不同的功能。在 mongo shell 中,我可以像下面这样使用: db.users.distinct("name"); 其中名称是用于区分的集合字段。 同样我想要,在 C
List nastava_izvjestaj = new List(); var data_context = new DataEvidencijaDataContext();
我的 Rails 应用程序中有 Ransack 搜索和 Foundation,本地 css 渲染正常,而生产中的同一个应用程序有一个怪癖: 应用程序中的其他内容完全相同。 我在 Chrome 和 Sa
我是一名优秀的程序员,十分优秀!