first commit
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - horizontal area
|
||||
*
|
||||
* Demo of area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-horizontal", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 10, 10, 50);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addCategoryAxis("x", "Month");
|
||||
x.addOrderRule("Date");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addMeasureAxis("y", "Unit Sales");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart
|
||||
.addSeries(null, dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Remove axis titles
|
||||
x.titleShape.remove();
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Remove axis titles
|
||||
x.titleShape.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - horizontal grouped area
|
||||
*
|
||||
* Demo of grouped area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-horizontal-grouped", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 10, 10, 45);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addCategoryAxis("x", ["Owner", "Month"]);
|
||||
x.addGroupOrderRule("Date");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addMeasureAxis("y", "Unit Sales");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart
|
||||
.addSeries("Owner", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
// Line weight
|
||||
s.lineWeight = 1;
|
||||
|
||||
// Area spacing
|
||||
s.barGap = 0.05;
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - horizontal stacked area
|
||||
*
|
||||
* Demo of stacked area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-horizontal-stacked", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 25, 10, 50);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addCategoryAxis("x", "Month");
|
||||
x.addOrderRule("Date");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addMeasureAxis("y", "Unit Sales");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart
|
||||
.addSeries("Channel", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
|
||||
// Add legend
|
||||
// ------------------------------
|
||||
|
||||
var myLegend = myChart.addLegend(0, 5, "100%", 0, "right");
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
// Legend font style
|
||||
myLegend.fontSize = "12";
|
||||
myLegend.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
// Remove axis titles
|
||||
x.titleShape.remove();
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
// Remove axis titles
|
||||
x.titleShape.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - horizontal grouped stacked area
|
||||
*
|
||||
* Demo of grouped stacked area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-horizontal-stacked-grouped", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 10, 180, 45);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addCategoryAxis("x", ["Owner", "Month"]);
|
||||
x.addGroupOrderRule("Date");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addMeasureAxis("y", "Unit Sales");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart
|
||||
.addSeries("SKU", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
// Line weight
|
||||
s.lineWeight = 1;
|
||||
|
||||
// Area spacing
|
||||
s.barGap = 0.05;
|
||||
|
||||
|
||||
// Add legend
|
||||
// ------------------------------
|
||||
|
||||
var myLegend = myChart.addLegend("100%", 0, 0, "100%", "right");
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
// Legend font style
|
||||
myLegend.fontSize = "12";
|
||||
myLegend.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - horizontal normalized stacked area
|
||||
*
|
||||
* Demo of normalized stacked area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-horizontal-stacked-normalized", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 25, 10, 50);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addCategoryAxis("x", "Month");
|
||||
x.addOrderRule("Date");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addPctAxis("y", "Unit Sales");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
myChart
|
||||
.addSeries("Channel", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
|
||||
// Add legend
|
||||
// ------------------------------
|
||||
|
||||
var myLegend = myChart.addLegend(0, 5, "100%", 0, "right");
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
// Legend font style
|
||||
myLegend.fontSize = "12";
|
||||
myLegend.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
// Remove axis titles
|
||||
x.titleShape.remove();
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
// Remove axis titles
|
||||
x.titleShape.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - vertical area
|
||||
*
|
||||
* Demo of area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-vertical", "100%", 500);
|
||||
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 5, 20, 40);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addMeasureAxis("x", "Unit Sales");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addCategoryAxis("y", "Month");
|
||||
y.addOrderRule("Date");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart
|
||||
.addSeries(null, dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - vertical grouped area
|
||||
*
|
||||
* Demo of grouped area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-vertical-grouped", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(70, 5, 20, 45);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addMeasureAxis("x", "Unit Sales");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addCategoryAxis("y", ["Owner", "Month"]);
|
||||
y.addGroupOrderRule("Date");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart
|
||||
.addSeries("Owner", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
// Line weight
|
||||
s.lineWeight = 1;
|
||||
|
||||
// Area spacing
|
||||
s.barGap = 0.05;
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - vertical stacked area
|
||||
*
|
||||
* Demo of stacked area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-vertical-stacked", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(55, 25, 20, 40);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addMeasureAxis("x", "Unit Sales");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addCategoryAxis("y", "Month");
|
||||
y.addOrderRule("Date");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
myChart
|
||||
.addSeries("Channel", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
|
||||
// Add legend
|
||||
// ------------------------------
|
||||
|
||||
var myLegend = myChart.addLegend(0, 5, "100%", 0, "left");
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
// Legend font style
|
||||
myLegend.fontSize = "12";
|
||||
myLegend.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,114 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - vertical grouped stacked area
|
||||
*
|
||||
* Demo of grouped stacked area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-vertical-stacked-grouped", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(70, 5, 180, 45);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addMeasureAxis("x", "Unit Sales");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addCategoryAxis("y", ["Owner", "Month"]);
|
||||
y.addGroupOrderRule("Date");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
var s = myChart.addSeries("SKU", dimple.plot.area);
|
||||
|
||||
// Line weight
|
||||
s.lineWeight = 1;
|
||||
|
||||
// Area spacing
|
||||
s.barGap = 0.05;
|
||||
|
||||
|
||||
// Add legend
|
||||
// ------------------------------
|
||||
|
||||
var myLegend = myChart.addLegend("100%", 0, 0, "100%", "right");
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
// Legend font style
|
||||
myLegend.fontSize = "12";
|
||||
myLegend.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
/* ------------------------------------------------------------------------------
|
||||
*
|
||||
* # Dimple.js - vertical normalized stacked area
|
||||
*
|
||||
* Demo of normalized stacked area chart. Data stored in .tsv file format
|
||||
*
|
||||
* Version: 1.0
|
||||
* Latest update: August 1, 2015
|
||||
*
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
$(function () {
|
||||
|
||||
// Construct chart
|
||||
var svg = dimple.newSvg("#dimple-area-vertical-stacked-normalized", "100%", 500);
|
||||
|
||||
|
||||
// Chart setup
|
||||
// ------------------------------
|
||||
|
||||
d3.tsv("assets/demo_data/dimple/demo_data.tsv", function (data) {
|
||||
|
||||
// Filter data
|
||||
data = dimple.filterData(data, "Owner", ["Aperture", "Black Mesa"])
|
||||
|
||||
|
||||
// Create chart
|
||||
// ------------------------------
|
||||
|
||||
// Define chart
|
||||
var myChart = new dimple.chart(svg, data);
|
||||
|
||||
// Set bounds
|
||||
myChart.setBounds(0, 0, "100%", "100%");
|
||||
|
||||
// Set margins
|
||||
myChart.setMargins(65, 25, 20, 40);
|
||||
|
||||
|
||||
// Create axes
|
||||
// ------------------------------
|
||||
|
||||
// Horizontal
|
||||
var x = myChart.addPctAxis("x", "Unit Sales");
|
||||
|
||||
// Vertical
|
||||
var y = myChart.addCategoryAxis("y", "Month");
|
||||
y.addOrderRule("Date");
|
||||
|
||||
|
||||
// Construct layout
|
||||
// ------------------------------
|
||||
|
||||
// Add area
|
||||
myChart
|
||||
.addSeries("Channel", dimple.plot.area)
|
||||
.interpolation = "basis";
|
||||
|
||||
|
||||
// Add legend
|
||||
// ------------------------------
|
||||
|
||||
var myLegend = myChart.addLegend(0, 5, "100%", 0, "right");
|
||||
|
||||
|
||||
// Add styles
|
||||
// ------------------------------
|
||||
|
||||
// Font size
|
||||
x.fontSize = "12";
|
||||
y.fontSize = "12";
|
||||
|
||||
// Font family
|
||||
x.fontFamily = "Roboto";
|
||||
y.fontFamily = "Roboto";
|
||||
|
||||
// Legend font style
|
||||
myLegend.fontSize = "12";
|
||||
myLegend.fontFamily = "Roboto";
|
||||
|
||||
|
||||
//
|
||||
// Draw chart
|
||||
//
|
||||
|
||||
// Draw
|
||||
myChart.draw();
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
|
||||
|
||||
// Resize chart
|
||||
// ------------------------------
|
||||
|
||||
// Add a method to draw the chart on resize of the window
|
||||
$(window).on('resize', resize);
|
||||
$('.sidebar-control').on('click', resize);
|
||||
|
||||
// Resize function
|
||||
function resize() {
|
||||
|
||||
// Redraw chart
|
||||
myChart.draw(0, true);
|
||||
|
||||
// Position legend text
|
||||
myLegend.shapes.selectAll("text").attr("dy", "1");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user