Skip to content

Commit

Permalink
Merge pull request #11373 from apache/fix-10945
Browse files Browse the repository at this point in the history
fix(gauge): update data with dataset #10945
  • Loading branch information
Ovilia authored Oct 21, 2019
2 parents 8b8a67f + 625f57c commit b732d09
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/chart/gauge/GaugeSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ var GaugeSeries = SeriesModel.extend({
type: 'series.gauge',

getInitialData: function (option, ecModel) {
var dataOpt = option.data || [];
if (!zrUtil.isArray(dataOpt)) {
dataOpt = [dataOpt];
}
option.data = dataOpt;
return createListSimply(this, ['value']);
},

Expand Down
159 changes: 159 additions & 0 deletions test/gauge-simple.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->


<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
<script src="lib/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<!-- <script src="ut/lib/canteen.js"></script> -->
<link rel="stylesheet" href="lib/reset.css" />
</head>

<body>
<style>
</style>



<div id="main0"></div>

<div id="main1"></div>

<div id="main2"></div>









<script>
require(['echarts'], function (echarts) {
var option = {
tooltip: {
formatter: "{a} <br/>{b} : {c}%"
},
series: [
{
name: 'Pressure',
type: 'gauge',
detail: {formatter: '{value}%'},
data: [{value: 50, name: 'score'}]
}
]
};

var chart = testHelper.create(echarts, 'main0', {
title: [
'Simple gauge',
'Value should be 88 after clicking button'
],
option: option,
buttons: [{
text: 'Change data', onclick: function () {
option.series[0].data[0].value = 88;
chart.setOption(option, true);
}
}]
});
});
</script>






<script>
require(['echarts'], function (echarts) {
var option = {
tooltip: {
formatter: "{a} <br/>{b} : {c}%"
},
dataset: {
source: [[10], [30]]
},
series: [
{
name: 'Pressure',
type: 'gauge',
detail: {formatter: '{value}%'}
}
]
};

var chart = testHelper.create(echarts, 'main1', {
title: [
'Gauge with dataset',
'Value should be 44 and 88 after clicking button'
],
option: option,
buttons: [{
text: 'Change data', onclick: function () {
chart.setOption({
dataset: {
source: [[44], [88]]
}
});
}
}]
});
});
</script>




<script>
require(['echarts'], function (echarts) {
var option = {
tooltip: {
formatter: "{a} <br/>{b} : {c}%"
},
series: [
{
name: 'Pressure',
type: 'gauge',
data: []
}
]
};

var chart = testHelper.create(echarts, 'main2', {
title: [
'Gauge with no data, should display NaN'
],
option: option
});
});
</script>

</body>

</html>
1 change: 1 addition & 0 deletions test/runTest/actions/__meta__.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@
"map-contour": 2,
"map-default": 1,
"map-labels": 1,
"gauge-simple": 2,
"polar-rounded": 2
}
1 change: 1 addition & 0 deletions test/runTest/actions/gauge-simple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"Action 1","ops":[{"type":"mousemove","time":613,"x":136,"y":595},{"type":"mousemove","time":813,"x":130,"y":264},{"type":"mousemove","time":1022,"x":89,"y":140},{"type":"mousemove","time":1223,"x":89,"y":126},{"type":"mousemove","time":1372,"x":89,"y":125},{"type":"mousemove","time":1572,"x":78,"y":101},{"type":"mousedown","time":1774,"x":75,"y":98},{"type":"mousemove","time":1807,"x":75,"y":98},{"type":"mouseup","time":1890,"x":75,"y":98},{"time":1891,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1570518999079},{"name":"Action 2","ops":[{"type":"mousemove","time":131,"x":512,"y":199},{"type":"mousemove","time":339,"x":334,"y":246},{"type":"mousemove","time":542,"x":155,"y":201},{"type":"mousemove","time":746,"x":81,"y":178},{"type":"mousedown","time":866,"x":78,"y":177},{"type":"mousemove","time":966,"x":78,"y":177},{"type":"mouseup","time":990,"x":78,"y":177},{"time":991,"delay":400,"type":"screenshot-auto"}],"scrollY":436,"scrollX":0,"timestamp":1570519158772}]

0 comments on commit b732d09

Please sign in to comment.