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.
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.
To install migration tool with npm:
npm install anychart-v7-to-v8-migration-tool -g
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
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
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:
7.x Version | 8.x Version |
---|---|
chart.yScale() | chart.yScale().stackDirection('reverse') |
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:
Grids API has been changed completely and can not be migrated automatically:
chart.grid(0).stroke("#9E9E9E", 2, "5 2 5");
chart.grid(1).layout('vertical').stroke("#9E9E9E", 1, "5 1 5");
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.
chart.minorGrid(0).stroke("#9E9E9E", 2, "5 2 5");
chart.minorGrid(1).layout('vertical').stroke("#9E9E9E", 1, "5 1 5");
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()
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');
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.
chart.contextMenu().itemsFormatter(function () {
// Adding custom item to the top of context menu.
this.unshift({
text: "My custom item"
});
return this;
});
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;
});
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.
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'});
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'});
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.
chart.legend().itemsLayout(anychart.enums.LegendLayout.HORIZONTAL_EXPANDABLE);
chart.legend().itemsLayout('horizontal-expandable');
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:
Old Version | New Version |
---|---|
allowPointsSelect() | selectionMode() |
isFloating() | positionMode() |
mouseWheel() | zoomOnMouseWheel() |
Old Version | New Version |
---|---|
colorAt() | itemAt() |
colors() | items() |
markerAt() | itemAt() |
markers() | items() |
Old Version | New Version |
---|---|
chart.type() | chart.seriesType() |
Old Version | New Version |
---|---|
anychart.server() | anychart.exports.server() |
getGroupingUnit() | getCurrentDataInterval() |
Old Version | New Version |
---|---|
cellFill() | rowFill() |
cellOddFill() | rowOddFill() |
cellEvenFill() | rowEvenFill() |
titleHeight() | headerHeight() |
?? AnyChart.com - JavaScript charts. Released under the Apache 2.0 License.