-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
konstantin
committed
Dec 9, 2014
1 parent
2e82727
commit 8445022
Showing
17 changed files
with
371 additions
and
96 deletions.
There are no files selected for viewing
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.graphical-report__legend { | ||
padding: 20px; | ||
width: 140px; | ||
} | ||
.graphical-report__legend__title, | ||
.graphical-report__legend__item { | ||
margin: 0 0 10px 0; | ||
} | ||
.graphical-report__legend__title { | ||
text-transform: uppercase; | ||
font-weight: 600; | ||
font-size: 13px; | ||
} | ||
.graphical-report__legend__item { | ||
padding-left: 25px; | ||
position: relative; | ||
font-size: 13px; | ||
} | ||
.graphical-report__legend__item:disabled, | ||
.graphical-report__legend__item.disabled { | ||
color: #cccccc; | ||
} | ||
.graphical-report__legend__example { | ||
width: 15px; | ||
height: 15px; | ||
box-sizing: border-box; | ||
border: 1px solid transparent; | ||
border-radius: 50%; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
} | ||
.graphical-report__legend__item .color10-1 { | ||
background: #e41a1c; | ||
} | ||
.graphical-report__legend__item .color10-2 { | ||
background: #377eb8; | ||
} | ||
.graphical-report__legend__item .color10-3 { | ||
background: #4daf4a; | ||
} | ||
.graphical-report__legend__item .color10-4 { | ||
background: #984ea3; | ||
} | ||
.graphical-report__legend__item .color10-5 { | ||
background: #ff7f00; | ||
} | ||
.graphical-report__legend__item .color10-6 { | ||
background: #e9e964; | ||
} | ||
.graphical-report__legend__item .color10-7 { | ||
background: #a65628; | ||
} | ||
.graphical-report__legend__item .color10-8 { | ||
background: #f781bf; | ||
} | ||
.graphical-report__legend__item .color10-9 { | ||
background: #999999; | ||
} | ||
.graphical-report__legend__item .color10-10 { | ||
background: #222222; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(function (factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['tauCharts'], function (tauPlugins) { | ||
return factory(tauPlugins); | ||
}); | ||
} else if (typeof module === "object" && module.exports) { | ||
var tauPlugins = require('tauCharts'); | ||
module.exports = factory(); | ||
} else { | ||
factory(this.tauCharts); | ||
} | ||
})(function (tauCharts) { | ||
var dfs = function (node) { | ||
if (node.color && node.size) { | ||
return node; | ||
} | ||
var i, children = node.unit || [], child, found; | ||
for (i = 0; i < children.length; i += 1) { | ||
child = children[i]; | ||
found = dfs(child); | ||
if (found) { | ||
return found; | ||
} | ||
} | ||
}; | ||
var _ = tauCharts.api._; | ||
var legend = function () { | ||
return { | ||
init: function (chart) { | ||
if (this.isNeedLegend(chart)) { | ||
this._container = chart.insertToRightSidebar(this.containerTemplate); | ||
} | ||
}, | ||
isNeedLegend: function (chart) { | ||
var conf = chart.getConfig(); | ||
return Boolean(dfs(conf.spec.unit)); | ||
}, | ||
onUnitReady: function (chart, unit) { | ||
if (unit.type.indexOf('ELEMENT') !== -1) { | ||
this._unit = unit; | ||
} | ||
}, | ||
_getColorMap: function (chart) { | ||
var color = this._unit.options.color; | ||
var colorDimension = color.dimension; | ||
var data = chart.getData(); | ||
var keys = _.map(data, function (item) { | ||
return item[colorDimension]; | ||
}); | ||
// debugger | ||
return _.unique(keys).reduce(function (colorMap, item) { | ||
colorMap[item] = color.get(item); | ||
return colorMap; | ||
}, {}); | ||
}, | ||
containerTemplate: '<div class="graphical-report__legend"></div>', | ||
template: _.template('<div class="graphical-report__legend__title"><%=name%></div><%=items%>'), | ||
itemTemplate: _.template([ | ||
'<div class="graphical-report__legend__item">', | ||
'<div class="graphical-report__legend__example <%=color%>" ></div><%=value%>', | ||
'</div>' | ||
].join('')), | ||
onRender: function (chart) { | ||
if(this._container) { | ||
var items = _.map(this._getColorMap(chart), function (item, key) { | ||
return this.itemTemplate({color: item, value: key}); | ||
}, this).join(''); | ||
this._container.innerHTML = this.template({items: items, name: this._unit.options.color.dimension}); | ||
} | ||
}, | ||
render: function () { | ||
|
||
} | ||
|
||
}; | ||
}; | ||
tauCharts.api.plugins.add('legend', legend); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.