Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
charts
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
charts
Commits
63faa7d9
Commit
63faa7d9
authored
15 years ago
by
Bruno Massa
Browse files
Options
Downloads
Patches
Plain Diff
Internals:
* Views integration now works after the internal data modification
parent
6c637196
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
charts.admin.inc
+38
-32
38 additions, 32 deletions
charts.admin.inc
views/charts_plugin_style_chart.inc
+20
-10
20 additions, 10 deletions
views/charts_plugin_style_chart.inc
with
58 additions
and
42 deletions
charts.admin.inc
+
38
−
32
View file @
63faa7d9
...
@@ -21,28 +21,30 @@ function _charts_color_form_complete(&$form, $default) {
...
@@ -21,28 +21,30 @@ function _charts_color_form_complete(&$form, $default) {
'#title'
=>
t
(
'Color'
),
'#title'
=>
t
(
'Color'
),
'#tree'
=>
TRUE
'#tree'
=>
TRUE
);
);
$form
[
'color'
][
'color_palette
s
'
]
=
array
(
$form
[
'color'
][
'color_palette'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'Color palettes'
),
'#title'
=>
t
(
'Color palettes'
),
'#options'
=>
$default
[
'#color_palettes'
],
'#options'
=>
$default
[
'#color_palettes'
],
'#default_value'
=>
$default
[
'#color_palette'
],
'#default_value'
=>
$default
[
'#color_palette'
],
);
);
$form
[
'color'
][
'background'
]
=
array
(
$form
[
'color'
][
'background'
]
=
array
(
'#type'
=>
$field_type
,
'#title'
=>
t
(
'Background'
),
'#default_value'
=>
$default
[
'#color'
][
'background'
],
// '#colorpicker' => 'colorpicker',
// '#colorpicker' => 'colorpicker',
'#default_value'
=>
$default
[
'#color'
][
'background'
],
'#title'
=>
t
(
'Background'
),
'#type'
=>
$field_type
,
);
);
$form
[
'color'
][
'text'
]
=
array
(
$form
[
'color'
][
'text'
]
=
array
(
'#type'
=>
$field_type
,
'#title'
=>
t
(
'Text'
),
'#default_value'
=>
$default
[
'#color'
][
'text'
],
'#default_value'
=>
$default
[
'#color'
][
'text'
],
'#required'
=>
TRUE
,
'#title'
=>
t
(
'Text'
),
'#type'
=>
$field_type
,
);
);
for
(
$series
=
0
;
$series
<
8
;
$series
++
)
{
for
(
$series
=
0
;
$series
<
8
;
$series
++
)
{
$form
[
'color'
][
$series
]
=
array
(
$form
[
'color'
][
$series
]
=
array
(
'#type'
=>
$field_type
,
'#title'
=>
t
(
'Series %serie'
,
array
(
'%serie'
=>
$series
+
1
)),
'#default_value'
=>
$default
[
'#color'
][
$series
],
'#default_value'
=>
$default
[
'#color'
][
$series
],
'#required'
=>
TRUE
,
'#title'
=>
t
(
'Series %serie'
,
array
(
'%serie'
=>
$series
+
1
)),
'#type'
=>
$field_type
,
);
);
}
}
...
@@ -57,11 +59,12 @@ function _charts_color_form_complete(&$form, $default) {
...
@@ -57,11 +59,12 @@ function _charts_color_form_complete(&$form, $default) {
*/
*/
function
_charts_color_form_simple
(
&
$form
,
$settings
)
{
function
_charts_color_form_simple
(
&
$form
,
$settings
)
{
// Load some color palettes
// Load some color palettes
$form
[
'color_palettes'
]
=
array
(
$form
[
'color_palette'
]
=
array
(
'#type'
=>
'select'
,
'#title'
=>
t
(
'Color palettes'
),
'#options'
=>
$settings
[
'#color_palettes'
],
'#default_value'
=>
$settings
[
'#color_palette'
],
'#default_value'
=>
$settings
[
'#color_palette'
],
'#options'
=>
$settings
[
'#color_palettes'
],
'#required'
=>
TRUE
,
'#title'
=>
t
(
'Color palettes'
),
'#type'
=>
'select'
,
);
);
}
}
...
@@ -74,25 +77,24 @@ function _charts_color_form_simple(&$form, $settings) {
...
@@ -74,25 +77,24 @@ function _charts_color_form_simple(&$form, $settings) {
* HTML. The generic Chart example
* HTML. The generic Chart example
*/
*/
function
_charts_example
()
{
function
_charts_example
()
{
// if (empty($data)) {
// This will hold the example chart
// This will hold the example chart
// Since the chart is an example, we should provide
// Since the chart is an example, we should provide
// and example data.
// and example data.
$data
[]
=
array
(
$data
[]
=
array
(
'#legend'
=>
'Profit'
,
'#legend'
=>
'Profit'
,
array
(
'#value'
=>
35
,
'#label'
=>
t
(
'Jan'
)),
array
(
'#value'
=>
35
,
'#label'
=>
t
(
'Jan'
)),
array
(
'#value'
=>
25
,
'#label'
=>
t
(
'Feb'
)),
array
(
'#value'
=>
25
,
'#label'
=>
t
(
'Feb'
)),
array
(
'#value'
=>
75
,
'#label'
=>
t
(
'Mar'
)),
array
(
'#value'
=>
75
,
'#label'
=>
t
(
'Mar'
)),
array
(
'#value'
=>
50
,
'#label'
=>
t
(
'Apr'
)),
array
(
'#value'
=>
50
,
'#label'
=>
t
(
'Apr'
)),
array
(
'#value'
=>
23
,
'#label'
=>
t
(
'May'
)),
array
(
'#value'
=>
23
,
'#label'
=>
t
(
'May'
)),
array
(
'#value'
=>
12
,
'#label'
=>
t
(
'Jun'
)),
array
(
'#value'
=>
12
,
'#label'
=>
t
(
'Jun'
)),
);
);
$data
[]
=
array
(
$data
[]
=
array
(
'#legend'
=>
'Revenue'
,
'#legend'
=>
'Revenue'
,
10
,
20
,
55
,
72
,
45
,
50
10
,
20
,
55
,
72
,
45
,
50
);
);
$data
[
'#title'
]
=
'Testing Chart'
;
$data
[
'#title'
]
=
'Testing Chart'
;
// }
return
charts_chart
(
$data
);
return
charts_chart
(
$data
);
}
}
...
@@ -143,6 +145,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
...
@@ -143,6 +145,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
$form
[
'plugin'
]
=
array
(
$form
[
'plugin'
]
=
array
(
'#default_value'
=>
$default
[
'#plugin'
],
'#default_value'
=>
$default
[
'#plugin'
],
'#options'
=>
$default
[
'#plugins'
],
'#options'
=>
$default
[
'#plugins'
],
'#required'
=>
TRUE
,
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'Chart plugin'
),
'#title'
=>
t
(
'Chart plugin'
),
);
);
...
@@ -151,6 +154,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
...
@@ -151,6 +154,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
$form
[
'type'
]
=
array
(
$form
[
'type'
]
=
array
(
'#default_value'
=>
$default
[
'#type'
],
'#default_value'
=>
$default
[
'#type'
],
'#options'
=>
$default
[
'#types'
],
'#options'
=>
$default
[
'#types'
],
'#required'
=>
TRUE
,
'#type'
=>
'radios'
,
'#type'
=>
'radios'
,
'#title'
=>
t
(
'Chart type'
),
'#title'
=>
t
(
'Chart type'
),
);
);
...
@@ -158,6 +162,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
...
@@ -158,6 +162,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
$form
[
'width'
]
=
array
(
$form
[
'width'
]
=
array
(
'#default_value'
=>
$default
[
'#width'
],
'#default_value'
=>
$default
[
'#width'
],
'#description'
=>
t
(
'The chart width, in pixels'
),
'#description'
=>
t
(
'The chart width, in pixels'
),
'#required'
=>
TRUE
,
'#size'
=>
8
,
'#size'
=>
8
,
'#type'
=>
'textfield'
,
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Width'
),
'#title'
=>
t
(
'Width'
),
...
@@ -165,6 +170,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
...
@@ -165,6 +170,7 @@ function _charts_settings_form(&$form, $default = array(), $options = array()) {
$form
[
'height'
]
=
array
(
$form
[
'height'
]
=
array
(
'#default_value'
=>
$default
[
'#height'
],
'#default_value'
=>
$default
[
'#height'
],
'#description'
=>
t
(
'The chart height, in pixels'
),
'#description'
=>
t
(
'The chart height, in pixels'
),
'#required'
=>
TRUE
,
'#size'
=>
8
,
'#size'
=>
8
,
'#type'
=>
'textfield'
,
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Height'
),
'#title'
=>
t
(
'Height'
),
...
@@ -215,7 +221,7 @@ function _charts_settings_page_submit(&$form, &$form_state) {
...
@@ -215,7 +221,7 @@ function _charts_settings_page_submit(&$form, &$form_state) {
unset
(
$settings
[
'op'
]);
unset
(
$settings
[
'op'
]);
// Unwanted values
// Unwanted values
unset
(
$settings
[
'color'
][
'color_palette
s
'
]);
unset
(
$settings
[
'color'
][
'color_palette'
]);
// Include a # sign in all attributes, because it will make the
// Include a # sign in all attributes, because it will make the
// merge between the chart data and the defaults easier on every
// merge between the chart data and the defaults easier on every
...
...
This diff is collapsed.
Click to expand it.
views/charts_plugin_style_chart.inc
+
20
−
10
View file @
63faa7d9
...
@@ -35,7 +35,8 @@ class charts_plugin_style_chart extends views_plugin_style {
...
@@ -35,7 +35,8 @@ class charts_plugin_style_chart extends views_plugin_style {
// Add the Chart Settings form
// Add the Chart Settings form
module_load_include
(
'admin.inc'
,
'charts'
);
module_load_include
(
'admin.inc'
,
'charts'
);
$form
[
'charts'
][
'#tree'
]
=
TRUE
;
// Get chart settings from options form.
_charts_settings_form
(
$form
[
'charts'
],
$this
->
options
[
'charts'
]);
_charts_settings_form
(
$form
[
'charts'
],
$this
->
options
[
'charts'
]);
$form
[
'show_legend'
]
=
array
(
$form
[
'show_legend'
]
=
array
(
...
@@ -48,7 +49,7 @@ class charts_plugin_style_chart extends views_plugin_style {
...
@@ -48,7 +49,7 @@ class charts_plugin_style_chart extends views_plugin_style {
// Views Calc related fields
// Views Calc related fields
$form
[
'aggregation_field'
]
=
array
(
$form
[
'aggregation_field'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'
Aggregation
field'
),
'#title'
=>
t
(
'
Legend
field'
),
'#options'
=>
$this
->
aggregated_field_options
(),
'#options'
=>
$this
->
aggregated_field_options
(),
'#default_value'
=>
$this
->
options
[
'aggregation_field'
],
'#default_value'
=>
$this
->
options
[
'aggregation_field'
],
'#description'
=>
t
(
'Select a field to aggreagate the results on.'
)
'#description'
=>
t
(
'Select a field to aggreagate the results on.'
)
...
@@ -57,25 +58,36 @@ class charts_plugin_style_chart extends views_plugin_style {
...
@@ -57,25 +58,36 @@ class charts_plugin_style_chart extends views_plugin_style {
// update Multiple to TRUE if that changes.
// update Multiple to TRUE if that changes.
$form
[
'calc_fields'
]
=
array
(
$form
[
'calc_fields'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'
Comput
ation field'
),
'#title'
=>
t
(
'
Oper
ation field'
),
'#options'
=>
$this
->
aggregated_field_options
(),
'#options'
=>
$this
->
aggregated_field_options
(),
'#default_value'
=>
$this
->
calc_fields
(),
'#default_value'
=>
$this
->
calc_fields
(),
'#multiple'
=>
FALSE
,
'#multiple'
=>
FALSE
,
'#description'
=>
t
(
'Select field to perform computations on.'
)
'#description'
=>
t
(
'Select field to perform computations on.'
)
);
);
$form
[
'calc'
]
=
array
(
$form
[
'calc'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'
Computation to perform
'
),
'#title'
=>
t
(
'
Operation
'
),
'#options'
=>
$this
->
calc_options
(),
'#options'
=>
$this
->
calc_options
(),
'#default_value'
=>
$this
->
options
[
'calc'
],
'#default_value'
=>
$this
->
options
[
'calc'
],
);
);
$form
[
'precision'
]
=
array
(
$form
[
'precision'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'Precision'
),
'#title'
=>
t
(
'Precision'
),
'#options'
=>
range
(
0
,
4
),
'#options'
=>
range
(
0
,
4
),
'#default_value'
=>
$this
->
options
[
'precision'
],
'#default_value'
=>
$this
->
options
[
'precision'
],
'#description'
=>
t
(
'Decimal points to use in computed values.'
),
'#description'
=>
t
(
'Decimal points to use in computed values.'
),
);
);
}
/**
* Generate a form for setting options.
*/
function
options_submit
(
&
$form
,
&
$form_state
)
{
$chart
=
&
$form_state
[
'values'
][
'style_options'
][
'charts'
];
foreach
(
element_children
(
$chart
)
as
$index
)
{
$chart
[
'#'
.
$index
]
=
$chart
[
$index
];
unset
(
$chart
[
$index
]);
}
}
}
/**
/**
...
@@ -122,9 +134,7 @@ class charts_plugin_style_chart extends views_plugin_style {
...
@@ -122,9 +134,7 @@ class charts_plugin_style_chart extends views_plugin_style {
*/
*/
function
render
()
{
function
render
()
{
// Get chart settings from options form.
// Get chart settings from options form.
foreach
(
$this
->
options
[
'charts'
]
as
$index
=>
$value
)
{
$chart
=
$this
->
options
[
'charts'
];
$chart
[
'#'
.
$index
]
=
$value
;
}
// Get values from rows.
// Get values from rows.
foreach
(
$this
->
calc_fields
()
as
$calc
)
{
foreach
(
$this
->
calc_fields
()
as
$calc
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment