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
390084f1
Commit
390084f1
authored
11 years ago
by
Nathan Haug
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2051709: ID is used and not the field value.
parent
618e3559
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
views/charts_plugin_style_chart.inc
+20
-13
20 additions, 13 deletions
views/charts_plugin_style_chart.inc
with
20 additions
and
13 deletions
views/charts_plugin_style_chart.inc
+
20
−
13
View file @
390084f1
...
...
@@ -91,8 +91,10 @@ class charts_plugin_style_chart extends views_plugin_style {
// Calculate the labels field alias.
$field_handlers
=
$this
->
display
->
handler
->
get_handlers
(
'field'
);
$label_field
=
FALSE
;
$label_field_key
=
NULL
;
if
(
$this
->
options
[
'label_field'
]
&&
array_key_exists
(
$this
->
options
[
'label_field'
],
$field_handlers
))
{
$label_field
=
$field_handlers
[
$this
->
options
[
'label_field'
]];
$label_field_key
=
$this
->
options
[
'label_field'
];
}
$data_field_options
=
array_filter
(
$this
->
options
[
'data_fields'
]);
$data_fields
=
array
();
...
...
@@ -101,6 +103,10 @@ class charts_plugin_style_chart extends views_plugin_style {
$data_fields
[
$field_key
]
=
$field_handlers
[
$field_key
];
}
}
// Do not allow the label field to be used as a data field.
if
(
isset
(
$data_fields
[
$label_field_key
]))
{
unset
(
$data_fields
[
$label_field_key
]);
}
$chart_id
=
$this
->
view
->
name
.
'__'
.
$this
->
view
->
current_display
;
$chart
=
array
(
...
...
@@ -121,15 +127,17 @@ class charts_plugin_style_chart extends views_plugin_style {
$chart_type_info
=
chart_get_type
(
$this
->
options
[
'type'
]);
if
(
$chart_type_info
[
'axis'
]
===
CHARTS_SINGLE_AXIS
)
{
$data_field
=
reset
(
$data_fields
);
$data_field_key
=
key
(
$data_fields
);
$data_field
=
$data_fields
[
$data_field_key
];
$data
=
array
();
foreach
(
$this
->
view
->
result
as
$row
)
{
$renders
=
$this
->
render_fields
(
$this
->
view
->
result
);
foreach
(
$renders
as
$row_number
=>
$row
)
{
$data_row
=
array
();
if
(
$label_field
)
{
$data_row
[]
=
$
label_field
->
render
(
$row
)
;
if
(
$label_field
_key
)
{
$data_row
[]
=
$
renders
[
$row_number
][
$label_field_key
]
;
}
$data_row
[]
=
(
in
t
)
$r
ow
->
{
$data_field
->
field_alias
}
;
$data_row
[]
=
(
floa
t
)
$r
enders
[
$row_number
][
$data_field_key
]
;
$data
[]
=
$data_row
;
}
...
...
@@ -157,7 +165,7 @@ class charts_plugin_style_chart extends views_plugin_style {
'#min'
=>
$this
->
options
[
'yaxis_min'
],
);
foreach
(
$data_fields
as
$field_key
=>
$field_handler
)
{
$chart
[
$field_
handler
->
field_alias
]
=
array
(
$chart
[
$field_
key
]
=
array
(
'#type'
=>
'chart_data'
,
'#data'
=>
array
(),
'#color'
=>
isset
(
$this
->
options
[
'field_colors'
][
$field_key
])
?
$this
->
options
[
'field_colors'
][
$field_key
]
:
NULL
,
...
...
@@ -168,14 +176,13 @@ class charts_plugin_style_chart extends views_plugin_style {
);
}
foreach
(
$this
->
view
->
result
as
$row
)
{
if
(
$label_field
)
{
$chart
[
'xaxis'
][
'#labels'
][]
=
$label_field
->
render
(
$row
);
unset
(
$row
->
{
$label_field
->
field_alias
})
;
$renders
=
$this
->
render_fields
(
$this
->
view
->
result
);
foreach
(
$renders
as
$row_number
=>
$row
)
{
if
(
$label_field_key
)
{
$chart
[
'xaxis'
][
'#labels'
][]
=
$renders
[
$row_number
][
$label_field_key
]
;
}
$row
=
(
array
)
$row
;
foreach
(
$row
as
$field_alias
=>
$data_item
)
{
$chart
[
$field_alias
][
'#data'
][]
=
(
int
)
$data_item
;
foreach
(
$data_fields
as
$field_key
=>
$field_handler
)
{
$chart
[
$field_key
][
'#data'
][]
=
(
float
)
$renders
[
$row_number
][
$field_key
];
}
}
}
...
...
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