123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845 |
- describe('modelAndOptionMapping', function() {
- var utHelper = window.utHelper;
- var testCase = utHelper.prepare([
- 'echarts/src/component/grid',
- 'echarts/src/chart/line',
- 'echarts/src/chart/pie',
- 'echarts/src/chart/bar',
- 'echarts/src/component/toolbox',
- 'echarts/src/component/dataZoom'
- ]);
- function getData0(chart, seriesIndex) {
- return getSeries(chart, seriesIndex).getData().get('y', 0);
- }
- function getSeries(chart, seriesIndex) {
- return chart.getModel().getComponent('series', seriesIndex);
- }
- function getModel(chart, type, index) {
- return chart.getModel().getComponent(type, index);
- }
- function countSeries(chart) {
- return countModel(chart, 'series');
- }
- function countModel(chart, type) {
- // FIXME
- // access private
- return chart.getModel()._componentsMap.get(type).length;
- }
- function getChartView(chart, series) {
- return chart._chartsMap[series.__viewId];
- }
- function countChartViews(chart) {
- return chart._chartsViews.length;
- }
- function saveOrigins(chart) {
- var count = countSeries(chart);
- var origins = [];
- for (var i = 0; i < count; i++) {
- var series = getSeries(chart, i);
- origins.push({
- model: series,
- view: getChartView(chart, series)
- });
- }
- return origins;
- }
- function modelEqualsToOrigin(chart, idxList, origins, boolResult) {
- for (var i = 0; i < idxList.length; i++) {
- var idx = idxList[i];
- expect(origins[idx].model === getSeries(chart, idx)).toEqual(boolResult);
- }
- }
- function viewEqualsToOrigin(chart, idxList, origins, boolResult) {
- for (var i = 0; i < idxList.length; i++) {
- var idx = idxList[i];
- expect(
- origins[idx].view === getChartView(chart, getSeries(chart, idx))
- ).toEqual(boolResult);
- }
- }
- describe('idNoNameNo', function () {
- testCase.createChart()('sameTypeNotMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22]},
- {type: 'line', data: [33]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- // Not merge
- var origins = saveOrigins(chart);
- chart.setOption(option, true);
- expect(countChartViews(chart)).toEqual(3);
- expect(countSeries(chart)).toEqual(3);
- modelEqualsToOrigin(chart, [0, 1, 2], origins, false);
- viewEqualsToOrigin(chart, [0, 1, 2], origins, true);
- });
- testCase.createChart()('sameTypeMergeFull', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22]},
- {type: 'line', data: [33]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- // Merge
- var origins = saveOrigins(chart);
- chart.setOption({
- series: [
- {type: 'line', data: [111]},
- {type: 'line', data: [222]},
- {type: 'line', data: [333]}
- ]
- });
- expect(countSeries(chart)).toEqual(3);
- expect(countChartViews(chart)).toEqual(3);
- expect(getData0(chart, 0)).toEqual(111);
- expect(getData0(chart, 1)).toEqual(222);
- expect(getData0(chart, 2)).toEqual(333);
- viewEqualsToOrigin(chart, [0, 1, 2], origins, true);
- modelEqualsToOrigin(chart, [0, 1, 2], origins, true);
- });
- testCase.createChart()('sameTypeMergePartial', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22]},
- {type: 'line', data: [33]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- // Merge
- var origins = saveOrigins(chart);
- chart.setOption({
- series: [
- {data: [22222]}
- ]
- });
- expect(countSeries(chart)).toEqual(3);
- expect(countChartViews(chart)).toEqual(3);
- expect(getData0(chart, 0)).toEqual(22222);
- expect(getData0(chart, 1)).toEqual(22);
- expect(getData0(chart, 2)).toEqual(33);
- viewEqualsToOrigin(chart, [0, 1, 2], origins, true);
- modelEqualsToOrigin(chart, [0, 1, 2], origins, true);
- });
- testCase.createChart()('differentTypeMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22]},
- {type: 'line', data: [33]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- // Merge
- var origins = saveOrigins(chart);
- chart.setOption({
- series: [
- {type: 'line', data: [111]},
- {type: 'bar', data: [222]},
- {type: 'line', data: [333]}
- ]
- });
- expect(countSeries(chart)).toEqual(3);
- expect(countChartViews(chart)).toEqual(3);
- expect(getData0(chart, 0)).toEqual(111);
- expect(getData0(chart, 1)).toEqual(222);
- expect(getData0(chart, 2)).toEqual(333);
- expect(getSeries(chart, 1).type === 'series.bar').toEqual(true);
- modelEqualsToOrigin(chart, [0, 2], origins, true);
- modelEqualsToOrigin(chart, [1], origins, false);
- viewEqualsToOrigin(chart, [0, 2], origins, true);
- viewEqualsToOrigin(chart, [1], origins, false);
- });
- });
- describe('idSpecified', function () {
- testCase.createChart()('sameTypeNotMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], id: 20},
- {type: 'line', data: [33], id: 30},
- {type: 'line', data: [44]},
- {type: 'line', data: [55]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- expect(countSeries(chart)).toEqual(5);
- expect(countChartViews(chart)).toEqual(5);
- expect(getData0(chart, 0)).toEqual(11);
- expect(getData0(chart, 1)).toEqual(22);
- expect(getData0(chart, 2)).toEqual(33);
- expect(getData0(chart, 3)).toEqual(44);
- expect(getData0(chart, 4)).toEqual(55);
- var origins = saveOrigins(chart);
- chart.setOption(option, true);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
- viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
- });
- testCase.createChart()('sameTypeMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], id: 20},
- {type: 'line', data: [33], id: 30},
- {type: 'line', data: [44]},
- {type: 'line', data: [55]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- chart.setOption(option);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
- viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
- });
- testCase.createChart()('differentTypeNotMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], id: 20},
- {type: 'line', data: [33], id: 30},
- {type: 'line', data: [44]},
- {type: 'line', data: [55]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- var option2 = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'bar', data: [22], id: 20},
- {type: 'line', data: [33], id: 30},
- {type: 'bar', data: [44]},
- {type: 'line', data: [55]}
- ]
- };
- chart.setOption(option2, true);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
- viewEqualsToOrigin(chart, [0, 2, 4], origins, true);
- viewEqualsToOrigin(chart, [1, 3], origins, false);
- });
- testCase.createChart()('differentTypeMergeFull', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], id: 20},
- {type: 'line', data: [33], id: 30, name: 'a'},
- {type: 'line', data: [44]},
- {type: 'line', data: [55]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- var option2 = {
- series: [
- {type: 'line', data: [11]},
- {type: 'bar', data: [22], id: 20, name: 'a'},
- {type: 'line', data: [33], id: 30},
- {type: 'bar', data: [44]},
- {type: 'line', data: [55]}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 2, 4], origins, true);
- modelEqualsToOrigin(chart, [1, 3], origins, false);
- viewEqualsToOrigin(chart, [0, 2, 4], origins, true);
- viewEqualsToOrigin(chart, [1, 3], origins, false);
- });
- testCase.createChart()('differentTypeMergePartial1', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], id: 20},
- {type: 'line', data: [33]},
- {type: 'line', data: [44], id: 40},
- {type: 'line', data: [55]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- var option2 = {
- series: [
- {type: 'bar', data: [444], id: 40},
- {type: 'line', data: [333]},
- {type: 'line', data: [222], id: 20}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- expect(getData0(chart, 0)).toEqual(333);
- expect(getData0(chart, 1)).toEqual(222);
- expect(getData0(chart, 2)).toEqual(33);
- expect(getData0(chart, 3)).toEqual(444);
- expect(getData0(chart, 4)).toEqual(55);
- modelEqualsToOrigin(chart, [0, 1, 2, 4], origins, true);
- modelEqualsToOrigin(chart, [3], origins, false);
- viewEqualsToOrigin(chart, [0, 1, 2, 4], origins, true);
- viewEqualsToOrigin(chart, [3], origins, false);
- });
- testCase.createChart()('differentTypeMergePartial2', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], id: 20}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var option2 = {
- series: [
- {type: 'bar', data: [444], id: 40},
- {type: 'line', data: [333]},
- {type: 'line', data: [222], id: 20},
- {type: 'line', data: [111]}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(4);
- expect(countSeries(chart)).toEqual(4);
- expect(getData0(chart, 0)).toEqual(333);
- expect(getData0(chart, 1)).toEqual(222);
- expect(getData0(chart, 2)).toEqual(444);
- expect(getData0(chart, 3)).toEqual(111);
- });
- testCase.createChart()('mergePartialDoNotMapToOtherId', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11], id: 10},
- {type: 'line', data: [22], id: 20}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var option2 = {
- series: [
- {type: 'bar', data: [444], id: 40}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(3);
- expect(countSeries(chart)).toEqual(3);
- expect(getData0(chart, 0)).toEqual(11);
- expect(getData0(chart, 1)).toEqual(22);
- expect(getData0(chart, 2)).toEqual(444);
- });
- testCase.createChart()('idDuplicate', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11], id: 10},
- {type: 'line', data: [22], id: 10}
- ]
- };
- var chart = this.chart;
- expect(function () {
- chart.setOption(option);
- }).toThrowError(/duplicate/);
- });
- testCase.createChart()('nameTheSameButIdNotTheSame', function () {
- var chart = this.chart;
- var option = {
- grid: {},
- xAxis: [
- {id: 'x1', name: 'a', xxxx: 'x1_a'},
- {id: 'x2', name: 'b', xxxx: 'x2_b'}
- ],
- yAxis: {}
- };
- chart.setOption(option);
- var xAxisModel0 = getModel(chart, 'xAxis', 0);
- var xAxisModel1 = getModel(chart, 'xAxis', 1);
- expect(xAxisModel0.option.xxxx).toEqual('x1_a');
- expect(xAxisModel1.option.xxxx).toEqual('x2_b');
- expect(xAxisModel1.option.name).toEqual('b');
- var option2 = {
- xAxis: [
- {id: 'k1', name: 'a', xxxx: 'k1_a'},
- {id: 'x2', name: 'a', xxxx: 'x2_a'}
- ]
- };
- chart.setOption(option2);
- var xAxisModel0 = getModel(chart, 'xAxis', 0);
- var xAxisModel1 = getModel(chart, 'xAxis', 1);
- var xAxisModel2 = getModel(chart, 'xAxis', 2);
- expect(xAxisModel0.option.xxxx).toEqual('x1_a');
- expect(xAxisModel1.option.xxxx).toEqual('x2_a');
- expect(xAxisModel1.option.name).toEqual('a');
- expect(xAxisModel2.option.xxxx).toEqual('k1_a');
- });
- });
- describe('noIdButNameExists', function () {
- testCase.createChart()('sameTypeNotMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], name: 'a'},
- {type: 'line', data: [33], name: 'b'},
- {type: 'line', data: [44]},
- {type: 'line', data: [55], name: 'a'}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- expect(getSeries(chart, 1)).not.toEqual(getSeries(chart, 4));
- expect(countSeries(chart)).toEqual(5);
- expect(countChartViews(chart)).toEqual(5);
- expect(getData0(chart, 0)).toEqual(11);
- expect(getData0(chart, 1)).toEqual(22);
- expect(getData0(chart, 2)).toEqual(33);
- expect(getData0(chart, 3)).toEqual(44);
- expect(getData0(chart, 4)).toEqual(55);
- var origins = saveOrigins(chart);
- chart.setOption(option, true);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
- viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
- });
- testCase.createChart()('sameTypeMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], name: 'a'},
- {type: 'line', data: [33], name: 'b'},
- {type: 'line', data: [44]},
- {type: 'line', data: [55], name: 'a'}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- chart.setOption(option);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
- viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
- });
- testCase.createChart()('differentTypeNotMerge', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], name: 'a'},
- {type: 'line', data: [33], name: 'b'},
- {type: 'line', data: [44]},
- {type: 'line', data: [55], name: 'a'}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- var option2 = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'bar', data: [22], name: 'a'},
- {type: 'line', data: [33], name: 'b'},
- {type: 'bar', data: [44]},
- {type: 'line', data: [55], name: 'a'}
- ]
- };
- chart.setOption(option2, true);
- expect(countChartViews(chart)).toEqual(5);
- expect(countSeries(chart)).toEqual(5);
- modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
- viewEqualsToOrigin(chart, [0, 2, 4], origins, true);
- viewEqualsToOrigin(chart, [1, 3], origins, false);
- });
- testCase.createChart()('differentTypeMergePartialOneMapTwo', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], name: 'a'},
- {type: 'line', data: [33]},
- {type: 'line', data: [44], name: 'b'},
- {type: 'line', data: [55], name: 'a'}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var origins = saveOrigins(chart);
- var option2 = {
- series: [
- {type: 'bar', data: [444], id: 40},
- {type: 'line', data: [333]},
- {type: 'bar', data: [222], name: 'a'}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(6);
- expect(countSeries(chart)).toEqual(6);
- expect(getData0(chart, 0)).toEqual(333);
- expect(getData0(chart, 1)).toEqual(222);
- expect(getData0(chart, 2)).toEqual(33);
- expect(getData0(chart, 3)).toEqual(44);
- expect(getData0(chart, 4)).toEqual(55);
- expect(getData0(chart, 5)).toEqual(444);
- modelEqualsToOrigin(chart, [0, 2, 3, 4], origins, true);
- modelEqualsToOrigin(chart, [1], origins, false);
- viewEqualsToOrigin(chart, [0, 2, 3, 4], origins, true);
- viewEqualsToOrigin(chart, [1], origins, false);
- });
- testCase.createChart()('differentTypeMergePartialTwoMapOne', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22], name: 'a'}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var option2 = {
- series: [
- {type: 'bar', data: [444], name: 'a'},
- {type: 'line', data: [333]},
- {type: 'line', data: [222], name: 'a'},
- {type: 'line', data: [111]}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(4);
- expect(countSeries(chart)).toEqual(4);
- expect(getData0(chart, 0)).toEqual(333);
- expect(getData0(chart, 1)).toEqual(444);
- expect(getData0(chart, 2)).toEqual(222);
- expect(getData0(chart, 3)).toEqual(111);
- });
- testCase.createChart()('mergePartialCanMapToOtherName', function () {
- // Consider case: axis.name = 'some label', which can be overwritten.
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11], name: 10},
- {type: 'line', data: [22], name: 20}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- var option2 = {
- series: [
- {type: 'bar', data: [444], name: 40},
- {type: 'bar', data: [999], name: 40},
- {type: 'bar', data: [777], id: 70}
- ]
- };
- chart.setOption(option2);
- expect(countChartViews(chart)).toEqual(3);
- expect(countSeries(chart)).toEqual(3);
- expect(getData0(chart, 0)).toEqual(444);
- expect(getData0(chart, 1)).toEqual(999);
- expect(getData0(chart, 2)).toEqual(777);
- });
- });
- describe('ohters', function () {
- testCase.createChart()('aBugCase', function () {
- var option = {
- series: [
- {
- type:'pie',
- radius: ['20%', '25%'],
- center:['20%', '20%'],
- avoidLabelOverlap: true,
- hoverAnimation :false,
- label: {
- normal: {
- show: true,
- position: 'center',
- textStyle: {
- fontSize: '30',
- fontWeight: 'bold'
- }
- },
- emphasis: {
- show: true
- }
- },
- data:[
- {value:135, name:'视频广告'},
- {value:1548}
- ]
- }
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- chart.setOption({
- series: [
- {
- type:'pie',
- radius: ['20%', '25%'],
- center: ['20%', '20%'],
- avoidLabelOverlap: true,
- hoverAnimation: false,
- label: {
- normal: {
- show: true,
- position: 'center',
- textStyle: {
- fontSize: '30',
- fontWeight: 'bold'
- }
- }
- },
- data: [
- {value:135, name:'视频广告'},
- {value:1548}
- ]
- },
- {
- type:'pie',
- radius: ['20%', '25%'],
- center: ['60%', '20%'],
- avoidLabelOverlap: true,
- hoverAnimation: false,
- label: {
- normal: {
- show: true,
- position: 'center',
- textStyle: {
- fontSize: '30',
- fontWeight: 'bold'
- }
- }
- },
- data: [
- {value:135, name:'视频广告'},
- {value:1548}
- ]
- }
- ]
- }, true);
- expect(countChartViews(chart)).toEqual(2);
- expect(countSeries(chart)).toEqual(2);
- });
- testCase.createChart()('color', function () {
- var option = {
- backgroundColor: 'rgba(1,1,1,1)',
- xAxis: {data: ['a']},
- yAxis: {},
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22]},
- {type: 'line', data: [33]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- expect(chart._model.option.backgroundColor).toEqual('rgba(1,1,1,1)');
- // Not merge
- chart.setOption({
- backgroundColor: '#fff'
- }, true);
- expect(chart._model.option.backgroundColor).toEqual('#fff');
- });
- testCase.createChart()('innerId', function () {
- var option = {
- xAxis: {data: ['a']},
- yAxis: {},
- toolbox: {
- feature: {
- dataZoom: {}
- }
- },
- dataZoom: [
- {type: 'inside', id: 'a'},
- {type: 'slider', id: 'b'}
- ],
- series: [
- {type: 'line', data: [11]},
- {type: 'line', data: [22]}
- ]
- };
- var chart = this.chart;
- chart.setOption(option);
- expect(countModel(chart, 'dataZoom')).toEqual(4);
- expect(getModel(chart, 'dataZoom', 0).id).toEqual('a');
- expect(getModel(chart, 'dataZoom', 1).id).toEqual('b');
- // Merge
- chart.setOption({
- dataZoom: [
- {type: 'slider', id: 'c'},
- {type: 'slider', name: 'x'}
- ]
- });
- expect(countModel(chart, 'dataZoom')).toEqual(5);
- expect(getModel(chart, 'dataZoom', 0).id).toEqual('a');
- expect(getModel(chart, 'dataZoom', 1).id).toEqual('b');
- expect(getModel(chart, 'dataZoom', 4).id).toEqual('c');
- });
- });
- });
|