FEATURE: charts will now use tertiary color (#6342)
This commit is contained in:
parent
90e67b671b
commit
bb93179609
|
@ -4,7 +4,6 @@ import loadScript from "discourse/lib/load-script";
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ["admin-report-chart"],
|
classNames: ["admin-report-chart"],
|
||||||
limit: 8,
|
limit: 8,
|
||||||
primaryColor: "rgb(0,136,204)",
|
|
||||||
total: 0,
|
total: 0,
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
|
@ -38,8 +37,8 @@ export default Ember.Component.extend({
|
||||||
data: chartData.map(d => Math.round(parseFloat(d.y))),
|
data: chartData.map(d => Math.round(parseFloat(d.y))),
|
||||||
backgroundColor: prevChartData.length
|
backgroundColor: prevChartData.length
|
||||||
? "transparent"
|
? "transparent"
|
||||||
: "rgba(200,220,240,0.3)",
|
: model.secondary_color,
|
||||||
borderColor: this.get("primaryColor")
|
borderColor: model.primary_color
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -47,7 +46,7 @@ export default Ember.Component.extend({
|
||||||
if (prevChartData.length) {
|
if (prevChartData.length) {
|
||||||
data.datasets.push({
|
data.datasets.push({
|
||||||
data: prevChartData.map(d => Math.round(parseFloat(d.y))),
|
data: prevChartData.map(d => Math.round(parseFloat(d.y))),
|
||||||
borderColor: this.get("primaryColor"),
|
borderColor: model.primary_color,
|
||||||
borderDash: [5, 5],
|
borderDash: [5, 5],
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { renderAvatar } from "discourse/helpers/user-avatar";
|
||||||
|
|
||||||
// Change this line each time report format change
|
// Change this line each time report format change
|
||||||
// and you want to ensure cache is reset
|
// and you want to ensure cache is reset
|
||||||
export const SCHEMA_VERSION = 2;
|
export const SCHEMA_VERSION = 3;
|
||||||
|
|
||||||
const Report = Discourse.Model.extend({
|
const Report = Discourse.Model.extend({
|
||||||
average: false,
|
average: false,
|
||||||
|
|
|
@ -3,14 +3,14 @@ require_dependency 'topic_subtype'
|
||||||
class Report
|
class Report
|
||||||
# Change this line each time report format change
|
# Change this line each time report format change
|
||||||
# and you want to ensure cache is reset
|
# and you want to ensure cache is reset
|
||||||
SCHEMA_VERSION = 2
|
SCHEMA_VERSION = 3
|
||||||
|
|
||||||
attr_accessor :type, :data, :total, :prev30Days, :start_date,
|
attr_accessor :type, :data, :total, :prev30Days, :start_date,
|
||||||
:end_date, :category_id, :group_id, :labels, :async,
|
:end_date, :category_id, :group_id, :labels, :async,
|
||||||
:prev_period, :facets, :limit, :processing, :average, :percent,
|
:prev_period, :facets, :limit, :processing, :average, :percent,
|
||||||
:higher_is_better, :icon, :modes, :category_filtering,
|
:higher_is_better, :icon, :modes, :category_filtering,
|
||||||
:group_filtering, :prev_data, :prev_start_date, :prev_end_date,
|
:group_filtering, :prev_data, :prev_start_date, :prev_end_date,
|
||||||
:dates_filtering, :error
|
:dates_filtering, :error, :primary_color, :secondary_color
|
||||||
|
|
||||||
def self.default_days
|
def self.default_days
|
||||||
30
|
30
|
||||||
|
@ -29,6 +29,8 @@ class Report
|
||||||
@modes = [:table, :chart]
|
@modes = [:table, :chart]
|
||||||
@prev_data = nil
|
@prev_data = nil
|
||||||
@dates_filtering = true
|
@dates_filtering = true
|
||||||
|
@primary_color = rgba_color(ColorScheme.hex_for_name('tertiary'))
|
||||||
|
@secondary_color = rgba_color(ColorScheme.hex_for_name('tertiary'), 0.1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.cache_key(report)
|
def self.cache_key(report)
|
||||||
|
@ -87,6 +89,8 @@ class Report
|
||||||
prev30Days: self.prev30Days,
|
prev30Days: self.prev30Days,
|
||||||
dates_filtering: self.dates_filtering,
|
dates_filtering: self.dates_filtering,
|
||||||
report_key: Report.cache_key(self),
|
report_key: Report.cache_key(self),
|
||||||
|
primary_color: self.primary_color,
|
||||||
|
secondary_color: self.secondary_color,
|
||||||
labels: labels || [
|
labels: labels || [
|
||||||
{
|
{
|
||||||
type: :date,
|
type: :date,
|
||||||
|
@ -1167,4 +1171,20 @@ class Report
|
||||||
report.data << revision
|
report.data << revision
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def hex_to_rgbs(hex_color)
|
||||||
|
hex_color = hex_color.gsub('#', '')
|
||||||
|
rgbs = hex_color.scan(/../)
|
||||||
|
rgbs
|
||||||
|
.map! { |color| color.hex }
|
||||||
|
.map! { |rgb| rgb.to_i }
|
||||||
|
end
|
||||||
|
|
||||||
|
def rgba_color(hex, opacity = 1)
|
||||||
|
rgbs = hex_to_rgbs(hex)
|
||||||
|
|
||||||
|
"rgba(#{rgbs.join(',')},#{opacity})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue