【Echart Bug记录】z / z2 / zlevel of displayable is invalid, which may cause unexpected errors

BUG:首将鼠标放在图表上时会出现此警告

在这里插入图片描述
在这里插入图片描述

解决方案

需要在 echarts 系列选项中声明“zlevel”和“z”属性。
series: [ { name: …, areaStyle…, itemStyle …, zlevel: 9 , z: 9, data: …, }

文档链接

series: [
              {
                name: newData.seriesData[0].year + '年',
                data: newData.seriesData[0].data,
                type: 'line',
                smooth: true,
                showSymbol: false,
                zlevel: 1,
                z: 1,
                lineStyle: {
                  width: 2,
                  color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [
                    {
                      offset: 0,
                      color: 'rgba(255, 241, 168, 1)',
                    },
                    {
                      offset: 0.5,
                      color: 'rgba(255, 225, 67, 1)',
                    },
                    {
                      offset: 1,
                      color: 'rgba(198, 202, 1, 1)',
                    },
                  ]),
                },
                areaStyle: {
                  color: new this.$echarts.graphic.LinearGradient(
                    0,
                    0,
                    0,
                    1,
                    [
                      {
                        offset: 0,
                        color: 'rgba(255, 214, 0, 0.18)',
                      },
                      {
                        offset: 1,
                        color: 'rgba(204, 255, 0, 0)',
                      },
                    ],
                    false
                  ),
                },
              },
              {
                name: newData.seriesData[1].year + '年',
                data: newData.seriesData[1].data,
                type: 'line',
                smooth: true,
                showSymbol: false,
                zlevel: 2,
                z: 2,
                lineStyle: {
                  width: 2,
                  color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [
                    {
                      offset: 0,
                      color: 'rgba(154, 255, 225, 1)',
                    },
                    {
                      offset: 0.5,
                      color: 'rgba(0, 255, 178, 1)',
                    },
                    {
                      offset: 1,
                      color: 'rgba(0, 172, 120, 1)',
                    },
                  ]),
                },
                areaStyle: {
                  color: new this.$echarts.graphic.LinearGradient(
                    0,
                    0,
                    0,
                    1,
                    [
                      {
                        offset: 0,
                        color: 'rgba(75, 255, 179, 0.25)',
                      },
                      {
                        offset: 1,
                        color: 'rgba(72, 255, 134, 0)',
                      },
                    ],
                    false
                  ),
                },
              },
              {
                name: newData.seriesData[2].year + '年',
                data: newData.seriesData[2].data,
                type: 'line',
                smooth: true,
                showSymbol: false,
                lineStyle: {
                  width: 2,
                  color: '#179DFF',
                },
                zlevel: 3,
                z: 3,
                areaStyle: {
                  color: new this.$echarts.graphic.LinearGradient(
                    0,
                    0,
                    0,
                    1,
                    [
                      {
                        offset: 0,
                        color: 'rgba(48, 156, 255, 0.3)',
                      },
                      {
                        offset: 1,
                        color: 'rgba(72, 167, 255, 0)',
                      },
                    ],
                    false
                  ),
                },
              },
            ],
  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,以下是我给出的C++代码,用于UG/NX二次开发环境下,在ug8.5和vs2010的环境下,编写一个用UIBlock的线性尺寸改变实体的长宽高。 ```cpp #include <NXOpen/BlockStyler_UIBlock.hxx> #include <NXOpen/BlockStyler.hxx> #include <NXOpen/Callback.hxx> #include <NXOpen/DisplayableObject.hxx> #include <NXOpen/DisplayableObjectCollection.hxx> #include <NXOpen/DisplayPart.hxx> #include <NXOpen/Part.hxx> #include <NXOpen/PartCollection.hxx> #include <NXOpen/Point.hxx> #include <NXOpen/Selection.hxx> #include <NXOpen/SelectionIntentRule.hxx> #include <NXOpen/SessionFactory.hxx> #include <NXOpen/Session.hxx> #include <NXOpen/SimpleDimension.hxx> #include <NXOpen/TaggedObject.hxx> #include <NXOpen/Unit.hxx> #include <NXOpen/UnitCollection.hxx> #include <NXOpen/Update.hxx> #include <NXOpen/Updater.hxx> #include <NXOpen/View.hxx> #include <NXOpen/ViewCollection.hxx> #include <NXOpen/WorkPart.hxx> #include <iostream> using namespace NXOpen; using namespace NXOpen::BlockStyler; // Callback object to handle events in the UI block class LinearDimensionCallback : public NXOpen::Callback { public: LinearDimensionCallback(UIBlock* block, Part* part, SimpleDimension* dimensionX, SimpleDimension* dimensionY, SimpleDimension* dimensionZ) : m_block(block), m_part(part), m_dimensionX(dimensionX), m_dimensionY(dimensionY), m_dimensionZ(dimensionZ) {} virtual ~LinearDimensionCallback() {} virtual void Notify(NXOpen::CallbackType type, NXOpen::TaggedObject* obj) { if (type == NXOpen::CallbackType_Create) { // Subscribe to the block's value change event m_block->AddValueChangeListener(this); } else if (type == NXOpen::CallbackType_ValueChanged) { // Get the current values of the UI block double xValue, yValue, zValue; m_block->GetDouble("XValue", xValue); m_block->GetDouble("YValue", yValue); m_block->GetDouble("ZValue", zValue); // Create a unit object to represent millimeters Unit* unit = m_part->UnitCollection()->FindObject("MilliMeter"); // Update the dimensions of the entity m_dimensionX->SetDimension(xValue, unit); m_dimensionY->SetDimension(yValue, unit); m_dimensionZ->SetDimension(zValue, unit); // Update the part display to show the changes m_part->UpdateManager()->DoUpdate(); } } private: UIBlock* m_block; Part* m_part; SimpleDimension* m_dimensionX; SimpleDimension* m_dimensionY; SimpleDimension* m_dimensionZ; }; // Function to create a block with three double values for the X, Y, and Z dimensions UIBlock* CreateDimensionBlock(UIBlock* parent, const char* name, double initialValue) { UIBlock* block = parent->AddBlock(name); block->SetProperty(UIBlock::PROP_LABEL, name); block->SetProperty(UIBlock::PROP_TYPE, UIBlock::TYPE_DOUBLE); block->SetDouble(initialValue); block->SetProperty(UIBlock::PROP_WIDTH_WEIGHT, 1); block->SetProperty(UIBlock::PROP_HEIGHT_WEIGHT, 1); block->SetProperty(UIBlock::PROP_DISPLAY_UNITS, "MilliMeter"); return block; } // Function to create a linear dimension entity with three dimensions void CreateLinearDimension(Part* part, const char* name, TaggedObject* entity, const char* xName, const char* yName, const char* zName) { // Create a unit object to represent millimeters Unit* unit = part->UnitCollection()->FindObject("MilliMeter"); // Create the dimensions for the X, Y, and Z axes SimpleDimension* dimensionX = part->Dimensions()->CreateLinearDimension(entity, NXOpen::Annotations::DimensionOrientation_X_Axis, NULL, unit, 0); SimpleDimension* dimensionY = part->Dimensions()->CreateLinearDimension(entity, NXOpen::Annotations::DimensionOrientation_Y_Axis, NULL, unit, 0); SimpleDimension* dimensionZ = part->Dimensions()->CreateLinearDimension(entity, NXOpen::Annotations::DimensionOrientation_Z_Axis, NULL, unit, 0); // Set the names of the dimensions dimensionX->SetDimensionName(xName); dimensionY->SetDimensionName(yName); dimensionZ->SetDimensionName(zName); // Create a displayable object for the entity DisplayableObject* displayObject = part->DisplayManager()->CreateDisplayableObject(entity); DisplayableObjectCollection displayObjects(part->DisplayManager()); displayObjects.Add(displayObject); // Create a view for the entity View* view = part->ViewCollection()->Create("Linear Dimension View"); view->SetVisibility(displayObjects, true); view->SetVisibilityOfSketchCurves(false); // Set the orientation of the view Point* origin = part->Points()->CreatePoint(0, 0, 0); view->SetOrientation(origin, NXOpen::View::Orientation_Top, NXOpen::View::Orientation_Inferred); // Update the part display to show the new entity part->UpdateManager()->DoUpdate(); // Create a dialog block to allow the user to change the dimensions BlockDialog* dialog = BlockDialog::AskBlockingDialog("Change Dimensions"); UIBlock* xBlock = CreateDimensionBlock(dialog->TopBlock(), xName, dimensionX->Value()); UIBlock* yBlock = CreateDimensionBlock(dialog->TopBlock(), yName, dimensionY->Value()); UIBlock* zBlock = CreateDimensionBlock(dialog->TopBlock(), zName, dimensionZ->Value()); LinearDimensionCallback* callback = new LinearDimensionCallback(dialog->TopBlock(), part, dimensionX, dimensionY, dimensionZ); dialog->SetApplyCallback(callback); dialog->SetCloseCallback(callback); dialog->SetModal(true); dialog->Show(); // Clean up memory delete callback; delete zBlock; delete yBlock; delete xBlock; delete view; delete origin; delete displayObject; } // Main entry point of the program extern "C" DllExport void ufusr(char* param, int* returnCode, int paramLen) { try { // Initialize the NXOpen session Session* session = SessionFactory::GetSession(); session->Parts()->Work(); // Get the current selection, which should be an entity Selection* selection = session->SelectionManager()->GetSelection(); std::vector<TaggedObject*> selectedObjects = selection->GetSelectedObjects(); if (selectedObjects.empty()) { std::cerr << "No entity selected" << std::endl; *returnCode = 1; return; } TaggedObject* entity = selectedObjects[0]; // Create a linear dimension for the entity Part* part = session->Parts()->Work(); CreateLinearDimension(part, "Linear Dimension", entity, "Length", "Width", "Height"); // Clean up memory and exit the program delete selection; *returnCode = 0; } catch (const NXOpen::NXException& ex) { std::cerr << "NXOpen exception: " << ex.Message() << std::endl; *returnCode = 1; } catch (const std::exception& ex) { std::cerr << "Exception: " << ex.what() << std::endl; *returnCode = 1; } } ``` 这个程序会创建一个UIBlock对话框,其中包含三个用于输入实体长度、宽度和高度的文本框。当用户更改这些值时,程序将更新实体的线性尺寸,并在屏幕上显示更改。请注意,这个程序是作为NXOpen插件编写的,需要将它编译为DLL,并在NX中加载它。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值