diff --git a/src/components/HourChart.vue b/src/components/HourChart.vue index f07caec..2d854d4 100644 --- a/src/components/HourChart.vue +++ b/src/components/HourChart.vue @@ -88,7 +88,7 @@ onMounted(() => { + + diff --git a/src/components/LatestWeekYieldOptions.js b/src/components/LatestWeekYieldOptions.js new file mode 100644 index 0000000..27c23f6 --- /dev/null +++ b/src/components/LatestWeekYieldOptions.js @@ -0,0 +1,137 @@ +export const options = { + color: ['#00D3E7', '#2B9BFF', '#0D4DFF'], + legend: { + textStyle: { + color: "#fff8", + }, + right: 0, + itemWidth: 12, + itemHeight: 12 + }, + tooltip: {}, + dataset: { + source: [], + }, + grid: { + top: 56, + bottom: 12, + left: 10, + right: 20, + containLabel: true, + }, + xAxis: { + type: "category", + axisLabel: { + fontSize: 12, + color: "#fff8", + }, + axisTick: { + alignWithLabel: true, + }, + }, + yAxis: { + name: "片", + nameTextStyle: { + color: "#fff8", + fontSize: 14, + }, + axisLabel: { + fontSize: 12, + color: "#fff8", + }, + splitLine: { + lineStyle: { + color: "#fff8", + }, + }, + minInterval: 1, + }, + series: [ + { + type: "bar", + label: { + show: true, + distance: 20, + rotate: 90, + color: "#fff", + verticalAlign: "middle", + position: 'top', + formatter: (params) => { + return params.data[1]; + }, + }, + }, + { + type: "bar", + label: { + show: true, + distance: 20, + rotate: 90, + color: "#fff", + verticalAlign: "middle", + position: 'top', + formatter: (params) => { + return params.data[2]; + }, + }, + }, + { + type: "bar", + label: { + show: true, + distance: 20, + rotate: 90, + color: "#fff", + verticalAlign: "middle", + position: 'top', + formatter: (params) => { + return params.data[3]; + }, + }, + }, + ], +}; + +export default function setup( + echartInstance, + list = [ + ["1-12", 1, 2, 3], + ["1-13", 4, 5, 6], + ["1-14", 14, 15, 16], + ["1-15", 9], + ["1-16", 4, 5, 6], + ["1-17", 1, 1, 1], + ] +) { + const new_options = { ...options }; + new_options.dataset.source = [["date", "钢1线", "钢2线", "钢3线"], ...list]; + echartInstance.setOption(new_options); +} + +export function createDatasetFrom(lines, datelist) { + const dataset = []; + datelist.forEach((date) => { + const row = [date]; + lines.forEach((line) => { + const item = line.data.find((item) => item.day === date); + row.push(item ? item.num : 0); + }); + dataset.push(row); + }); + console.log(dataset); + return dataset; +} + +export function findDatelist(lines) { + const dateList = []; + lines.forEach((line) => { + dateList.push(...line.data.map((item) => item.day)); + }); + return Array.from(new Set(dateList)).sort(); +} + +export function loadData(list) { + if (!list || list.length != 3 || list[0].data.length <= 0) return null; + const datelist = findDatelist(list); + return createDatasetFrom(list, datelist); +} diff --git a/src/components/datapage/LatestWeekYieldOptions.js b/src/components/datapage/LatestWeekYieldOptions.js index 1de95c6..5287855 100644 --- a/src/components/datapage/LatestWeekYieldOptions.js +++ b/src/components/datapage/LatestWeekYieldOptions.js @@ -1,4 +1,5 @@ export const options = { + color: ['#00D3E7', '#2B9BFF', '#0D4DFF'], legend: { textStyle: { color: "#fff8", diff --git a/src/pages/DataPage.vue b/src/pages/DataPage.vue index b43e950..d47bb6a 100644 --- a/src/pages/DataPage.vue +++ b/src/pages/DataPage.vue @@ -1,8 +1,8 @@