|
@@ -51,7 +51,6 @@ export default defineComponent({
|
|
|
},
|
|
|
},
|
|
|
setup(props, contx) {
|
|
|
- //debugger;
|
|
|
const lastChartBox = ref();
|
|
|
const allData = reactive({
|
|
|
lastChart: null,
|
|
@@ -59,7 +58,7 @@ export default defineComponent({
|
|
|
getLastDayEnergy() {
|
|
|
queryLastDayEnergy().then((res) => {
|
|
|
var resdata = res.data.content || [];
|
|
|
- //debugger;
|
|
|
+
|
|
|
resdata.forEach(function(item) {
|
|
|
var dateStr = item.date;
|
|
|
item.Date =
|
|
@@ -79,7 +78,7 @@ export default defineComponent({
|
|
|
);
|
|
|
});
|
|
|
allData.lastChart = allData.cInitChart(resdata);
|
|
|
- console.log("contx,contx", contx, contx.emit);
|
|
|
+ //console.log("contx,contx", contx, contx.emit);
|
|
|
allData.setChartInterval();
|
|
|
});
|
|
|
},
|
|
@@ -106,23 +105,16 @@ export default defineComponent({
|
|
|
"lastend",
|
|
|
end.format("YYYY-MM-DD")
|
|
|
);
|
|
|
+ const rows = allData.ds.views.ttime.rows;
|
|
|
+ allData.lastChart.changeData(rows);
|
|
|
+ //console.log("rows----", rows.length, rows, start, end);
|
|
|
+ // allData.ds.on("statechange", (name, value) => {
|
|
|
+ // const rows = allData.ds.views.ttime.rows;
|
|
|
+ // allData.lastChart.changeData(rows);
|
|
|
+ // // allData.lastChart.render(true);
|
|
|
+ // });
|
|
|
|
|
|
- allData.ds.on("statechange", (name, value) => {
|
|
|
- const rows = allData.ds.views.bar.rows;
|
|
|
- allData.lastChart.changeData(rows);
|
|
|
- // allData.lastChart.render(true);
|
|
|
- // console.log(
|
|
|
- // "end--22",
|
|
|
- // ds.views,
|
|
|
- // ds.views.bar.rows,
|
|
|
- // rows
|
|
|
- // );
|
|
|
- });
|
|
|
-
|
|
|
- if (
|
|
|
- end.format("YYYY-MM-DD") ==
|
|
|
- end2.endOf("month").format("YYYY-MM-DD")
|
|
|
- ) {
|
|
|
+ if (rows.length == 11) {
|
|
|
clearInterval(intervalInt);
|
|
|
contx.emit("donethreepage");
|
|
|
}
|
|
@@ -136,6 +128,7 @@ export default defineComponent({
|
|
|
} else {
|
|
|
var end = cdata[11] && cdata[11].Date;
|
|
|
}
|
|
|
+ // 指定初始化状态量
|
|
|
let ds = new DataSet({
|
|
|
state: {
|
|
|
laststart: cdata[0] && cdata[0].Date,
|
|
@@ -145,8 +138,8 @@ export default defineComponent({
|
|
|
// var dv = new DataSet.DataView(ds, {
|
|
|
// watchingStates: [],
|
|
|
// });
|
|
|
- var dv = ds.createView("bar", {
|
|
|
- watchingStates: ["laststart", "lastend"],
|
|
|
+ var dv = ds.createView("ttime", {
|
|
|
+ // watchingStates: ["laststart", "lastend"],
|
|
|
});
|
|
|
dv.source(cdata).transform({
|
|
|
type: "filter",
|
|
@@ -162,7 +155,7 @@ export default defineComponent({
|
|
|
//console.log("dv.row", dv.rows, dv.transforms);
|
|
|
var width =
|
|
|
document.getElementsByTagName("body")[0].offsetWidth - 80;
|
|
|
- console.log("lastChartBox", lastChartBox.value);
|
|
|
+
|
|
|
var chart =
|
|
|
lastChartBox.value &&
|
|
|
new Chart({
|
|
@@ -172,17 +165,20 @@ export default defineComponent({
|
|
|
// height: props.screenType === "hor" ? 274 : 330,
|
|
|
padding: [20, 20, 36, 20],
|
|
|
});
|
|
|
+
|
|
|
if (!chart) return chart;
|
|
|
- chart.data(dv.rows); //这个赋值是升级后的 方式
|
|
|
- chart.tooltip(false);
|
|
|
- chart.scale("Date", {
|
|
|
+
|
|
|
+ const chartView = chart.createView();
|
|
|
+ chartView.data(dv.rows); //这个赋值是升级后的 方式
|
|
|
+ chartView.tooltip(false);
|
|
|
+ chartView.scale("Date", {
|
|
|
//range: [0, 1],
|
|
|
- tickCount: 12,
|
|
|
- //tickInterval:0,
|
|
|
+ //tickCount: 12,
|
|
|
+ tickInterval: 2,
|
|
|
type: "timeCat",
|
|
|
mask: "MM-DD",
|
|
|
});
|
|
|
- chart.scale("value", {
|
|
|
+ chartView.scale("value", {
|
|
|
//range: [0, 1],
|
|
|
tickCount: 5,
|
|
|
type: "linear",
|
|
@@ -190,7 +186,7 @@ export default defineComponent({
|
|
|
//tickInterval
|
|
|
// type: 'timeCat'
|
|
|
});
|
|
|
- chart.axis("Date", {
|
|
|
+ chartView.axis("Date", {
|
|
|
line: {
|
|
|
style: {
|
|
|
lineWidth: 1, // 设置线的宽度
|
|
@@ -206,7 +202,7 @@ export default defineComponent({
|
|
|
},
|
|
|
tickLine: null,
|
|
|
});
|
|
|
- chart.axis("value", {
|
|
|
+ chartView.axis("value", {
|
|
|
line: null,
|
|
|
grid: {
|
|
|
line: {
|
|
@@ -221,9 +217,9 @@ export default defineComponent({
|
|
|
label: null,
|
|
|
});
|
|
|
|
|
|
- chart.legend(false);
|
|
|
+ chartView.legend(false);
|
|
|
|
|
|
- chart
|
|
|
+ chartView
|
|
|
.interval()
|
|
|
.position("Date*value")
|
|
|
.color("l(90) 0:#BFA17E 1:#E0D1BB")
|