AnyChart 7.x to 8.x Migration Tool
AnyChart migration tool is a utility script that helps to migrate JavaScript code of AnyChart 7.14.x to AnyChart 8.x.
IMPORTANT NOTE 1:
AnyChart made a number of adjustments moving from version 7 to 8. This migration tool can do a lot but it does not guarantee 100% migration. Some things can not be changes automatically and need manual coding. See the list of such cases in Manual migration section.
IMPORTANT NOTE 2:
This migration tool change API methods, enums and parameters of AnyChart API version 7.14.3 to version 8.0. It may work on earlier 7.x version but the numer of errors is more likely.
IMPORTANT NOTE 3:
We did our best to create this tool but it is not a panacea. If you don't want to change your code automatically, please see the List of changes section and figure out how your code is affected and what needs to be changed.
Modes
AnyChart migration tool is available in three ways
-
Online script at https://migration.anychart.com/
-
You own Web-Server that does the same as the script above but it is deployed on your side.
-
Console Utility script - you can choose a file or a folder, script will look for AnyChart code and replace everything, use with caution.
Installation
To install migration tool with npm:
npm install anychart-v7-to-v8-migration-tool -g
Running as Web Server
To run web server on port 3000 navigate to migration tool folder and run:
anychart-v7-to-v8-migration-tool-server -p 3000
To show help message navigate to migration tool folder and run:
anychart-v7-to-v8-migration-tool-server --help
Running as Console Utility
To process a file:
anychart-v7-to-v8-migration-tool-cli path_to_file
To process all files in a folder:
anychart-v7-to-v8-migration-tool-cli path_to_directory -r
To show help console script help:
anychart-v7-to-v8-migration-tool-cli --help
API Changes
Stacking Settings
The ordering in which the series are stacked is changed and now goes in other direction. To restore the previous behavior stackDirection() method has been added. Set 'reverse' to make the order match 7.x:
State Settings
The API for select and hover settings has been refactored: methods like hoverFill() are replaced with hovered().fill(), selectFill() - with selected().fill() and so on. The order of the parameters and behavior is the same.
These changes allow to clone/copy the settings from the state to state easily.
See the full list of replaced methods:
Common API Methods
Specific API Methods
Grids API
Grids API has been changed completely and can not be migrated automatically:
- Single grid() method is replaced with xGrid() and yGrid() methods.
7.x Version Code
chart.grid(0).stroke("#9E9E9E", 2, "5 2 5");
chart.grid(1).layout('vertical').stroke("#9E9E9E", 1, "5 1 5");
8.x.x
chart.xGrid().stroke("#9E9E9E", 2, "5 2 5");
chart.yGrid().stroke("#9E9E9E", 1, "5 1 5");
- Single minorGrid() method is replaced with yMinorGrid() and xMinorGrid() methods.
7.x Version Code
chart.minorGrid(0).stroke("#9E9E9E", 2, "5 2 5");
chart.minorGrid(1).layout('vertical').stroke("#9E9E9E", 1, "5 1 5");
8.x.x
chart.xMinorGrid().stroke("#9E9E9E", 2, "5 2 5");
chart.yMinorGrid().stroke("#9E9E9E", 1, "5 1 5");
- oddFill() and evenFill() methods are replaced with fill() method that now accepts palette()
7.x Version Code
var chart = anychart.polar();
chart.grid()
// coloring odd cells of the grid
.evenFill('white 0.9')
// coloring even cells of the grid
.oddFill('lightgray 0.3')
// set layout type
.layout('curcuit')
.stroke('white');
8.x.x
var chart = anychart.polar();
chart.yGrid().palette(['lightgray 0.3', 'white 0.9']);
Context menu API has been changed completely and can not be migrated automatically. Objects with IDs are now used instead of arrays. Please refer to Context Menu article to learn how to use the context menu in version 8.x.
7.14.3 Version Code
chart.contextMenu().itemsFormatter(function () {
// Adding custom item to the top of context menu.
this.unshift({
text: "My custom item"
});
return this;
});
8.x Version Code
chart.contextMenu().itemsFormatter(function (items) {
// Adding custom item to the top of context menu.
items["my-custom-item"] = {
index: 0,
text: "Show help info",
href: "https://docs.anychart.com/"
};
return items;
});
Data Mapping API
Improved API of mapAs() method, now it accepts only one parameter instead for four old version. You don't need to pass undefined
as first parameter for object based data sets.
7.x Version Code
var dataSet = anychart.data.set([
{platform: 'Mobile', views: 100},
{platform: 'Tablet', views: 200},
{platform: 'Desktop', views: 300}
]);
var mapping = dataSet.mapAs(undefined, {x: 'platform', value: 'views'});
8.x.x
var dataSet = anychart.data.set([
{platform: 'Mobile', views: 100},
{platform: 'Tablet', views: 200},
{platform: 'Desktop', views: 300}
]);
var mapping = dataSet.mapAs({x: 'platform', value: 'views'});
Dropped Enums API
There are two changes in enums API:
- Enums no longer can be set by name, only string values can be used.
- Enums string values are changed from camel case to dash case.
7.x Version Code
chart.legend().itemsLayout(anychart.enums.LegendLayout.HORIZONTAL_EXPANDABLE);
8.x Version Code
chart.legend().itemsLayout('horizontal-expandable');
Deprecated API Drop
Version 8.x drops a number of deprecated methods. Which means that you may have used these methods and the library only showed warnings. With upgrading to version 8.x using these methods is no longer possible.
See the list of dropped methods and their replacement below:
Text Formatting
Interactivity Settings
Palettes
Sparkline API
Misc
Gantt Data Grid
Constructors and Standalones
License
?? AnyChart.com - JavaScript charts. Released under the Apache 2.0 License.