-
18 Feb 2013 9:50 PM #1
[4.2.0 RC] Setting up legend for chart throws JavaScript error
[4.2.0 RC] Setting up legend for chart throws JavaScript error
REQUIRED INFORMATION
Ext version tested:- Ext 4.2.0 RC
- Chrome
- FireFox
- IE9
- <!DOCTYPE html>
- Setting up a legend for achart throws a JavaScript error "index is not defined" within the drawLine function of the Ext.chart.LegendItem class. The index variable seems to be not defined at all.
- Just run the sample
- No error
- The "index is not defined" JavaScript error occurs.
Code:<!DOCTYPE html> <html> <head> <title>Chart JS error legend item</title> <link rel="stylesheet" href="../resources/css/ext-all.css" /> <script src="../ext-all-debug.js"></script> <script> Ext.onReady(function () { Ext.create("Ext.chart.Chart", { renderTo: Ext.getBody(), height: 400, width: 400, axes: [{ position: "bottom", title: "X", fields: ["x"], type: "Numeric" }, { position: "left", title: "Y", fields: ["y"], type: "Numeric" }], legend: {}, // removing it causes the sample to be launched without any error series: [{ title: "Chart", xField: "x", yField: "y", type: "line" }], store: { fields: [{ name: "x" }, { name: "y" }], data: [{ x: 0, y: 0 }, { x: 50, y: 50 }, { x: 100, y: 100 }] } }); }); </script> </head> <body> </body> </html>
-
22 Feb 2013 11:00 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
Thanks for the report! I have opened a bug in our bug tracker.
-
27 Feb 2013 12:30 AM #3
The problem is that you have added a legend but you haven't configured what field to use for the label in the legend or set a title for the series.
Adding:
will fix the problem.Code:... series: [{ title: "Chart", xField: "x", yField: "y", type: "line", label: { field: 'model.field.with.text.for.the.legend' } }], ...
-
4 Mar 2013 3:02 AM #4
Thank you for the answer, Jack (by the way it is cool to speak with an Ext Founder).
Seems, adding a label config option doesn't help to fix the problem. I am a bit confused what are the relations between a series' label option and a legend? Could you clarify, please?
Also the series' title is set up in my test case. It seems also don't help to avoid the error. Well, there seems just a developer error in the LegendItem's drawLine method. The "index" variable is not defined anywhere. Probably, this was fixed in Sprint 4.
Please correct me if I am wrong somewhere.
Hi Mitchell,
Thank you for opening a bug ticket and fixing!
-
10 Mar 2013 11:35 AM #5
I had just ran into a similar error and upon quick glance thought you had run into the same one. After looking at the source, index is not defined in that function.
-
11 Mar 2013 6:14 AM #6
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-8798
in
4.2.0 Sprint 4 (GA).


Reply With Quote