[<img src="https://cdn.anychart.com/images/logo-transparent-segoe.png?2" width="234px" alt="AnyChart - Robust JavaScript/HTML5 Chart library any project">](https://anychart.com)
npm install anychart-v7-to-v8-migration-tool
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
$3
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') |
$3
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
| 7.x Version | 8.x Version |
| ------------- | ------------- |
| hover/selectFill() | hovered/selected().fill() |
| hover/selectStroke() | hovered/selected().stroke() |
| hover/selectLabels() | hovered/selected().labels() |
| hover/selectMarkers() | hovered/selected().markers() |
#### Specific API Methods
| 7.x Version | 8.x Version |
| ------------- | ------------- |
| hover/selectNegativeFill() | hovered/selected().negativeFill() |
| hover/selectRisingFill() | hovered/selected().risingFill() |
| hover/selectFallingFill() | hovered/selected().fallingFill() |
| hover/selectLowStroke() | hovered/selected().lowStroke() |
| hover/selectHighStroke() | hovered/selected().highStroke() |
| hover/selectNegativeStroke() | hovered/selected().negativeStroke() |
| hover/selectRisingStroke() | hovered/selected().risingStroke() |
| hover/selectFallingStroke() | hovered/selected().fallingStroke() |
| hover/selectMedianStroke() | hovered/selected().medianStroke() |
| hover/selectStemStroke() | hovered/selected().stemStroke() |
| hover/selectWhiskerStroke() | hovered/selected().whiskerStroke() |
| hover/selectHatchFill() | hovered/selected().hatchFill() |
| hover/selectNegativeHatchFill() | hovered/selected().negativeHatchFill() |
| hover/selectRisingHatchFill() | hovered/selected().risingHatchFill() |
| hover/selectFallingHatchFill() | hovered/selected().fallingHatchFill() |
| hover/selectWhiskerWidth() | hovered/selected().whiskerWidth() |
| hover/selectType() | hovered/selected().type() |
| hover/selectSize() | hovered/selected().size() |
| hover/selectTrend() | hovered/selected().trend() |
| hover/selectGrid() | hovered/selected().grid() |
| hover/selectEmptyFill() | hovered/selected().emptyFill() |
| hover/selectEmptyHatchFill() | hovered/selected().emptyHatchFill() |
| - | hovered/selected().fontFamily() |
| - | hovered/selected().fontStyle() |
| - | hovered/selected().fontVariant() |
| - | hovered/selected().fontWeight() |
| - | hovered/selected().fontSize() |
| - | hovered/selected().dummyFill() |
| - | hovered/selected().dummyStroke() |
| - | hovered/selected().headers() |
| hover/selectLowerLabels() | hovered/selected().lowerLabels() |
| hover/selectUpperLabels() | hovered/selected().upperLabels() |
| hover/selectOutlierMarkers() | hovered/selected().outlierMarkers() |
$3
Grids API has been changed completely and can not be migrated automatically:
1. 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");
`
2. 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");
`
3. 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']);
`
$3
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;
});
`
$3
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'});
`
$3
There are two changes in enums API:
1. Enums no longer can be set by name, only string values can be used.
2. 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');
``