Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more cohesive color strategy #124

Merged
merged 1 commit into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
rm -r _build
make html
cp -r _build/html/ ../../panoramix-docs/
23 changes: 18 additions & 5 deletions panoramix/static/panoramix.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ var px = (function() {
var visualizations = {};
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){
return v = new Date(dttm.getUTCFullYear(), dttm.getUTCMonth(), dttm.getUTCDate(), dttm.getUTCHours(), dttm.getUTCMinutes(), dttm.getUTCSeconds());
}
Expand All @@ -27,10 +43,6 @@ var px = (function() {
return f(d);
};
}
colors = [
"#FF5A5F", "#007A87", "#7B0051", "#00D1C1", "#8CE071", "#FFB400",
"#FFAA91", "#B4A76C", "#9CA299", "#565A5C"
];

var Slice = function(data, dashboard){
var timer;
Expand Down Expand Up @@ -474,7 +486,8 @@ var px = (function() {
initExploreView: initExploreView,
initDashboardView: initDashboardView,
formatDate: formatDate,
colors: colors,
timeFormatFactory: timeFormatFactory,
colorBnb: colorBnb,
bnbColors: bnbColors,
}
})();
2 changes: 1 addition & 1 deletion panoramix/static/widgets/viz_wordcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ px.registerViz('word_cloud', function(slice) {
scale = d3.scale.linear()
.range(range)
.domain(d3.extent(data, function(d) { return d.size; }));
var fill = d3.scale.category20();
var fill = px.colorBnb();
var layout = d3.layout.cloud()
.size(size)
.words(data)
Expand Down
23 changes: 5 additions & 18 deletions panoramix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,13 @@ def process_result_value(self, value, dialect):

class ColorFactory(object):
BNB_COLORS = [
"#007A87",
"#00D1C1",
"#565A5C",
"#7B0051",
"#898C8C",
"#8CE071",
"#4EDED2",
"#4FA3AB",
"#9CA299",
"#A14D83",
"#B4A76C",
"#C9BF97",
"#FF5A5F",
"#FFAA91",
"#FFB400",
"#FFC4B3",
"#FFCA4F",
#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',
]

def __init__(self, hash_based=True):
def __init__(self, hash_based=False):
self.d = {}
self.hash_based = hash_based

Expand Down
2 changes: 1 addition & 1 deletion panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ def get_json_data(self):
df = self.get_df()
series = df.to_dict('series')
chart_data = []
cf = utils.ColorFactory()
for name, ys in series.items():
if df[name].dtype.kind not in "biufc":
continue
Expand All @@ -855,7 +856,6 @@ def get_json_data(self):
series_title = ", ".join(name)
else:
series_title = ", ".join(name[1:])
cf = utils.ColorFactory()
d = {
"key": series_title,
"color": cf.get(series_title),
Expand Down