大屏开源项目go-view二次开发3----象形柱图控件(C#)

news2025/7/19 20:05:49

环境搭建参考:

大屏开源项目go-view二次开发1----环境搭建(C#)-CSDN博客

要做的象形柱图控件最终效果如下图:

其实这个控件我前面的文章也介绍过,不过是用wpf做的,链接如下:

wpf利用Microsoft.Web.WebView2显示html代码(以Echarts的象形柱图Velocity of Christmas Reindeers为例)_webview集成echarts,formatter-CSDN博客

这一次是在上一篇博文大屏开源项目go-view二次开发2----半环形控件(C#)-CSDN博客

的基础上继续操作:

具体步骤如下:

1 首先,我们现在从这里抄该控件的option,链接如下:

Examples - Apache ECharts

2  在src\packages\components\Charts\Others(Others目录是上一篇博文新建的,具体请参考:大屏开源项目go-view二次开发2----半环形控件(C#)-CSDN博客)新增PictorialBar目录,然后从长得最像的控件BarCrossrange拷贝文件,拷贝src\packages\components\Charts\Bars\BarCrossrange目录下的5个文件到PictorialBar目录下,如下图:

3  编辑PictorialBar目录下的config.ts的文件如下:

import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { PictorialBar } from  './index'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'

export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
export const seriesItem = {
  name: 'hill',
  type: 'pictorialBar',
  barCategoryGap: '-130%',
  symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
  itemStyle: {
    opacity: 0.5
  },
  emphasis: {
    itemStyle: {
      opacity: 1
    }
  },
  //data: [90, 60, 25, 18],
  z: 10,
  label: {
    show: true,
    position: 'top',
    color: '#e54035',
    fontSize: 20
  }
}
export const option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'none'
    }
  },
  dataset: { ...dataJson },
  xAxis: {
    show: true,
    type: 'category',
    axisTick: { show: false },
    axisLine: { show: false },
    axisLabel: {
      color: '#e54035',
      fontSize: 20
    }
  },
  yAxis: {
    show: true,
    type: 'value',
    splitLine: { show: false },
    axisTick: { show: false },
    axisLine: { show: false },
    axisLabel: { 
      show: false,
      fontSize: 20
     }

  },

  color: ['#e54035'],
  series: [
    seriesItem
  ]

}

export default class Config extends PublicConfigClass implements CreateComponentType {
  public key = PictorialBar.key
  public chartConfig = cloneDeep(PictorialBar)
  // 图表配置项
  public option = echartOptionProfixHandle(option, includes)
}

从前面抄来的option就是放在这里的,我做了相应的调整,这个文件的具体功能已经在这篇博文做了详细的介绍:大屏开源项目go-view二次开发2----半环形控件(C#)-CSDN博客

4 编辑PictorialBar目录下的config.vue的文件如下:

<template>
    <!-- Echarts 全局设置 --> 
    <global-setting :optionData="optionData"></global-setting>

    <CollapseItem :name="`象形柱图`" :expanded="true">
        <SettingItemBox name="颜色">
            <SettingItem name="图形颜色">
              <n-color-picker
                size="small"
                :modes="['hex']"
                v-model:value="optionData.color">
              </n-color-picker>
            </SettingItem>
            <SettingItem name="label颜色">
                <n-color-picker
                  size="small"
                  :modes="['hex']"
                  v-model:value="seriesList[0].label.color">
                </n-color-picker>
            </SettingItem>
            <SettingItem name="X轴颜色">
              <template v-if="optionData.xAxis && optionData.xAxis.axisLabel">
                <n-color-picker
                  size="small"
                  :modes="['hex']"
                  v-model:value="optionData.xAxis.axisLabel.color">
                </n-color-picker>
              </template>
            </SettingItem>
         </SettingItemBox>

         <SettingItemBox name="字体大小">
            <SettingItem name="图例">
              <n-input-number
                  v-model:value="seriesList[0].label.fontSize"
                  size="small"
                  :min="1"
              ></n-input-number>
            </SettingItem>
            <SettingItem name="X轴">
              <template v-if="optionData.xAxis && optionData.xAxis.axisLabel">
                <n-input-number
                  v-model:value="optionData.xAxis.axisLabel.fontSize"
                  size="small"
                  :min="1"
              ></n-input-number>
              </template>
              
            </SettingItem>
            <SettingItem name="Y轴">
              <template v-if="optionData.yAxis && optionData.yAxis.axisLabel">
                <n-input-number
                  v-model:value="optionData.yAxis.axisLabel.fontSize"
                  size="small"
                  :min="1"
              ></n-input-number>
              </template>
            </SettingItem>
         </SettingItemBox>

    </CollapseItem>


  </template>
  
  <script setup lang="ts">
  import { PropType, computed } from 'vue'
  import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
  import { option } from './config'
  import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
  
  const props = defineProps({
    optionData: {
      type: Object as PropType<GlobalThemeJsonType>,
      required: true
    }
  })
  
  const seriesList = computed(() => {
  return props.optionData.series
})
  </script>
  

5  编辑PictorialBar目录下的data.json的文件如下:

{
    "dimensions": ["product", "data1"],
    "source": [
      {
        "product": "Mon",
        "data1": 120
      },
      {
        "product": "Tue",
        "data1": 200
      },
      {
        "product": "Wed",
        "data1": 150
      },
      {
        "product": "Thu",
        "data1": 80
      },
      {
        "product": "Fri",
        "data1": 70
      },
      {
        "product": "Sat",
        "data1": 110
      },
      {
        "product": "Sun",
        "data1": 130
      }
    ]
  }
  

6   编辑PictorialBar目录下的index.ts的文件如下:

import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'

export const PictorialBar: ConfigType = {
  key: 'PictorialBar',
  chartKey: 'VPictorialBar',
  conKey: 'VCPictorialBar',
  title: '象形柱图',
  category: ChatCategoryEnum.OTHERCHART,
  categoryName: ChatCategoryEnumName.OTHERCHART,
  package: PackagesCategoryEnum.CHARTS,
  chartFrame: ChartFrameEnum.ECHARTS,
  image: 'PictorialBar.png'
}

接着把该图片

下载后修改名称为PictorialBar.png,并放到src\assets\images\chart\charts目录下

7    编辑PictorialBar目录下的index.vue的文件如下:

<template>
    <v-chart
      ref="vChartRef"
      :init-options="initOptions"
      :theme="themeColor"
      :option="option"
      :update-options="{
        replaceMerge: replaceMergeArr
      }"
      autoresize
    ></v-chart>
  </template>
  
  <script setup lang="ts">
  import { ref, nextTick, computed, watch, PropType } from 'vue'
  import VChart from 'vue-echarts'
  import { useCanvasInitOptions } from '@/hooks/useCanvasInitOptions.hook'
  import { use } from 'echarts/core'
  import { CanvasRenderer } from 'echarts/renderers'
  import {  PictorialBarChart } from 'echarts/charts'
  import { mergeTheme } from '@/packages/public/chart'
  import config, { includes, seriesItem } from './config'
  import { useChartDataFetch } from '@/hooks'
  import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
  import isObject from 'lodash/isObject'
  import cloneDeep from 'lodash/cloneDeep'
  
  const props = defineProps({
    themeSetting: {
      type: Object,
      required: true
    },
    themeColor: {
      type: Object,
      required: true
    },
    chartConfig: {
      type: Object as PropType<config>,
      required: true
    }
  })
  
  const initOptions = useCanvasInitOptions(props.chartConfig.option, props.themeSetting)
  
  use([DatasetComponent, CanvasRenderer,  PictorialBarChart, GridComponent, TooltipComponent, LegendComponent])
  
  const replaceMergeArr = ref<string[]>()
  
  const option = computed(() => {
    return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
  })
  
  // dataset 无法变更条数的补丁
  watch(
    () => props.chartConfig.option.dataset,
    (newData: { dimensions: any }, oldData) => {
      try {
        if (!isObject(newData) || !('dimensions' in newData)) return
        if (Array.isArray(newData?.dimensions)) {
          const seriesArr = []
          for (let i = 0; i < newData.dimensions.length - 1; i++) {
            seriesArr.push(cloneDeep(seriesItem))
          }
          replaceMergeArr.value = ['series']
          props.chartConfig.option.series = seriesArr
          nextTick(() => {
            replaceMergeArr.value = []
          })
        }
      } catch (error) {
        console.log(error)
      }
    },
    {
      deep: false
    }
  )
  
  const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
    props.chartConfig.option.dataset = newData
  })
  </script>
  

8  在src\packages\components\Charts\Others的文件index.ts新增配置如下:

9  运行C#后端程序(参考文章最前面给的链接大屏开源项目go-view二次开发1----环境搭建(C#)-CSDN博客),并在前端输入npm run dev命令运行后,效果图如下:

源码可以从这里获取:

张祥裕/分享的资源名称 - Gitee.com

好了,本文的内容到此结束

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2259965.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

ORB-SLAM3源码学习:G2oTypes.cc: void EdgeInertial::computeError 计算预积分残差

前言 这部分函数涉及了g2o的内容以及IMU相关的推导内容&#xff0c;需要你先去进行这部分的学习。 1.函数声明 void EdgeInertial::computeError() 2.函数定义 涉及到的IMU的公式&#xff1a; {// TODO Maybe Reintegrate inertial measurments when difference between …

Kafka - 消息乱序问题的常见解决方案和实现

文章目录 概述一、MQ消息乱序问题分析1.1 相同topic内的消息乱序1.2 不同topic的消息乱序 二、解决方案方案一&#xff1a; 顺序消息Kafka1. Kafka 顺序消息的实现1.1 生产者&#xff1a;确保同一业务主键的消息发送到同一个分区1.2 消费者&#xff1a;顺序消费消息 2. Kafka 顺…

[MoeCTF 2021]unserialize

[广东强网杯 2021 团队组]欢迎参加强网杯 这题简单&#xff0c;flag直接写在脸上 NSSCTF {Wec10m3_to_QwbCtF} [MoeCTF 2021]unserialize <?phpclass entrance {public $start;function __construct($start){// 构造函数初始化 $start 属性$this->start $start;}fun…

舌头分割数据集labelme格式2557张1类别

数据集格式&#xff1a;labelme格式(不包含mask文件&#xff0c;仅仅包含jpg图片和对应的json文件) 图片数量(jpg文件个数)&#xff1a;2557 标注数量(json文件个数)&#xff1a;2557 标注类别数&#xff1a;1 标注类别名称:["tongue"] 每个类别标注的框数&#xff1…

回归预测 | Matlab实现基于BiLSTM-Adaboost双向长短期记忆神经网络结合Adaboost集成学习回归预测

目录 效果一览基本介绍模型设计程序设计参考资料效果一览 基本介绍 回归预测 | Matlab实现基于BiLSTM-Adaboost双向长短期记忆神经网络结合Adaboost集成学习回归预测 模型设计 基于BiLSTM-Adaboost的回归预测模型结合了双向长短期记忆神经网络(BiLSTM)和Adaboost集成学习的…

Unity学习笔记(二)如何制作角色动画

前言 本文为Udemy课程The Ultimate Guide to Creating an RPG Game in Unity学习笔记 创建一个角色 我们的目的是创建一个可移动、跳跃、冲刺等动作的角色 需要的组件&#xff1a;Rigidbody&#xff08;用于创建物理规则&#xff09;、Collider&#xff08;用于检测碰撞&am…

嵌入式入门Day30

IO Day5 线程相关函数pthread_createpthread_selfpthread_exitpthread_join\pthread_detachpthread_cancelpthread_setcancelstatepthread_setcanceltype 作业 线程 线程是轻量化的进程&#xff0c;一个进程内可以有多个线程&#xff0c;至少包含一个线程&#xff08;主线程&a…

【Ubuntu】双硬盘安装双系统 Windows 和 Ubuntu

【Ubuntu】双硬盘安装双系统 Windows 和 Ubuntu 1 安装顺序2 Ubutnu 20.042.1 准备工作2.2 自定义分区2.3 遇到的一些问题 1 安装顺序 我选择先在一块 SSD 上安装 Windows 再在另一块 SSD 上安装 Ubuntu&#xff0c;建议先安装 Windows 2 Ubutnu 20.04 2.1 准备工作 制作启…

【Qt】QWidget中的常见属性及其功能(一)

目录 一、 enabled 例子&#xff1a; 二、geometry 例子&#xff1a; window fram 例子 &#xff1a; 四、windowTiltle 五、windowIcon 例子&#xff1a; qrc机制 创建qrc文件 例子&#xff1a; qt中的很多内置类都是继承自QWidget的&#xff0c;因此熟悉QWidget的…

iOS swift开发系列 -- tabbar问题总结

1.单视图如何改为tabbar&#xff0c;以便显示2个标签页 右上角➕&#xff0c;输入tabbar 找到控件&#xff0c;然后选中&#xff0c;把entrypoint移动到tabbar控件 2.改成tabbar&#xff0c;生成两个item&#xff0c;配置各自视图后&#xff0c;启动发现报错 Thread 1: “-[p…

Muduo网络库解析--网络模块(2)

前文 重写Muduo库实现核心模块的Git仓库 注&#xff1a;本文将重点剖析 Muduo 网络库的核心框架&#xff0c;深入探讨作者精妙的代码设计思路&#xff0c;并针对核心代码部分进行重写&#xff0c;将原本依赖 boost 的实现替换为原生的 C11 语法。需要说明的是&#xff0c;本文…

电脑怎么设置通电自动开机(工控机)

操作系统&#xff1a;win10 第一步&#xff0c;电脑开机时按del键进入bios页面。 第二步&#xff0c;选择advanced下的IT8712 Super IO Configuration 第三步&#xff0c;找到Auto Power On&#xff0c;将其从Power off设置为Power On 第四步&#xff0c;F10保存&#xff0c;大…

如何对小型固定翼无人机进行最优的路径跟随控制?

控制架构 文章继续采用的是 ULTRA-Extra无人机&#xff0c;相关参数如下&#xff1a; 这里用于guidance law的无人机运动学模型为&#xff1a; { x ˙ p V a cos ⁡ γ cos ⁡ χ V w cos ⁡ γ w cos ⁡ χ w y ˙ p V a cos ⁡ γ sin ⁡ χ V w cos ⁡ γ w sin ⁡ χ…

基于Redis实现令牌桶算法

基于Redis实现令牌桶算法 令牌桶算法算法流程图优点缺点 实现其它限流算法 令牌桶算法 令牌桶是一种用于分组交换和电信网络的算法。它可用于检查数据包形式的数据传输是否符合定义的带宽和突发性限制&#xff08;流量不均匀或变化的衡量标准&#xff09;。它还可以用作调度算…

学习threejs,局部纹理刷新,实现图片分块加载

&#x1f468;‍⚕️ 主页&#xff1a; gis分享者 &#x1f468;‍⚕️ 感谢各位大佬 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍⚕️ 收录于专栏&#xff1a;threejs gis工程师 文章目录 一、&#x1f340;前言1.1 ☘️Texture 贴图 二、&#x1…

超标量处理器设计笔记(10) 寄存器重命名过程的恢复、分发

重命名 寄存器重命名过程的恢复使用 Checkpoint 对 RAT 进行恢复使用 WALK 对 RAT 进行恢复使用 Architecture State 对 RAT 进行恢复总结 分发&#xff08;Dispatch&#xff09; 寄存器重命名过程的恢复 当发生异常、分支预测失败时&#xff0c;指令占用 RAT、ROB 和 Issue …

海康萤石摄像机接入EasyNVR流程:开启RTSP-》萤石视频添加到EasyNVR-》未来支持海康SDK协议添加到EasyNVR

EasyNVR目前支持GB28181、RTSP、ONVIF、RTMP&#xff08;推流&#xff09;这几种协议接入&#xff0c;目前正在增加海康HIKSDK、大华DHSDK等几种SDK的接入&#xff0c;我们今天就介绍一下萤石摄像机怎么通过RTSP接入到EasyNVR。 第一步&#xff1a;萤石摄像机开启 萤石设备默…

Qt编写的文件传输工具

使用QT编写的文件传输工具 文件传输工具通过发送udp广播消息将IP广播给其他开启该程序的局域网机器 文件传输工具 通过发送udp广播消息将IP广播给其他开启该程序的局域网机器 收到的广播消息可以显示在IP地址列表中&#xff0c;点击IP地址可以自动填充到IP地址栏内 选择文件…

【潜意识Java】深入理解 Java 面向对象编程(OOP)

目录 什么是面向对象编程&#xff08;OOP&#xff09;&#xff1f; 1. 封装&#xff08;Encapsulation&#xff09; Java 中的封装 2. 继承&#xff08;Inheritance&#xff09; Java 中的继承 3. 多态&#xff08;Polymorphism&#xff09; Java 中的多态 4. 抽象&…

PWM调节DCDC参数计算原理

1、动态电压频率调整DVFS SOC芯片的核电压、GPU电压、NPU电压、GPU电压等&#xff0c;都会根据性能和实际应用场景来进行电压和频率的调整。 即动态电压频率调整DVFS&#xff08;Dynamic Voltage and Frequency scaling&#xff09;&#xff0c;优化性能和功耗。 比如某SOC在…