-
Notifications
You must be signed in to change notification settings - Fork 238
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
text, background, and chart colors wired in #382
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,17 @@ export function fillInSpec(spec: any, definition: any) { | |
if (definition.legend) { | ||
spec.legend.enabled = definition.legend.enable | ||
} | ||
// If we have styles.... | ||
if (definition.styles) { | ||
// Snag out styles for brevities sake | ||
const styles = definition.styles | ||
// If a backgroundColor.. | ||
if (styles.backgroundColor) { spec.backgroundColor = styles.backgroundColor } | ||
// If a backgroundAlpha.. | ||
if (styles.backgroundAlpha) { spec.backgroundAlpha = styles.backgroundAlpha } | ||
// If a textColor | ||
if (styles.textColor) { spec.color = styles.textColor } | ||
} | ||
|
||
// Iterate over datasets | ||
definition.datasets.forEach((dataset, d) => { | ||
|
@@ -102,6 +113,11 @@ export function fillInSpec(spec: any, definition: any) { | |
/* tslint:enable */ | ||
// TODO: map other fields besides value like color, size, etc | ||
|
||
// handle le color | ||
if (definition.styles && definition.styles.colors) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't expecting this to be needed so I'm curious what happens if you don't have this? is this for bar graph outlines? or needed for line charts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
graph.lineColor = definition.styles.colors[s] | ||
} | ||
|
||
graph.balloonText = `${graph.title} [[${spec.categoryField}]]: <b>[[${graph.valueField}]]</b>` | ||
|
||
// Group vs. stack | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,14 @@ export interface ISeries { | |
} | ||
|
||
export interface ILegend { | ||
enable: boolean | ||
enable?: boolean | ||
} | ||
|
||
export interface IStyles { | ||
backgroundColor?: string, | ||
backgroundAlpha?: number, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer What I don't like about that is that it's inconsistent w/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that is a good point. Realistically
|
||
colors?: string[], | ||
textColor?: string | ||
} | ||
|
||
export interface IDefinition { | ||
|
@@ -67,7 +74,8 @@ export interface IDefinition { | |
type?: string | ||
specification?: {} | ||
overrides?: {}, | ||
legend?: ILegend | ||
legend?: ILegend, | ||
styles?: IStyles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had planned to call this |
||
} | ||
|
||
export default class Chart { | ||
|
@@ -135,6 +143,12 @@ export default class Chart { | |
return this._definitionAccessor('legend', newLegend) | ||
} | ||
|
||
public styles(newStyles: IStyles): Chart | ||
public styles(): IStyles | ||
public styles(newStyles?: any): any { | ||
return this._definitionAccessor('styles', newStyles) | ||
} | ||
|
||
// data is read only | ||
public data() { | ||
return this._data | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls refrain from using words I don't know like "brevities"