Merge pull request #124 from mistercrunch/colors

A more cohesive color strategy
This commit is contained in:
Maxime Beauchemin 2016-01-23 10:03:16 -08:00
commit 9fb708a74a
5 changed files with 26 additions and 25 deletions

View File

@ -1,3 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
rm -r _build rm -r _build
make html make html
cp -r _build/html/ ../../panoramix-docs/

View File

@ -3,6 +3,22 @@ var px = (function() {
var visualizations = {}; var visualizations = {};
var dashboard = undefined; var dashboard = undefined;
var bnbColors = [
//rausch hackb kazan babu lima beach barol
'#ff5a5f', '#7b0051', '#007A87', '#00d1c1', '#8ce071', '#ffb400', '#b4a76c',
'#ff8083', '#cc0086', '#00a1b3', '#00ffeb', '#bbedab', '#ffd266', '#cbc29a',
'#ff3339', '#ff1ab1', '#005c66', '#00b3a5', '#55d12e', '#b37e00', '#988b4e',
];
function colorBnb() {
// Color factory
var seen = {};
return function(s){
if(seen[s] === undefined)
seen[s] = Object.keys(seen).length;
return bnbColors[seen[s] % bnbColors.length];
};
}
function UTC(dttm){ function UTC(dttm){
return v = new Date(dttm.getUTCFullYear(), dttm.getUTCMonth(), dttm.getUTCDate(), dttm.getUTCHours(), dttm.getUTCMinutes(), dttm.getUTCSeconds()); return v = new Date(dttm.getUTCFullYear(), dttm.getUTCMonth(), dttm.getUTCDate(), dttm.getUTCHours(), dttm.getUTCMinutes(), dttm.getUTCSeconds());
} }
@ -27,10 +43,6 @@ var px = (function() {
return f(d); return f(d);
}; };
} }
colors = [
"#FF5A5F", "#007A87", "#7B0051", "#00D1C1", "#8CE071", "#FFB400",
"#FFAA91", "#B4A76C", "#9CA299", "#565A5C"
];
var Slice = function(data, dashboard){ var Slice = function(data, dashboard){
var timer; var timer;
@ -474,7 +486,8 @@ var px = (function() {
initExploreView: initExploreView, initExploreView: initExploreView,
initDashboardView: initDashboardView, initDashboardView: initDashboardView,
formatDate: formatDate, formatDate: formatDate,
colors: colors,
timeFormatFactory: timeFormatFactory, timeFormatFactory: timeFormatFactory,
colorBnb: colorBnb,
bnbColors: bnbColors,
} }
})(); })();

View File

@ -27,7 +27,7 @@ px.registerViz('word_cloud', function(slice) {
scale = d3.scale.linear() scale = d3.scale.linear()
.range(range) .range(range)
.domain(d3.extent(data, function(d) { return d.size; })); .domain(d3.extent(data, function(d) { return d.size; }));
var fill = d3.scale.category20(); var fill = px.colorBnb();
var layout = d3.layout.cloud() var layout = d3.layout.cloud()
.size(size) .size(size)
.words(data) .words(data)

View File

@ -107,26 +107,13 @@ class JSONEncodedDict(TypeDecorator):
class ColorFactory(object): class ColorFactory(object):
BNB_COLORS = [ BNB_COLORS = [
"#007A87", #rausch hackb kazan babu lima beach barol
"#00D1C1", '#ff5a5f', '#7b0051', '#007A87', '#00d1c1', '#8ce071', '#ffb400', '#b4a76c',
"#565A5C", '#ff8083', '#cc0086', '#00a1b3', '#00ffeb', '#bbedab', '#ffd266', '#cbc29a',
"#7B0051", '#ff3339', '#ff1ab1', '#005c66', '#00b3a5', '#55d12e', '#b37e00', '#988b4e',
"#898C8C",
"#8CE071",
"#4EDED2",
"#4FA3AB",
"#9CA299",
"#A14D83",
"#B4A76C",
"#C9BF97",
"#FF5A5F",
"#FFAA91",
"#FFB400",
"#FFC4B3",
"#FFCA4F",
] ]
def __init__(self, hash_based=True): def __init__(self, hash_based=False):
self.d = {} self.d = {}
self.hash_based = hash_based self.hash_based = hash_based

View File

@ -845,6 +845,7 @@ class DistributionBarViz(DistributionPieViz):
df = self.get_df() df = self.get_df()
series = df.to_dict('series') series = df.to_dict('series')
chart_data = [] chart_data = []
cf = utils.ColorFactory()
for name, ys in series.items(): for name, ys in series.items():
if df[name].dtype.kind not in "biufc": if df[name].dtype.kind not in "biufc":
continue continue
@ -855,7 +856,6 @@ class DistributionBarViz(DistributionPieViz):
series_title = ", ".join(name) series_title = ", ".join(name)
else: else:
series_title = ", ".join(name[1:]) series_title = ", ".join(name[1:])
cf = utils.ColorFactory()
d = { d = {
"key": series_title, "key": series_title,
"color": cf.get(series_title), "color": cf.get(series_title),