s
Last active
February 21, 2017 08:24
-
-
Save lhstock/711d1fec7bb3fb9f272e1a208ed98be9 to your computer and use it in GitHub Desktop.
points to class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="https://d3js.org/d3.v3.min.js"></script> | |
<script src="point.js"></script> | |
<style> | |
.xis_x_class .domain { | |
fill: black; | |
stroke-width: 1px; | |
} | |
.xis_y_class .domain { | |
fill: black; | |
stroke-width: 1px; | |
} | |
line { | |
y2: -6; | |
fill: #878282; | |
stroke: #878282; | |
stroke-width: 1px; | |
} | |
.Tooltip { | |
position: absolute; | |
width: 120; | |
height: auto; | |
font-family: simsun; | |
font-size: 14px; | |
text-align: center; | |
border-style: solid; | |
border-width: 1px; | |
background-color: white; | |
border-radius: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="a"> | |
</div> | |
</body> | |
<script> | |
window.scatterplot = window.scatterplot || Scatterplot.CreateNew() | |
.Labelid("a") | |
.Width(900) | |
.Placement_legend(true) | |
.Scale_type_x(1) | |
.Scale_type_x_ordinal_type(2) | |
.Scale_type_x_range_type_Points_n(2) | |
.Scale_type_x_range_type_Bands_p(0) | |
.Scale_type_x_range_type_Bands_o(0) | |
.Scale_type_y(1) | |
.Scale_type_y_ordinal_type(1) | |
.Scale_type_y_range_type_Points_n(3) | |
.Scale_type_y_range_type_Bands_p(1) | |
.Scale_type_y_range_type_Bands_o(1) | |
.Showbackground_x(true) | |
.Showbackground_y(true) | |
.BottomAxis("x") | |
.Switch_x_transfrom(true) | |
.Switch_y_transfrom(true) | |
.CreateSvg(); | |
d3.json("point.json", function(error, jsonData) { | |
if(!error) { | |
scatterplot.Data(jsonData).Draw() | |
} else { | |
console.log(error); | |
} | |
}); | |
</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! function() { | |
var Scatterplot = Object.create(Object); | |
Object.defineProperties(Scatterplot, { | |
"CreateNew": { | |
"value": function(v) { | |
return FCreateNew(); | |
} | |
} | |
}); | |
function FCreateNew() { | |
var scatterplot = Object.create(Scatterplot); | |
scatterplot = { | |
"_labelid": undefined, | |
"_width": undefined, | |
"_data": undefined, | |
"_placement_legend": undefined, | |
"_scale_type_x": undefined, | |
"_scale_type_y": undefined, | |
"_switch_x_transfrom": undefined, | |
"_switch_y_transfrom": undefined, | |
"_scale_type_x_ordinal_type": undefined, | |
"_scale_type_x_range_type_range_array": undefined, | |
"_scale_type_x_range_type_min": undefined, | |
"_scale_type_x_range_type_max": undefined, | |
"_scale_type_x_range_type_Points_n": undefined, | |
"_scale_type_y_ordinal_type": undefined, | |
"_scale_type_y_range_type_range_array": undefined, | |
"_scale_type_y_range_type_min": undefined, | |
"_scale_type_y_range_type_max": undefined, | |
"_scale_type_y_range_type_Points_n": undefined, | |
"_scale_type_y_range_type_Bands_p": undefined, | |
"_scale_type_y_range_type_Bands_o": undefined, | |
"_showbackground_x": undefined, | |
"_showbackground_y": undefined, | |
"_svg_type": undefined, | |
"_bottomAxis": undefined, | |
"ValueToProperty": function(value, name) { | |
this[name] = value; | |
return this; | |
} | |
}; | |
Object.defineProperties(scatterplot, { | |
"Labelid": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_labelid") | |
return this; | |
} | |
}, | |
"Width": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_width") | |
return this; | |
} | |
}, | |
"Data": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_data") | |
return this; | |
} | |
}, | |
"Placement_legend": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_placement_legend") | |
return this; | |
} | |
}, | |
"Scale_type_x": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x") | |
return this; | |
} | |
}, | |
"Scale_type_y": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y") | |
return this; | |
} | |
}, | |
"Switch_x_transfrom": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_switch_x_transfrom") | |
return this; | |
} | |
}, | |
"Switch_y_transfrom": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_switch_y_transfrom") | |
return this; | |
} | |
}, | |
"Scale_type_x_ordinal_type": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x_ordinal_type") | |
return this; | |
} | |
}, | |
"Scale_type_x_range_type_range_array": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x_range_type_range_array") | |
return this; | |
} | |
}, | |
"Scale_type_x_range_type_min": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x_range_type_min") | |
return this; | |
} | |
}, | |
"Scale_type_x_range_type_max": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x_range_type_max") | |
return this; | |
} | |
}, | |
"Scale_type_x_range_type_Points_n": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x_range_type_Points_n") | |
return this; | |
} | |
}, | |
"Scale_type_x_range_type_Bands_p": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_x_range_type_Bands_p") | |
return this; | |
} | |
}, | |
"Scale_type_x_range_type_Bands_o": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_Scale_type_x_range_type_Bands_o") | |
return this; | |
} | |
}, | |
"Scale_type_y_ordinal_type": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y_ordinal_type") | |
return this; | |
} | |
}, | |
"Scale_type_y_range_type_range_array": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y_range_type_range_array") | |
return this; | |
} | |
}, | |
"Scale_type_y_range_type_min": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y_range_type_min") | |
return this; | |
} | |
}, | |
"Scale_type_y_range_type_max": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y_range_type_max") | |
return this; | |
} | |
}, | |
"Scale_type_y_range_type_Points_n": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y_range_type_Points_n") | |
return this; | |
} | |
}, | |
"Scale_type_y_range_type_Bands_p": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_scale_type_y_range_type_Bands_p") | |
return this; | |
} | |
}, | |
"Scale_type_y_range_type_Bands_o": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_Scale_type_y_range_type_Bands_o") | |
return this; | |
} | |
}, | |
"Showbackground_x": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_showbackground_x") | |
return this; | |
} | |
}, | |
"Showbackground_y": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_showbackground_y") | |
return this; | |
} | |
}, | |
"BottomAxis": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_bottomAxis") | |
return this; | |
} | |
}, | |
"Svg_type": { | |
"value": function(v) { | |
this.ValueToProperty(v, "_svg_type") | |
return this; | |
} | |
}, | |
"CreateSvg": { | |
value: function() { | |
CreateSvg_scatterplot(this); | |
return this; | |
} | |
}, | |
"Draw": { | |
value: function() { | |
draw_scatterplot(this); | |
return this; | |
} | |
} | |
}); | |
function CreateSvg_scatterplot(scatterplot) { | |
DetermineProperties_scatterplot(scatterplot); | |
scatterplot.svg = d3.select("#" + scatterplot._labelid) | |
.append("svg") | |
.style("background", "red") | |
.attr("id", scatterplot._svgid) | |
.attr("width", scatterplot._width) | |
.attr("height", scatterplot._height); | |
scatterplot.tool_window = d3.select("body") | |
.append("div") | |
.attr({ | |
"class": scatterplot._c_tool_window, | |
"id": scatterplot._id_tool_window, | |
"left": 0, | |
"top": scatterplot._height, | |
}) | |
.style({ | |
"opacity": 0 | |
}) | |
} | |
function DetermineProperties_scatterplot(scatterplot) { | |
SetId_scatterplot(scatterplot); | |
scatterplot._height = scatterplot._width < 300 ? alert("width不能< 300") : | |
(scatterplot._width / 0.618 * (1 - 0.618) < 500 ? scatterplot._width / 0.618 * (1 - 0.618) : 500); | |
scatterplot._svg_type = 1; | |
scatterplot._ToRight = 100; | |
scatterplot._legend_length = 100; | |
scatterplot._scatterplot_axis_x_length = scatterplot._width - scatterplot._ToRight - (scatterplot._placement_legend ? scatterplot._legend_length : 30); | |
scatterplot._scale_type_x_range_type_min = 0; | |
scatterplot._scale_type_x_range_type_max = scatterplot._scatterplot_axis_x_length; | |
scatterplot._scale_type_y_range_type_min = 0; | |
scatterplot._scale_type_y_range_type_max = scatterplot._height - 100; | |
// scatterplot._showbackground_x = scatterplot._switch_x_transfrom ? false : scatterplot._showbackground_x; | |
// scatterplot._showbackground_y = scatterplot._switch_y_transfrom ? false : scatterplot._showbackground_y; | |
} | |
function draw_scatterplot(scatterplot) { | |
Tool_scatterplot(scatterplot); | |
DataPretreatment_scatterplot(scatterplot); | |
d3.selectAll("." + scatterplot._axis_x_class)[0][0] == null && scatterplot.svg.append("g") | |
.attr("class", scatterplot._axis_x_class) | |
.attr("transform", "translate(" + (scatterplot._ToRight) + "," + (scatterplot._height - 50 + scatterplot._switch_x_transfrom * (scatterplot.axis_y_scale(0))) + ")") | |
.call(scatterplot.axis_x) | |
.style("font-size", "12px") | |
d3.selectAll("." + scatterplot._axis_y_class)[0][0] == null && scatterplot.svg.append("g") | |
.attr("class", scatterplot._axis_y_class) | |
.attr("transform", "translate(" + (scatterplot._ToRight + scatterplot._switch_y_transfrom * (scatterplot.axis_x_scale(0))) + "," + (scatterplot._height - 50) + ")") | |
.call(scatterplot.axis_y) | |
.style("font-size", "12px"); | |
var maxlength = []; | |
d3.selectAll("." + scatterplot._axis_y_class).selectAll("text")[0].map(function(d) { | |
maxlength.push(d.getComputedTextLength()); | |
}); | |
scatterplot.g_title_x = scatterplot.svg.append("g") | |
.attr({ | |
"class": scatterplot._c_g_title_x, | |
"id": scatterplot._id_g_title_x, | |
"transform": "translate(" + (scatterplot._ToRight + scatterplot._scatterplot_axis_x_length / 2) + "," + (scatterplot._height - 20) + ")" | |
}) | |
scatterplot.title_x_updata = scatterplot.g_title_x.selectAll("." + scatterplot._c_g_title_x).data(["x轴/cm"]); | |
scatterplot.title_x_enter = scatterplot.title_x_updata.enter(); | |
scatterplot.title_x_exit = scatterplot.title_x_updata.exit(); | |
scatterplot.g_title_y = scatterplot.svg.append("g") | |
.attr({ | |
"class": scatterplot._c_g_grid_y_axis, | |
"id": scatterplot._id_g_grid_y_axis, | |
"transform": "translate(" + (100 - 12 - d3.max(maxlength)) + " ," + (scatterplot._height / 2) + ")" | |
}) | |
scatterplot.title_y_updata = scatterplot.g_title_y.selectAll("." + scatterplot._c_g_title_y).data(["y轴/个"]); | |
scatterplot.title_y_enter = scatterplot.title_y_updata.enter(); | |
scatterplot.title_y_exit = scatterplot.title_y_updata.exit(); | |
scatterplot.svg_legend_g = d3.selectAll("." + scatterplot._svg_legend_g_class)[0][0] == null && scatterplot.svg.append("g") | |
.attr("class", scatterplot._svg_legend_g_class) | |
.attr("id", scatterplot._svg_legend_g_id) | |
.attr("transform", scatterplot._placement_legend ? "translate(" + scatterplot._width + ",0)" : "translate(0,0)"); | |
scatterplot.g_grid_x_axis = scatterplot.g_grid_x_axis || scatterplot.svg.append("g") | |
.attr({ | |
"class": scatterplot._c_g_grid_x_axis, | |
"id": scatterplot._id_g_grid_x_axis, | |
"transform": "translate(" + (scatterplot._ToRight) + "," + (scatterplot._height - 50) + ")" | |
}) | |
scatterplot.g_grid_y_axis = scatterplot.g_grid_y_axis || scatterplot.svg.append("g") | |
.attr({ | |
"class": scatterplot._c_g_grid_y_axis, | |
"id": scatterplot._id_g_grid_y_axis, | |
"transform": "translate(" + (scatterplot._ToRight) + "," + (scatterplot._height - 50) + ")" | |
}) | |
title(scatterplot); | |
grid(scatterplot); | |
point(scatterplot) | |
legend(scatterplot); | |
function title(scatterplot) { | |
scatterplot.title_x_enter.append("text") | |
.attr({ | |
"class": scatterplot._c_title_x, | |
"id": scatterplot._id_title_x, | |
"x": 0, | |
"dx": 0, | |
"y": 0, | |
"dy": 0 | |
}) | |
.style("font-size", "12px") | |
.text(function(d) { | |
return d; | |
}) | |
scatterplot.title_y_enter.append("text") | |
.attr({ | |
"class": scatterplot._c_title_y, | |
"id": scatterplot._id_title_y, | |
"x": 0, | |
"dx": 0, | |
"y": 0, | |
"dy": 0 | |
}) | |
.style({ | |
"font-size": "12px", | |
"writing-mode": "tb" | |
}) | |
.text(function(d) { | |
return d; | |
}) | |
} | |
function grid(scatterplot) { | |
scatterplot.grid_x = scatterplot.g_grid_x_axis.call(d3.svg.axis().scale(scatterplot.axis_x_scale).innerTickSize(-(scatterplot._height - 100))) | |
scatterplot.grid_x.selectAll(".tick").selectAll("text").remove(); | |
scatterplot.grid_x.selectAll(".domain").remove() | |
scatterplot.grid_x.selectAll("line") | |
.attr("stroke-opacity", scatterplot._showbackground_x ? 1 : 0) | |
.style("stroke-dasharray", [2, 1]) | |
scatterplot.grid_y = scatterplot.g_grid_y_axis.call(d3.svg.axis().scale(scatterplot.axis_y_scale).innerTickSize(-(scatterplot._scatterplot_axis_x_length)).orient("left")) | |
scatterplot.grid_y.selectAll(".tick").selectAll("text").remove(); | |
scatterplot.grid_y.selectAll(".domain").remove() | |
scatterplot.grid_y.selectAll("line") | |
.style("stroke-opacity", scatterplot._showbackground_y ? 0.5 : 0) | |
.style("stroke-dasharray", [2, 1]) | |
} | |
function point(scatterplot) { | |
scatterplot.svg_point_updata = scatterplot.svg.selectAll("#" + scatterplot._svg_point_class).data(scatterplot._data_.map(function(d) { | |
return d; | |
})) | |
scatterplot.svg_point_enter = scatterplot.svg_point_updata.enter(); | |
scatterplot.svg_point_exit = scatterplot.svg_point_updata.exit(); | |
scatterplot.svg_point_enter | |
.append("g") | |
.attr("class", function(d, i) { | |
return scatterplot._svg_point_g_class + i; | |
}) | |
.attr("id", function(d, i) { | |
return scatterplot._svg_point_g_id + i; | |
}) | |
.attr("fill", function(d) { | |
return scatterplot._scalecolor(d.name) | |
}) | |
.attr("opacity", 0.6) | |
.attr("transform", "translate(" + (scatterplot._ToRight ) + "," + (scatterplot._height - 50 ) + ")") | |
.selectAll("circle") | |
.data(function(d, i) { | |
return d; | |
}) | |
.enter() | |
.append("circle") | |
.attr({ | |
"class": function(d, i) { | |
return scatterplot._svg_point_class + d.i + i; | |
}, | |
"id": function(d, i) { | |
return scatterplot._svg_point_id + d.i + i; | |
}, | |
"cx": function(d) { | |
return scatterplot._bottomAxis == "x" ? scatterplot.axis_x_scale(d[0]) : scatterplot.axis_x_scale(d[1]) | |
}, | |
"cy": function(d, i) { | |
return scatterplot._bottomAxis == "x" ? scatterplot.axis_y_scale(d[1]) : scatterplot.axis_y_scale(d[0]) | |
}, | |
"r": function(d, i) { | |
return scatterplot._svg_type == 1 ? "5px" : scatterplot.qipao_scale(d.weight); | |
} | |
}) | |
.on("mousemove", function(d) { | |
scatterplot.tool_window.html("type:" + d.name + "<br />" + "x:" + d[0] + "<br />" + "y:" + d[1]) | |
.style("left", (d3.event.pageX) + "px") | |
.style("top", (d3.event.pageY + 20) + "px") | |
.style("opacity", 1.0) | |
}) | |
.on("mouseout", function(d) { | |
scatterplot.tool_window | |
.html("") | |
.style("left", "0px") | |
.style("top", "0px") | |
.style("opacity", 0.0) | |
}) | |
} | |
function legend(scatterplot) { | |
scatterplot.svg_legend_logo_updata = scatterplot.svg_legend_g.selectAll("#" + scatterplot._svg_legend_logo_class).data(scatterplot._data_) | |
scatterplot.svg_legend_logo_enter = scatterplot.svg_legend_logo_updata.enter(); | |
scatterplot.svg_legend_logo_exit = scatterplot.svg_legend_logo_updata.exit(); | |
scatterplot.svg_legend_logo_enter.append("circle") | |
.attr({ | |
"class": function(d, i) { | |
return scatterplot._svg_legend_logo_class + i; | |
}, | |
"id": function(d, i) { | |
return scatterplot._svg_legend_logo_id + i; | |
}, | |
"cx": function(d, i) { | |
return scatterplot._placement_legend ? (-10) : 110 + i * ((scatterplot._width - 100) / scatterplot._data_.length); | |
}, | |
"cy": function(d, i) { | |
return scatterplot._placement_legend ? (20 * i + 10) : 10; | |
}, | |
"fill": function(d, i) { | |
return scatterplot._scalecolor(d.name); | |
}, | |
"r": function(d, i) { | |
return "5px"; | |
} | |
}); | |
scatterplot.svg_legend_text_updata = scatterplot.svg_legend_g.selectAll("#" + scatterplot._svg_legend_text_class).data(scatterplot._data_) | |
scatterplot.svg_legend_text_enter = scatterplot.svg_legend_text_updata.enter(); | |
scatterplot.svg_legend_text_exit = scatterplot.svg_legend_text_updata.exit(); | |
scatterplot.svg_legend_text_enter.append("text") | |
.attr({ | |
"class": function(d, i) { | |
return scatterplot._svg_legend_text_class + i; | |
}, | |
"id": function(d, i) { | |
return scatterplot._svg_legend_text_id + i; | |
}, | |
"x": function(d, i) { | |
return scatterplot._placement_legend ? -(10 + 5) : 115 + i * ((scatterplot._width - 100) / scatterplot._data_.length); | |
}, | |
"y": function(d, i) { | |
return scatterplot._placement_legend ? (20 * i + 10 + 5) : 10 + 5; | |
} | |
}) | |
.text(function(d, i) { | |
return d.name | |
}) | |
.style("text-anchor", scatterplot._placement_legend ? "end" : "start") | |
} | |
} | |
function Tool_scatterplot(scatterplot) { | |
scatterplot._scalecolor = d3.scale.category10(); | |
scatterplot.qipao_scale = scatterplot._svg_type == 2 && a(scatterplot); | |
function a(scatterplot) { | |
scale = d3.scale.linear(); | |
var max = [], | |
min = []; | |
scatterplot._data.map(function(d) { | |
max.push(d3.max(d.weight.map(function(d) { | |
return d | |
}))) | |
min.push(d3.min(d.weight.map(function(d) { | |
return d | |
}))) | |
}) | |
var domain = [d3.min(min), d3.max(max)] | |
scale.domain(domain); | |
scale.rangeRound([5, 10]) | |
return scale; | |
} | |
} | |
function DataPretreatment_scatterplot(scatterplot) { | |
scatterplot._data_ = []; | |
scatterplot._data.map(function(d, i) { | |
var a = []; | |
d.value.map(function(q, j) { | |
var b = q; | |
b.name = d.name; | |
b.weight = d.weight[j]; | |
d.i = i; | |
a.push(b); | |
}) | |
a.name = d.name; | |
scatterplot._data_.push(a); | |
}) | |
scatterplot._scalecolor(); | |
Package_scale(scatterplot, "x"); | |
Package_scale(scatterplot, "y"); | |
} | |
function Package_scatterplot(scatterplot) { | |
} | |
function Package_scale(scatterplot, object) { | |
var scale; | |
var array = ["_scale_type_" + object, | |
"_scale_type_" + object + "_ordinal_type", | |
"_scale_type_" + object + "_range_type_range_array", | |
"_scale_type_" + object + "_range_type_min", | |
"_scale_type_" + object + "_range_type_max", | |
"_scale_type_" + object + "_range_type_Points_n", | |
"_scale_type_" + object + "_range_type_Bands_p", | |
"_scale_type_" + object + "_range_type_Bands_o", | |
"_axis_" + object + "_data", | |
"axis_" + object + "_scale", | |
"axis_" + object, | |
"_showbackground_" + object, | |
"axis_" + object + "_grid" | |
]; | |
if(scatterplot[array[0]] == 1) { | |
scale = d3.scale.linear(); | |
var max = [], | |
min = []; | |
scatterplot._data_.map(function(d) { | |
max.push(d3.max(d.map(function(d) { | |
return d[object == scatterplot._bottomAxis ? 0 : 1] | |
}))) | |
min.push(d3.min(d.map(function(d) { | |
return d[object == scatterplot._bottomAxis ? 0 : 1] | |
}))) | |
}) | |
var domain = object == scatterplot._bottomAxis ? [d3.min(min), d3.max(max)] : [d3.min(min), d3.max(max)] | |
var ceshi = domain.map(function(d, i) { | |
if(i == 0) { | |
var ii = 0; | |
var f = d >= 0 ? 1 : -1; | |
var num = Math.abs(d); | |
while(num >= 10) { | |
num = (num - (num % 10)) / 10; | |
ii++; | |
} | |
var c = Math.pow(10, ii) | |
var o = Math.ceil(Math.abs(d) / c) | |
var shu = f > 0 ? (c == 1 ? 0 : f * o * c) : (c == 1 ? 10 * f : f * o * c); | |
return shu; | |
} else { | |
var ii = 0; | |
var f = d >= 0 ? 1 : -1; | |
var num = Math.abs(d); | |
while(num >= 10) { | |
num = (num - (num % 10)) / 10; | |
ii++; | |
} | |
var c = Math.pow(10, ii) | |
var o = Math.ceil(Math.abs(d) / c) | |
var shu = f > 0 ? (c == 1 ? 10 * f : f * o * c) : (c == 1 ? 0 : f * o * c); | |
return shu; | |
} | |
}); | |
scale.domain(ceshi); | |
scale.rangeRound([(object == "x" ? 1 : -1) * scatterplot[array[3]], (object == "x" ? 1 : -1) * scatterplot[array[4]]]) | |
} else if(scatterplot[array[0]] == 2) { | |
scale = d3.scale.ordinal(); | |
scatterplot[array[8]] = Filterthedata(scatterplot._data, "value").map(function(d, i) { | |
return object == "x" ? d[0].name : d[0].value | |
}) | |
if(scatterplot[array[1]] == 1) { | |
scale.range(scatterplot[array[2]]); | |
} else if(scatterplot[array[1]] == 2) { | |
scale.rangeRoundPoints([(object == "x" ? 1 : -1) * scatterplot[array[3]], (object == "x" ? 1 : -1) * scatterplot[array[4]]], scatterplot[array[5]]); | |
} else { | |
scale.rangeRoundBands([(object == "x" ? 1 : -1) * scatterplot[array[3]], (object == "x" ? 1 : -1) * scatterplot[array[4]]], scatterplot[array[6]], scatterplot[array[7]]) | |
} | |
scale.domain(scatterplot[array[8]]); | |
} else { | |
scale = d3.time.scale(); | |
} | |
scatterplot[array[9]] = scale; | |
scatterplot[array[10]] = d3.svg.axis() | |
.scale(scatterplot[array[9]]) | |
.tickSize(1) | |
.innerTickSize(3) | |
.orient(object == "x" ? "bottom" : "left"); | |
} | |
function Filterthedata(array, str) { | |
var a = str.split("-"); | |
a.map(function(d, i) { | |
array = array[d]; | |
}) | |
return array; | |
} | |
function Detect_function_scatterplot(object_lh) { | |
return typeof(object_lh) == "undefined"; | |
} | |
function SetId_scatterplot(scatterplot) { | |
scatterplot._svgid = scatterplot._labelid + "svg"; | |
scatterplot._axis_x_class = scatterplot._labelid + "axis_x_class"; | |
scatterplot._axis_y_class = scatterplot._labelid + "axis_y_class"; | |
scatterplot._c_g_title_x = scatterplot._labelid + "_c_g_title_x" | |
scatterplot._id_g_title_x = scatterplot._labelid + "_id_g_title_x" | |
scatterplot._c_title_x = scatterplot._labelid + "_c_title_x" | |
scatterplot._id_title_x = scatterplot._labelid + "_id_title_x" | |
scatterplot._c_g_title_y = scatterplot._labelid + "_c_g_title_y" | |
scatterplot._id_g_title_y = scatterplot._labelid + "_id_g_title_y" | |
scatterplot._c_title_y = scatterplot._labelid + "_c_title_y" | |
scatterplot._id_title_y = scatterplot._labelid + "_id_title_y" | |
scatterplot._c_g_grid_x_axis = scatterplot._labelid + "_c_g_grid_x_axis"; | |
scatterplot._id_g_grid_x_axis = scatterplot._labelid + "_id_g_grid_x_axis"; | |
scatterplot._c_g_grid_y_axis = scatterplot._labelid + "_c_g_grid_y_axis"; | |
scatterplot._id_g_grid_y_axis = scatterplot._labelid + "_id_g_grid_y_axis"; | |
scatterplot._c_grid_x_axis = scatterplot._labelid + "_c_grid_x_axis"; | |
scatterplot._id_grid_x_axis = scatterplot._labelid + "_id_grid_x_axis"; | |
scatterplot._c_grid_y_axis = scatterplot._labelid + "_c_grid_y_axis"; | |
scatterplot._id_grid_y_axis = scatterplot._labelid + "_id_grid_y_axis"; | |
scatterplot._svg_point_g_class = scatterplot._labelid + "point_g_class"; | |
scatterplot._svg_point_g_id = scatterplot._labelid + "point_g_id"; | |
scatterplot._svg_point_class = scatterplot._labelid + "point_class"; | |
scatterplot._svg_point_id = scatterplot._labelid + "point_id"; | |
scatterplot._svg_legend_g_class = scatterplot._labelid + "legend_g_class"; | |
scatterplot._svg_legend_g_id = scatterplot._labelid + "legend_g_id"; | |
scatterplot._svg_legend_logo_class = scatterplot._labelid + "legend_logo_class"; | |
scatterplot._svg_legend_logo_id = scatterplot._labelid + "legend_logo_id"; | |
scatterplot._svg_legend_text_class = scatterplot._labelid + "legend_text_class"; | |
scatterplot._svg_legend_text_id = scatterplot._labelid + "legend_text_id"; | |
scatterplot._c_tool_g = scatterplot._labelid + "_c_tool_g"; | |
scatterplot._id_tool_g = scatterplot._labelid + "_id_tool_g"; | |
scatterplot._c_tool_line = scatterplot._labelid + "_c_tool_line"; | |
scatterplot._id_tool_line = scatterplot._labelid + "_id_tool_line"; | |
scatterplot._c_tool_window = "Tooltip"; | |
scatterplot._id_tool_window = scatterplot._labelid + "PiesTooltip_id"; | |
} | |
return scatterplot; | |
}; | |
this.Scatterplot = Scatterplot; | |
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"name":"num","value":[[-1.2,5],[0.5,10],[1,1],[2,2],[3,3],[4.4,4],[5,5],[6,6],[7.5,1.5]],"weight":[9,8,9,8,9,8,9,8,1]}, | |
{"name":"num1","value":[[-1.1,5],[0.5,17],[1,6],[2,5],[3.5,4],[4,3],[5,2],[6,1],[7.5,3]],"weight":[1,2,1,1,2,2,1,3,20]}, | |
{"name":"num2","value":[[-1.6,5],[0.4,-3.4],[1,4],[2,5],[3,26],[4,7],[5.6,5],[6,4],[7.5,2]],"weight":[5,4,6,5,4,8,6,3,6]} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment