Articles in this section
Category / Section

How to Customize the Shape Colors Using Color Picker in Vue Diagram?

3 mins read

This article explains how to customize the shape colors using the Color Picker in Vue Diagram. To customize the color of shapes in the Vue Diagram, you can use the fill property of shapes. This property allows you to set the color of shapes in the diagram.

Refer to the code snippet below to customize the color of nodes using the fill property:

// Set fill property to customize color of nodes
var nodes = [
   {
       id:'node1',
       offsetX: 250,
       offsetY: 250,
       width: 100,
       height: 100,
       style: {fill:'white'}
   }
] 

To dynamically customize the color of shapes in your diagram, you can use the color picker component Vue ColorPicker. The color picker allows users to select a color, which is then applied to the fill property of the shapes in the diagram. This updates the color of the shapes in real-time, providing a smooth and interactive way to customize the appearance of elements in your diagram.

Refer to the code snippet below to customize the color of shapes:

import { ColorPickerComponent} from "@syncfusion/ej2-vue-inputs";

colorPicker: function () {
       return {
         template: createApp({}).component('colorPicker', {
           template:
             '<ejs-colorpicker mode="Palette" :showButtons="false" :change="onChangeColor"></ejs-colorpicker>',
           components: {
             'ejs-colorpicker': ColorPickerComponent,
           },
           data() {
             return {
               onChangeColor: function (args) {
                 var diagram = document.getElementById('diagram').ej2_instances[0];
                 for (var i = 0; i < diagram.selectedItems.nodes.length; i++) {
                   var node = diagram.selectedItems.nodes[i];
                   node.style.fill = args.value;
                   diagram.dataBind();
                 }
               },
             };
           },
         }),
       };
     }

Refer to the working sample for additional details and implementation: click here for sample

Conclusion

We hope you enjoyed learning how to customize the shape colors using the Color Picker in Vue Diagram.

You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied